Skip to content
Snippets Groups Projects
Commit 780dcefe authored by Millicent Billette's avatar Millicent Billette
Browse files

v3.5.5

FIX: Dictonary lowerCase option now have only 3 mode but there are more consistent : 0 for no change (like before) 1 for classic variation ALL UPPERCASE, all lowercase, First Letter Only (and original string) 2 for Every individual variation from Capitalized version.
MAJ: bump dependencies version.
parent 10bb518a
Branches
Tags v3.5.5
No related merge requests found
Pipeline #18337 passed with warnings
......@@ -14,6 +14,10 @@ et ce projet adhère au [versionnage sémantique](https://semver.org/spec/v2.0.0
## [Non-publié/Non-Stabilisé] (par [1000i100])
## [Version 3.5.5] - 2022-12-31 (par [1000i100])
### Corrections
- Dans dictionary et dictionary-parser, les différents modes autour des majuscules sont désormais strictement progressif : 0 tel quel, 1 TOUT MAJUSCULE + tout minuscule + Première Lettre En Majuscule, 2 comme 1 mais en passant en minuscule chaque caractère individuellement.
## [Version 3.5.4] - 2022-12-17 (par [1000i100])
### Corrections
- Dictionary bascule en mode sans échec (non regex) si l'interprétation du texte fourni échoue (ou si options.escapeAll=1)
......
{
"name": "g1lib",
"version": "3.5.4",
"version": "3.5.5",
"description": "An ubiquitous static javascript toolbox lib for Ǧ1 / Duniter ecosystem with reliability in mind.",
"main": "nodejs/all.mjs",
"browser": "browser/all.mjs",
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -52,20 +52,20 @@
"@jscpd/badge-reporter": "^3.4.5",
"ava": "^5.1.0",
"badgen": "^3.2.2",
"browser-ava": "^1.1.0",
"browser-ava": "^1.3.13",
"c8": "^7.12.0",
"chokidar-cli": "^3.0.0",
"codehawk-cli": "^10.0.1",
"es6-plato": "https://github.com/1000i100/es6-plato#master",
"esbuild": "^0.15.15",
"esbuild": "^0.16.12",
"eslint-plugin-ava": "^13.2.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unicorn": "^45.0.0",
"jscpd": "^3.5.1",
"eslint-plugin-unicorn": "^45.0.2",
"jscpd": "^3.5.3",
"mkdirp": "^1.0.4",
"npm-run-all": "^4.1.5",
"rollup": "^3.4.0",
"xo": "^0.53.1"
"rollup": "^3.9.0",
"xo": "^0.44.0"
},
"disabledDependenciesTODOAddComplexityQualityCheck": {
"ecma-nacl": "^2.5.0",
......
......@@ -33,10 +33,8 @@ function parseEnd(str,allLines,options) {
theString = qtyHandler(theString);
if(options.accent===1) theString = zeroAccent(theString);
if(options.accent===2) theString = optionalAccent(theString);
if(options.lowerCase===1) theString = zeroUpperCase(theString);
if(options.lowerCase===2) theString = optionalUpperCase(theString);
if(options.lowerCase===3) theString = allUpperCase(allCapitalized(theString));
if(options.lowerCase===4) theString = optionalCapitalized(theString);
if(options.lowerCase===1) theString = allCase(theString);
if(options.lowerCase===2) theString = optionalCase(theString);
if(options.leetSpeak===1) theString = optionalLeetSpeak(theString);
if(options.leetSpeak===2) theString = allLeetSpeak(theString);
if(options.leetSpeak===3) theString = everyLeetSpeak(theString);
......@@ -57,6 +55,12 @@ function zeroAccent(string) {
function optionalAccent(string) {
return optionalVariant(string,zeroAccent);
}
function allCase(string) {
return flattenIt(`(${allCapitalized(string)}|${allUpperCase(string)}|${zeroUpperCase(string)})`);
}
function optionalCase(string) {
return flattenIt(`(${string.toUpperCase()}|${optionalCapitalized(string)})`);
}
function zeroUpperCase(string) {
return zeroVariant(string,str=>str.toLowerCase() );
}
......@@ -72,7 +76,8 @@ function allCapitalized(string) {
return zeroVariant(str,()=>str2 );
}
function optionalCapitalized(string) {
return optionalUpperCase(allCapitalized(string));
let str = string.split(' ').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(' ');
return optionalUpperCase(str);
}
function zeroLeetSpeak(string) {
return zeroVariant(string,fromLeet);
......
......@@ -99,10 +99,10 @@ test('throw if multiple @@ in the same sequence', t => t.throws(() => app.parse(
test('add no accents variant', t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, accent:1}), '(G1GdiT ici|Ǧ1ǦdiT ici)'));
test('add optional accents variants', t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, accent:2}), '(G|Ǧ)1(G|Ǧ)diT ici'));
test('add lowercase variant', t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, lowerCase:1}), '(Ǧ1ǦdiT ici|ǧ1ǧdit ici)'));
test('add optional lowercase variant', t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, lowerCase:2}), '|ǧ)1(Ǧ|ǧ)di(T|t) ici'));
test('add uppercase variants', t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, lowerCase:3}), '(Ǧ1ǦDIT ICI|Ǧ1ǦdiT Ici|Ǧ1ǦdiT ici|Ǧ1ǧdit Ici)'));
//test('add optional capitalized variants', t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, lowerCase:4}), '(Ǧ|ǧ)1(Ǧ|ǧ)di(T|t) (I|i)ci'));
test('add variant : FULL UPPERCASE, full lowercase, Capitalized Words',
t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, lowerCase:1}), '1ǦDIT ICI|Ǧ1ǦdiT Ici|Ǧ1ǦdiT ici|Ǧ1ǧdit Ici|ǧ1ǧdit ici)'));
test('add variant : FULL UPPERCASE and all partial lowercase variant from Capitalized',
t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, lowerCase:2}), '((Ǧ|ǧ)1(Ǧ|ǧ)di(T|t) (I|i)ci|Ǧ1ǦDIT ICI)'));
test('add no leetSpeak variants', t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, leetSpeak:1}), 'Ǧ(1|I|L|T|i|l|t)ǦdiT ici'));
test('add leetSpeak variants', t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, leetSpeak:2}), '(Ǧ1Ǧd1(1|7) 1c1|Ǧ1ǦdiT ici)'));
test('add every leetSpeak variants', t => t.is(app.parse('Ǧ1ǦdiT ici',{idSecPwd:false, leetSpeak:3}), 'Ǧ(1|I|L|T|i|l|t)Ǧd(1|I|L|T|i|l|t)(1|7|I|L|T|Y|i|l|t|y) (1|I|L|T|i|l|t)c(1|I|L|T|i|l|t)'));
......
......@@ -72,6 +72,7 @@ function adjustVariant(self){
}
let lastLess1hConfig;
while (self.estimateDuration() < durationGoal && self.length < self.config.cacheMax){
//console.log(`${parseInt(self.estimateDuration())}s, alt:${self.length} \\:${self.config.escapeAll} à:${self.config.accent} M:${self.config.lowerCase} 3:${self.config.leetSpeak}`, serialize(self.tree));
lastLess1hConfig = JSON.parse(JSON.stringify(self.config));
if(self.config.escapeAll !== 2 && (typeof self.originalConfig.escapeAll === 'undefined' || self.originalConfig.escapeAll === "auto")) {
self.config.escapeAll = 2;
......@@ -84,7 +85,7 @@ function adjustVariant(self){
rebuildTree(self);
continue;
}
if(self.config.lowerCase !== 4 && (typeof self.originalConfig.lowerCase === 'undefined' || self.originalConfig.lowerCase === "auto")) {
if(self.config.lowerCase !== 2 && (typeof self.originalConfig.lowerCase === 'undefined' || self.originalConfig.lowerCase === "auto")) {
if(!self.config.lowerCase) self.config.lowerCase = 1;
else self.config.lowerCase++;
rebuildTree(self);
......
......@@ -115,12 +115,12 @@ test('duplicate match §duplicate§ pattern', t => {
t.is(second, '§duplicate§a@@a');
});
test('dictionary called with speed option try to activate variante accent, caps and leetSpeak option to reach 1h of compute estimated time', t => {
const dictionaryString = 'Ǧ1Ǧ1';
const dico = new app.Dictionary(dictionaryString, {speed:30});
t.is(dico.length,272);
t.is(dico.duplicateTotal,16);
t.is(dico.duplicateRatio.toPrecision(3),'0.0588');
t.is(dico.uniqueRatio.toPrecision(3),'0.941');
const dictionaryString = 'Ǧ3Ǧo';
const dico = new app.Dictionary(dictionaryString, {speed:300});
t.is(dico.length,526257);
t.is(dico.duplicateTotal,194481);
t.is(dico.duplicateRatio.toPrecision(2),'0.37');
t.is(dico.uniqueRatio.toPrecision(2),'0.63');
});
test('auto activate leetSpeak for tiny case', t => {
const dictionaryString = 'a';
......@@ -186,11 +186,11 @@ test('escapeAll:2 -> everything is escaped', t => {
});
test('escapeAll:auto -> try 2 if too slow 0 if previous fail 1', t => {
const dico = new app.Dictionary('[0-1]{3}@@=autre>\nautre::ça',{escapeAll:'auto',speed:30});
t.is(dico.length, 77);
t.is(dico.length, 154);
});
test('escapeAll:undefined -> like auto', t => {
const dico = new app.Dictionary('[0-1]{3}@@=autre>\nautre::ça',{speed:30});
t.is(dico.length, 77);
t.is(dico.length, 154);
});
test('invalid string -> autofallback to escapeAll:1', t => {
const dico = new app.Dictionary('[0-1]{z}@@=autre>\nautre::ça');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment