Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// Oriya Bindu is Before_Sub in the spec.
if (codepoint.code === 0x0B01) {
position = 'Before_Sub';
}
return Math.log2(POSITIONS[position]);
}
let symbols = {};
for (let c in CATEGORIES) {
symbols[c] = Math.log2(CATEGORIES[c]);
}
let trie = new UnicodeTrieBuilder;
for (let i = 0; i < codepoints.length; i++) {
let codepoint = codepoints[i];
if (codepoint) {
let category = OVERRIDES[codepoint.code] || CATEGORY_MAP[codepoint.indicSyllabicCategory] || 'X';
let position = getPosition(codepoint, category);
trie.set(codepoint.code, (symbols[category] << 8) | position);
}
}
fs.writeFileSync(__dirname + '/indic.trie', trie.toBuffer());
let stateMachine = compile(fs.readFileSync(__dirname + '/indic.machine', 'utf8'), symbols);
fs.writeFileSync(__dirname + '/indic.json', JSON.stringify(stateMachine));
return USE;
}
function getCategory(code) {
for (let category in CATEGORIES) {
for (let pattern of CATEGORIES[category]) {
if (matches(pattern, {UISC: getUISC(code), UGC: code.category, U: code.code})) {
return getPositionalCategory(code, category);
}
}
}
return null;
}
let trie = new UnicodeTrieBuilder;
let symbols = {};
let numSymbols = 0;
let decompositions = {};
for (let i = 0; i < codepoints.length; i++) {
let codepoint = codepoints[i];
if (codepoint) {
let category = getCategory(codepoint);
if (!(category in symbols)) {
symbols[category] = numSymbols++;
}
trie.set(codepoint.code, symbols[category]);
if (codepoint.indicSyllabicCategory === 'Vowel_Dependent' && codepoint.decomposition.length > 0) {
decompositions[codepoint.code] = decompose(codepoint.code);
}
import codepoints from 'codepoints';
import fs from 'fs';
import UnicodeTrieBuilder from 'unicode-trie/builder';
let ShapingClasses = {
Non_Joining: 0,
Left_Joining: 1,
Right_Joining: 2,
Dual_Joining: 3,
Join_Causing: 3,
ALAPH: 4,
'DALATH RISH': 5,
Transparent: 6
};
let trie = new UnicodeTrieBuilder;
for (let i = 0; i < codepoints.length; i++) {
let codepoint = codepoints[i];
if (codepoint) {
if (codepoint.joiningGroup === 'ALAPH' || codepoint.joiningGroup === 'DALATH RISH') {
trie.set(codepoint.code, ShapingClasses[codepoint.joiningGroup] + 1);
} else if (codepoint.joiningType) {
trie.set(codepoint.code, ShapingClasses[codepoint.joiningType] + 1);
}
}
}
fs.writeFileSync(__dirname + '/data.trie', trie.toBuffer());