57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
dChar.set(c, nChar);
lChar.push(c);
nChar += 1;
}
dCharOccur.set(c, dCharOccur.gl_get(c, 0) + 1);
}
// affixes to find stem from flexion
sAff = funcStemmingGen(sFlex, sStem);
if (!dAff.get(sAff)) {
dAff.set(sAff, nAff);
lAff.push(sAff);
nAff += 1;
}
dAffOccur.set(sAff, dCharOccur.gl_get(sAff, 0) + 1);
// tags
|
|
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
dChar.set(c, nChar);
lChar.push(c);
nChar += 1;
}
dCharOccur.set(c, dCharOccur.gl_get(c, 0) + 1);
}
// affixes to find stem from flexion
let sAff = funcStemmingGen(sFlex, sStem);
if (!dAff.get(sAff)) {
dAff.set(sAff, nAff);
lAff.push(sAff);
nAff += 1;
}
dAffOccur.set(sAff, dCharOccur.gl_get(sAff, 0) + 1);
// tags
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
lEntry.length = 0; // clear the array
// Dictionary of arc values occurrency, to sort arcs of each node
let lKeyVal = [];
for (let c of dChar.keys()) { lKeyVal.push([dChar[c], dCharOccur[c]]); }
for (let sAff of dAff.keys()) { lKeyVal.push([dAff[sAff]+nChar, dAffOccur[sAff]]); }
for (let sTag in dTag.keys()) { lKeyVal.push([dTag[sTag]+nChar+nAff, dTagOccur[sTag]]); }
dValOccur = new Map(lKeyVal);
lKeyVal.length = 0; // clear the array
//with open(spfSrc[:-8]+".valuesfreq.txt", 'w', encoding='utf-8') as hFreqDst: # DEBUG
// for iKey, nOcc in sorted(dValOccur.entries(), key=lambda t: t[1], reverse=True):
// hFreqDst.write("{}: {}\n".format(lVal[iKey], nOcc))
// hFreqDst.close()
|
|
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
lEntry.length = 0; // clear the array
// Dictionary of arc values occurrency, to sort arcs of each node
let lKeyVal = [];
for (let c of dChar.keys()) { lKeyVal.push([dChar[c], dCharOccur[c]]); }
for (let sAff of dAff.keys()) { lKeyVal.push([dAff[sAff]+nChar, dAffOccur[sAff]]); }
for (let sTag in dTag.keys()) { lKeyVal.push([dTag[sTag]+nChar+nAff, dTagOccur[sTag]]); }
let dValOccur = new Map(lKeyVal);
lKeyVal.length = 0; // clear the array
//with open(spfSrc[:-8]+".valuesfreq.txt", 'w', encoding='utf-8') as hFreqDst: # DEBUG
// for iKey, nOcc in sorted(dValOccur.entries(), key=lambda t: t[1], reverse=True):
// hFreqDst.write("{}: {}\n".format(lVal[iKey], nOcc))
// hFreqDst.close()
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
}
_parseNodes (oNode) {
// Warning: recursive method
if (oNode.pos > 0) {
return;
}
oNode.setPos();
this.lSortedNodes.append(oNode);
for (let oNextNode of oNode.arcs.values()) {
this._parseNodes(oNextNode);
}
}
lookup (sWord) {
let oNode = this.oRoot;
|
|
|
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
}
_parseNodes (oNode) {
// Warning: recursive method
if (oNode.pos > 0) {
return;
}
//oNode.setPos(); // version 2
this.lSortedNodes.push(oNode);
for (let oNextNode of oNode.arcs.values()) {
this._parseNodes(oNextNode);
}
}
lookup (sWord) {
let oNode = this.oRoot;
|