-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparseRusToKalm.js
More file actions
41 lines (39 loc) · 890 Bytes
/
parseRusToKalm.js
File metadata and controls
41 lines (39 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const initial_dictionary = require('./ors_halmg_tol.json');
const R = require('ramda');
const startPoint = [
'соед.',
'межд.',
'нареч.',
'мн. ч.',
'нескл.',
'род. п.',
'предлог',
'м.',
'сущ.',
'союз',
'ед. ч.',
'накл.',
'усл.',
'cл.',
'частица',
'вводн. сл.',
'п.',
'сов.',
'числ.',
'двух-',
'сказ.',
')',
'вр.',
'прил.',
'I'
];
console.log(R.toPairs(initial_dictionary).map(([word, translate]) => {
const entries = startPoint.map(x => {
const index = translate.indexOf(x);
return [index, index + x.length]
}).filter(([x]) => x >= 0).reduce((res, x) => x.index > res.index ? x : res);
const startIndex = entries[0];
const result = translate.slice(startIndex);
console.log(word);
return result;
}).filter(R.identity).slice(0, 100))