natural-content
Advanced tools
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 @@ |
{ | ||
"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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28299
1196