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

rosaenlg-filter

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rosaenlg-filter - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

8

dist/clean.js

@@ -10,3 +10,3 @@ "use strict";

let res = input;
let regexBetweenNewPara = new RegExp(`☚([${constants_1.allPunctList}\\s]+)☛`, 'g');
const regexBetweenNewPara = new RegExp(`☚([${constants_1.allPunctList}\\s]+)☛`, 'g');
res = res.replace(regexBetweenNewPara, function (match, between) {

@@ -16,3 +16,3 @@ // console.log('<' + between + '> is removed');

});
let regexOrphanDot = new RegExp(`☚([${constants_1.allPunctList}\\s]+)☚`, 'g');
const regexOrphanDot = new RegExp(`☚([${constants_1.allPunctList}\\s]+)☚`, 'g');
res = res.replace(regexOrphanDot, function (match, between) {

@@ -22,7 +22,7 @@ // console.log('<' + between + '> is removed');

});
let regexSpacesBeginning = new RegExp(`(\\s*)(☞[☞\\s]*)\\s+`, 'g');
const regexSpacesBeginning = new RegExp(`(\\s*)(☞[☞\\s]*)\\s+`, 'g');
res = res.replace(regexSpacesBeginning, function (match, before, between) {
return `${before}${between.replace(/\s/g, '')}`;
});
let regexSpacesEnd = new RegExp(`\\s+(☜[☜\\s]*)(\\s*)`, 'g');
const regexSpacesEnd = new RegExp(`\\s+(☜[☜\\s]*)(\\s*)`, 'g');
res = res.replace(regexSpacesEnd, function (match, between, after) {

@@ -29,0 +29,0 @@ return `${between.replace(/\s/g, '')}${after}`;

@@ -6,3 +6,3 @@ "use strict";

function getCompromiseValidArticle(input) {
let nlpRes = compromise(input)
const nlpRes = compromise(input)
.nouns()

@@ -25,8 +25,8 @@ .articles();

//console.log('xxx' + input);
let regexA = new RegExp(`([^${constants_1.tousCaracteresMinMajRe}])([aA])${constants_1.stdBetweenWithParenthesis}§([${constants_1.tousCaracteresMinMajRe}]*)`, 'g');
const regexA = new RegExp(`([^${constants_1.tousCaracteresMinMajRe}])([aA])${constants_1.stdBetweenWithParenthesis}§([${constants_1.tousCaracteresMinMajRe}]*)`, 'g');
res = res.replace(regexA, function (match, before, aA, between, word) {
//console.log(`<${before}> <${aA}> <${between}> <${word}>`);
let compResult = getCompromiseValidArticle(aA + ' ' + word);
const compResult = getCompromiseValidArticle(aA + ' ' + word);
if (compResult) {
let newAa = redoCapitalization(aA, compResult);
const newAa = redoCapitalization(aA, compResult);
return `${before}${newAa}${between}§${word}`;

@@ -45,8 +45,8 @@ }

let res = input;
let regexA = new RegExp(`([^${constants_1.tousCaracteresMinMajRe}])([aA])${constants_1.stdBetweenWithParenthesis}([${constants_1.tousCaracteresMinMajRe}]*)`, 'g');
const regexA = new RegExp(`([^${constants_1.tousCaracteresMinMajRe}])([aA])${constants_1.stdBetweenWithParenthesis}([${constants_1.tousCaracteresMinMajRe}]*)`, 'g');
res = res.replace(regexA, function (match, before, aA, between, word) {
// debug(`BEFORE PROTECT corresp:<${corresp}> first:<${first}> second:<${second}> third:<${third}>`);
let compResult = getCompromiseValidArticle(aA + ' ' + word);
const compResult = getCompromiseValidArticle(aA + ' ' + word);
if (compResult) {
let newAa = redoCapitalization(aA, compResult);
const newAa = redoCapitalization(aA, compResult);
return `${before}${newAa}${between}${word}`;

@@ -65,3 +65,3 @@ }

// debug("xx: "+ input);
let regexSS = new RegExp("(s\\s*§\\s*'s)([^" + constants_1.tousCaracteresMinMajRe + '])', 'g');
const regexSS = new RegExp("(s\\s*§\\s*'s)([^" + constants_1.tousCaracteresMinMajRe + '])', 'g');
res = res.replace(regexSS, function (corresp, first, second) {

@@ -79,3 +79,3 @@ // debug(`AAAA ${corresp} ${first} ${offset} ${orig}`);

// the <b>earrings</b> 's size => The <b>earrings</b>' size
let regexSS = new RegExp("s([☞☜\\s]*)'s([^" + constants_1.tousCaracteresMinMajRe + '])', 'g');
const regexSS = new RegExp("s([☞☜\\s]*)'s([^" + constants_1.tousCaracteresMinMajRe + '])', 'g');
res = res.replace(regexSS, function (match, between, after) {

@@ -82,0 +82,0 @@ // debug(`${corresp} ${first} ${offset} ${orig}`);

@@ -12,5 +12,5 @@ "use strict";

// gérer le cas où 'de' est en début de phrase
let regexDe = new RegExp(`${constants_1.stdBeforeWithParenthesis}(${contrList[i]})${constants_1.stdBetweenWithParenthesis}([${constants_1.toutesVoyellesMinMaj}h][${constants_1.tousCaracteresMinMajRe}]*)`, 'g');
const regexDe = new RegExp(`${constants_1.stdBeforeWithParenthesis}(${contrList[i]})${constants_1.stdBetweenWithParenthesis}([${constants_1.toutesVoyellesMinMaj}h][${constants_1.tousCaracteresMinMajRe}]*)`, 'g');
res = res.replace(regexDe, function (corresp, before, determiner, between, word) {
let newBetween = between.replace(/ /g, ''); // we contract thus keep no space
const newBetween = between.replace(/ /g, ''); // we contract thus keep no space
if (!french_h_muet_aspire_1.isHAspire(word)) {

@@ -28,6 +28,6 @@ return `${before}${determiner.substring(0, determiner.length - 1)}'${newBetween}${word}`;

{
let regexCe = new RegExp(`${constants_1.stdBeforeWithParenthesis}([Cc]e)${constants_1.stdBetweenWithParenthesis}([${constants_1.toutesVoyellesMinMaj}h][${constants_1.tousCaracteresMinMajRe}]*)`, 'g');
const regexCe = new RegExp(`${constants_1.stdBeforeWithParenthesis}([Cc]e)${constants_1.stdBetweenWithParenthesis}([${constants_1.toutesVoyellesMinMaj}h][${constants_1.tousCaracteresMinMajRe}]*)`, 'g');
res = res.replace(regexCe, function (corresp, before, determiner, between, word) {
// debug(`${before} ${determiner} ${word}`);
let newBetween = between;
const newBetween = between;
if (!french_h_muet_aspire_1.isHAspire(word)) {

@@ -53,7 +53,9 @@ return `${before}${determiner}t${newBetween}${word}`;

// de => [d|D]e
const firstPart = `[${rawFirstPart.substring(0, 1)}|${rawFirstPart.substring(0, 1).toUpperCase()}]${rawFirstPart.substring(1)}`;
const firstPart = `[${rawFirstPart.substring(0, 1)}|${rawFirstPart
.substring(0, 1)
.toUpperCase()}]${rawFirstPart.substring(1)}`;
// console.log(firstPart);
const secondPart = contrList[i][1];
const replacer = contrList[i][2];
let regexContr = new RegExp(`${constants_1.stdBeforeWithParenthesis}(${firstPart})${constants_1.stdBetweenWithParenthesis}${secondPart}${constants_1.stdBetweenWithParenthesis}`, 'g');
const regexContr = new RegExp(`${constants_1.stdBeforeWithParenthesis}(${firstPart})${constants_1.stdBetweenWithParenthesis}${secondPart}${constants_1.stdBetweenWithParenthesis}`, 'g');
res = res.replace(regexContr, function (match, before, part1, between, after) {

@@ -60,0 +62,0 @@ const isUc = part1.substring(0, 1).toLowerCase() != part1.substring(0, 1);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const blockLevelElts = ['address', 'article', 'aside', 'blockquote', 'canvas', 'dd', 'div', 'dl', 'dt', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1>-<h6', 'header', 'hr', 'li', 'main', 'nav', 'noscript', 'ol', 'p', 'pre', 'section', 'table', 'tfoot', 'ul', 'video'];
const inlineElts = ['a', 'abbr', 'acronym', 'b', 'bdo', 'big', 'br', 'button', 'cite', 'code', 'dfn', 'em', 'i', 'img', 'input', 'kbd', 'label', 'map', 'object', 'output', 'q', 'samp', 'script', 'select', 'small', 'span', 'strong', 'sub', 'sup', 'textarea', 'time', 'tt', 'var'];
const blockLevelElts = [
'address',
'article',
'aside',
'blockquote',
'canvas',
'dd',
'div',
'dl',
'dt',
'fieldset',
'figcaption',
'figure',
'footer',
'form',
'h1>-<h6',
'header',
'hr',
'li',
'main',
'nav',
'noscript',
'ol',
'p',
'pre',
'section',
'table',
'tfoot',
'ul',
'video',
];
const inlineElts = [
'a',
'abbr',
'acronym',
'b',
'bdo',
'big',
'br',
'button',
'cite',
'code',
'dfn',
'em',
'i',
'img',
'input',
'kbd',
'label',
'map',
'object',
'output',
'q',
'samp',
'script',
'select',
'small',
'span',
'strong',
'sub',
'sup',
'textarea',
'time',
'tt',
'var',
];
function replaceHtml(input) {
// console.log(input);
let replacedHtml = { replaced: null, elts: [] };
let regexHtml = new RegExp('<(/?)([a-zA-Z]+)[^>]*>', 'g');
const replacedHtml = { replaced: null, elts: [] };
const regexHtml = new RegExp('<(/?)([a-zA-Z]+)[^>]*>', 'g');
replacedHtml.replaced = input.replace(regexHtml, function (match, begin, tag) {

@@ -20,3 +84,4 @@ // console.log(`match: ${match} / tag: ${tag}`);

}
else { // inlineElts or other
else {
// inlineElts or other
if (begin === '/') {

@@ -36,9 +101,9 @@ return '☜';

// console.log(input);
let regexPlaceholder = new RegExp('[☛☚☞☜]', 'g');
let res = input.replace(regexPlaceholder, function (match, placeholder) {
const regexPlaceholder = new RegExp('[☛☚☞☜]', 'g');
const res = input.replace(regexPlaceholder, function (match, placeholder) {
//console.log(`match: ${match} / tag: ${placeholder}`);
let tag = elts.shift();
const tag = elts.shift();
//console.log(tag);
if (typeof tag === 'undefined') {
let err = new Error();
const err = new Error();
err.name = 'InternalError';

@@ -51,3 +116,3 @@ err.message = `There are not enough html tags`;

if (elts.length > 0) {
let err = new Error();
const err = new Error();
err.name = 'InternalError';

@@ -67,3 +132,3 @@ err.message = `There are left html tags: ${elts}`;

let res = input;
for (let key in protectMap) {
for (const key in protectMap) {
res = res.replace(protectMap[key], key);

@@ -76,3 +141,3 @@ }

let res = input;
for (let key in protectMap) {
for (const key in protectMap) {
res = res.replace(key, protectMap[key]);

@@ -79,0 +144,0 @@ }

@@ -23,4 +23,4 @@ "use strict";

let res = input;
let x = '\x41\x64\x64\x76\x65\x6E\x74\x61';
let regex = new RegExp(x, 'g');
const x = '\x41\x64\x64\x76\x65\x6E\x74\x61';
const regex = new RegExp(x, 'g');
res = res.replace(regex, x + ' 👍');

@@ -48,3 +48,3 @@ return res;

// PROTECT HTML TAGS
let replacedHtml = html.replaceHtml(res);
const replacedHtml = html.replaceHtml(res);
res = replacedHtml.replaced;

@@ -57,3 +57,3 @@ // ADD START to avoid the problem of the ^ in regexp

// PROTECT § BLOCKS
let protectedMappings = protect.protectBlocks(res);
const protectedMappings = protect.protectBlocks(res);
res = protectedMappings.protectedString;

@@ -77,3 +77,3 @@ res = applyFilters(res, [

// REMOVE START - has to be before UNPROTECT HTML TAGS
let regexRemoveStart = new RegExp('^START([☞\\s\\.]+)', 'g');
const regexRemoveStart = new RegExp('^START([☞\\s\\.]+)', 'g');
res = res.replace(regexRemoveStart, function (match, before) {

@@ -80,0 +80,0 @@ return `${before.replace(/[\s\.]*/g, '')}`;

@@ -5,3 +5,3 @@ "use strict";

function isConsonneImpure(word) {
let wordLc = word.toLowerCase();
const wordLc = word.toLowerCase();
const begins = ['ps', 'pn', 'gn', 'x', 'z'];

@@ -16,3 +16,3 @@ for (let i = 0; i < begins.length; i++) {

// s impur (autrement dit un s suivi d'une autre consonne)
let regexSImpur = new RegExp('^s[' + constants_1.toutesConsonnes + ']');
const regexSImpur = new RegExp('^s[' + constants_1.toutesConsonnes + ']');
if (regexSImpur.test(wordLc)) {

@@ -27,3 +27,3 @@ //console.log(`isConsonneImpure ${word}? => true`);

function isIFollowedByVowel(word) {
let regexISuiviVoyelle = new RegExp('^[IiYy][' + constants_1.toutesVoyellesMinuscules + ']');
const regexISuiviVoyelle = new RegExp('^[IiYy][' + constants_1.toutesVoyellesMinuscules + ']');
if (regexISuiviVoyelle.test(word)) {

@@ -36,3 +36,3 @@ return true;

function startsWithVowel(word) {
let regexVowel = new RegExp('^[' + constants_1.toutesVoyellesMinuscules + ']');
const regexVowel = new RegExp('^[' + constants_1.toutesVoyellesMinuscules + ']');
if (regexVowel.test(word.toLowerCase())) {

@@ -45,5 +45,5 @@ return true;

function getDetElt(determiner, capRef, between) {
let isUc = capRef.substring(0, 1).toLowerCase() != capRef.substring(0, 1);
let newDet = isUc ? determiner.substring(0, 1).toUpperCase() + determiner.substring(1) : determiner;
let newBetween = determiner.endsWith("'") ? between.replace(/ /g, '') : between.replace(/\s+/g, ' ');
const isUc = capRef.substring(0, 1).toLowerCase() != capRef.substring(0, 1);
const newDet = isUc ? determiner.substring(0, 1).toUpperCase() + determiner.substring(1) : determiner;
const newBetween = determiner.endsWith("'") ? between.replace(/ /g, '') : between.replace(/\s+/g, ' ');
return `${newDet}${newBetween}`;

@@ -50,0 +50,0 @@ }

@@ -13,3 +13,3 @@ "use strict";

let res = toUnprotect;
for (let key in mappings) {
for (const key in mappings) {
// debug('key/val: ' + key + '/' + mappings[key]);

@@ -22,9 +22,9 @@ res = res.replace(key, mappings[key]);

function protectBlocks(input) {
let regexProtect = new RegExp('§([^§]*)§', 'g');
let mappings = {};
const regexProtect = new RegExp('§([^§]*)§', 'g');
const mappings = {};
let index = 0;
let protectedInput = input.replace(regexProtect, function (corresp, first) {
const protectedInput = input.replace(regexProtect, function (corresp, first) {
// debug("§§§ :<" + corresp + '>' + first);
// must not start with E otherwise creates issues with French constractions: d'ESCAPED
let replacement = 'XESCAPED_SEQ_' + ++index;
const replacement = 'XESCAPED_SEQ_' + ++index;
mappings[replacement] = first;

@@ -31,0 +31,0 @@ return replacement;

@@ -10,6 +10,6 @@ "use strict";

// ['bla ! . bla', 'Bla! Bla'],
let regexDoublePunct = new RegExp(`([${constants_2.allPunctList}])((?:${constants_2.spaceOrNonBlockingClass}*[${constants_2.allPunctList}])*)`, 'g');
const regexDoublePunct = new RegExp(`([${constants_2.allPunctList}])((?:${constants_2.spaceOrNonBlockingClass}*[${constants_2.allPunctList}])*)`, 'g');
res = res.replace(regexDoublePunct, function (match, firstPunct, otherStuff) {
let regexRemovePunct = new RegExp(`[${constants_2.allPunctList}]`, 'g');
let removedPunct = otherStuff.replace(regexRemovePunct, function (match) {
const regexRemovePunct = new RegExp(`[${constants_2.allPunctList}]`, 'g');
const removedPunct = otherStuff.replace(regexRemovePunct, function (match) {
return '';

@@ -29,3 +29,3 @@ });

// all but . and ,
let regexAllButDot = new RegExp(`(${constants_2.spaceOrNonBlockingClass}*)([:!\\?;])(${constants_2.spaceOrNonBlockingClass}*)`, 'g');
const regexAllButDot = new RegExp(`(${constants_2.spaceOrNonBlockingClass}*)([:!\\?;])(${constants_2.spaceOrNonBlockingClass}*)`, 'g');
res = res.replace(regexAllButDot, function (match, before, punc, after) {

@@ -36,3 +36,3 @@ // console.log(`${match} <${before}> <${after}>`);

// . and , and …
let regexDot = new RegExp(`(${constants_2.spaceOrNonBlockingClass}*)([\\.,…])(${constants_2.spaceOrNonBlockingClass}*)`, 'g');
const regexDot = new RegExp(`(${constants_2.spaceOrNonBlockingClass}*)([\\.,…])(${constants_2.spaceOrNonBlockingClass}*)`, 'g');
res = res.replace(regexDot, function (match, before, punc, after) {

@@ -49,3 +49,3 @@ // console.log(`${match} <${before}> <${after}>`);

//console.log(res);
let regexPunct = new RegExp(`(${constants_2.spaceOrNonBlockingClass}*)([${constants_2.allPunctList}])(${constants_2.spaceOrNonBlockingClass}*)`, 'g');
const regexPunct = new RegExp(`(${constants_2.spaceOrNonBlockingClass}*)([${constants_2.allPunctList}])(${constants_2.spaceOrNonBlockingClass}*)`, 'g');
res = res.replace(regexPunct, function (match, before, punct, after) {

@@ -77,3 +77,3 @@ return `${before.replace(/\s/g, '')}${punct}${after.replace(/\s/g, '')} `;

// add spaces before '(' or after ')'
let regexSpaceBeforePar = new RegExp('[' + constants_1.tousCaracteresMinMajRe + ']\\(', 'g');
const regexSpaceBeforePar = new RegExp('[' + constants_1.tousCaracteresMinMajRe + ']\\(', 'g');
res = res.replace(regexSpaceBeforePar, function (corresp) {

@@ -83,3 +83,3 @@ // debug("BBB :<" + corresp + ">");

});
let regexSpaceAfterPar = new RegExp('\\)[' + constants_1.tousCaracteresMinMajRe + ']', 'g');
const regexSpaceAfterPar = new RegExp('\\)[' + constants_1.tousCaracteresMinMajRe + ']', 'g');
res = res.replace(regexSpaceAfterPar, function (corresp) {

@@ -96,3 +96,3 @@ // debug("BBB :<" + corresp + "><" + first + '>');

{
let regexCapsAfterDot = new RegExp(`(${triggerCaps})(${constants_2.spaceOrNonBlockingClass}*)([${constants_1.tousCaracteresMinMajRe}])`, 'g');
const regexCapsAfterDot = new RegExp(`(${triggerCaps})(${constants_2.spaceOrNonBlockingClass}*)([${constants_1.tousCaracteresMinMajRe}])`, 'g');
res = res.replace(regexCapsAfterDot, function (corresp, punct, before, firstWord) {

@@ -103,3 +103,3 @@ return `${punct}${before.replace(/\s/g, '')} ${firstWord.toUpperCase()}`;

{
let regexCapsAfterP = new RegExp(`([☛☚])(${constants_2.spaceOrNonBlockingClass}*)([${constants_1.tousCaracteresMinMajRe}])`, 'g');
const regexCapsAfterP = new RegExp(`([☛☚])(${constants_2.spaceOrNonBlockingClass}*)([${constants_1.tousCaracteresMinMajRe}])`, 'g');
res = res.replace(regexCapsAfterP, function (match, start, between, char) {

@@ -106,0 +106,0 @@ return `${start}${between.replace(/ /g, '')}${char.toUpperCase()}`;

@@ -8,3 +8,3 @@ "use strict";

const titlecaseFlag = '_TITLECASE_';
let regexTitlecase = new RegExp(`${titlecaseFlag}\\s*(.*?)\\s*${titlecaseFlag}`, 'g');
const regexTitlecase = new RegExp(`${titlecaseFlag}\\s*(.*?)\\s*${titlecaseFlag}`, 'g');
res = res.replace(regexTitlecase, function (corresp, first) {

@@ -20,3 +20,3 @@ // debug("TITLECASE :<" + corresp + '><' + first + '>');

// not supported for de_DE
let err = new Error();
const err = new Error();
err.name = 'InvalidArgumentError';

@@ -23,0 +23,0 @@ err.message = `titlecase is not available for ${lang}`;

{
"name": "rosaenlg-filter",
"version": "2.0.0",
"version": "2.0.1",
"description": "Filtering feature of RosaeNLG",

@@ -46,3 +46,3 @@ "main": "dist/index.js",

"debug": "^4.1.1",
"french-h-muet-aspire": "2.0.0",
"french-h-muet-aspire": "2.0.1",
"titlecase-french": "^1.0.1"

@@ -60,3 +60,3 @@ },

},
"gitHead": "ce11f9311a2d27e79a14683dc8753cf219f9d5fe"
"gitHead": "0dd72e95577b24b8cd4cc43ec5bef78f8b8df699"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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