Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

natural-content

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

natural-content - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

26

index.js

@@ -7,2 +7,12 @@ const diacritics = require('./lib/diacritics.js');

/**
* isFirstCharUpperCase - Check if the first letter of a statement is on uppercase
*
* @param {string} statement the statement
* @returns {boolean} true if the letter is upper case
*/
function isFirstCharUpperCase(statement) {
return /^[A-Z]/.test(statement);
}
/**
* getStatements - Get all statements from a text

@@ -19,7 +29,17 @@ *

.replace(/ +/g, WORD_SEPARATOR) // remove multiple spaces
.replace('...', STATEMENT_SEPARATOR)
.replace(/[.]{3}/g, `.${ STATEMENT_SEPARATOR }`)
.replace(/[.]/g, `.${ STATEMENT_SEPARATOR }`)
.replace(/[!]/g, `!${ STATEMENT_SEPARATOR }`)
.replace(/[?]/g, `?${ STATEMENT_SEPARATOR }`)
.replace(/[...]/g, `.${ STATEMENT_SEPARATOR }`)
.split(STATEMENT_SEPARATOR);
.split(STATEMENT_SEPARATOR)
.reduce((result, t) => {
if (t.trim() === '') {
return result;
}
result.push(t.trim());
return result;
}, []);
}

@@ -155,2 +175,4 @@

exports.isFirstCharUpperCase = isFirstCharUpperCase;
exports.getStatements = getStatements;

@@ -157,0 +179,0 @@

2

package.json
{
"name": "natural-content",
"version": "1.0.12",
"version": "1.0.13",
"description": "A set of natural functions like tf.idf, extract words & n-grams, remove diacritics, ... (experimental project)",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -18,5 +18,8 @@ const assert = require('assert');

it('Statements', () => {
const stats = natural.getStatements('word1 word2 word3 word4 :word5 word6. word7 word1, word8 word9 word10 word11 word6. word1 word12 word13');
const stats = natural.getStatements('word1 word2 word3 word4 :word5 word6. word7 word1, word8 word9 word10 word11 word6. Question? Word1 word12 word13!...End text.');
assert(stats.length === 3);
// console.log(stats);
assert(stats.length === 5);
// console.log(natural.getStatements(txt));
});

@@ -23,0 +26,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc