-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
80 lines (70 loc) · 1.13 KB
/
utils.js
File metadata and controls
80 lines (70 loc) · 1.13 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const { dirname } = require('path');
const __root = dirname(require.main.filename);
const fs = require('fs').promises;
const Tagger = require('wink-pos-tagger');
// See: https://winkjs.org/wink-pos-tagger/
const tagger = Tagger();
const partsOfSpeech = [
'CC',
'CD',
'DT',
'EX',
'FW',
'IN',
'JJ',
'JJR',
'JJS',
'LS',
'MD',
'NN',
'NNS',
'NNP',
'NNPS',
'PDT',
'POS',
'PRP',
'PRP$',
'RB',
'RBR',
'RBS',
'RP',
'SYM',
'TO',
'UH',
'VB',
'VBD',
'VBG',
'VBN',
'VBP',
'VBZ',
'WDT',
'WP',
'WP$',
'WRB'
];
module.exports = {
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789#$%&',
vowels: 'aeiou',
y: 'y',
x: 'x',
w: 'w',
k: 'k',
j: 'j',
partsOfSpeech,
getPartsOfSpeech: text => (
tagger.tagSentence(text)
),
isLowerCase: letter => (
letter === letter.toLowerCase() &&
letter !== letter.toUpperCase()
),
toSentenceCase: string => (
string.replace(string.charAt(0), string.charAt(0).toUpperCase())
),
tokenize: input => (
input
.trim()
.replace(/[\p{P}$+<=>^`(\\\n)|~]/gu, ' ')
.split(' ')
)
};