rosaenlg-commons
Version:
Common technical elements for RosaeNLG
58 lines • 2.08 kB
JavaScript
"use strict";
/**
* @license
* Copyright 2019 Ludan Stoecklé
* SPDX-License-Identifier: Apache-2.0
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Constants = void 0;
const voyellesSimplesMinuscules = 'aeiouy';
const correspondances = {
a: 'àáâãäå',
A: 'ÀÁÂ',
e: 'èéêë',
E: 'ÈÉÊË',
i: 'ìíîï',
I: 'ÌÍÎÏ',
o: 'òóôõöø',
O: 'ÒÓÔÕÖØ',
u: 'ùúûü',
U: 'ÙÚÛÜ',
y: 'ÿ',
c: 'ç',
C: 'Ç',
n: 'ñ',
N: 'Ñ',
};
class Constants {
constructor(allPunctList) {
this.toutesConsonnes = 'bcdfghjklmnpqrstvwxz';
this.spaceOrNonBlockingClass = '[\\s¤☞☜]';
// init order IS IMPORTANT
this.allPunctList = allPunctList;
this.toutesVoyellesMinuscules = this.getToutesVoyellesMinuscules();
this.tousCaracteresMinusculesRe = this.getTousCaracteresMinusculesRe();
this.toutesVoyellesMajuscules = this.toutesVoyellesMinuscules.toUpperCase();
this.toutesVoyellesMinMaj = this.toutesVoyellesMinuscules + this.toutesVoyellesMajuscules;
this.tousCaracteresMajusculesRe = this.tousCaracteresMinusculesRe.toUpperCase();
this.tousCaracteresMinMajRe = this.tousCaracteresMinusculesRe + '0-9' + this.tousCaracteresMajusculesRe + '\\-';
this.stdBetweenWithParenthesis = `(${this.spaceOrNonBlockingClass}+|$)`;
this.stdBeforeWithParenthesis = `([\\s¤☛☚☞☜${this.allPunctList}])`;
}
getToutesVoyellesMinuscules() {
let res = voyellesSimplesMinuscules;
for (const voyelleSimpleMinuscule of voyellesSimplesMinuscules) {
res = (res + correspondances[voyelleSimpleMinuscule]);
}
return res;
}
getTousCaracteresMinusculesRe() {
return 'a-z' + this.toutesVoyellesMinuscules;
}
getInBetween(beforeProtect) {
return beforeProtect ? '§[\\s¤]*' : '';
}
}
exports.Constants = Constants;
Constants.stdPunctList = '\\.:!\\?;,…'; // without ¡¿ for Spanish
//# sourceMappingURL=Constants.js.map