This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathscratch.js
More file actions
112 lines (99 loc) · 2.33 KB
/
Copy pathscratch.js
File metadata and controls
112 lines (99 loc) · 2.33 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const nlp = require('./src/index');
//nlp.verbose('tagger');
const tagSets = {
Device: {},
Room: {},
DeviceType: {},
Command: {},
Status: {},
'aa55d3cf-acdc-4413-8b04-edf33ccef4ac': {
isA: 'Device'
}
};
nlp.addTags(tagSets);
const words = {
'desk lamp': 'aa55d3cf-acdc-4413-8b04-edf33ccef4ac',
office: 'Room',
kitchen: 'Room',
upstairs: 'Room',
garage: 'Room',
on: 'Command',
off: 'Command',
open: 'Command',
close: 'Command',
lock: 'Command',
unlock: 'Command'
};
nlp.addWords(words);
const regEx = {
'light(?:(?:s|es)?)': 'DeviceType'
};
nlp.addRegex(regEx);
const patterns = {
'(#Device|#Command|#Value|#Unit)': 'DeviceAction',
'(#DeviceType|#Command|#Value|#Unit|#Room)': 'DeviceTypeAction'
};
nlp.addPatterns(patterns);
var doc = nlp('turn desk lamp on to fifty percent for ten minutes');
let level = doc
.values()
.toNice()
.noDates()
.out();
let delay = doc.match('#Duration+');
console.log(delay);
//console.log('Level: ', level, '\nDelay: ', delay);
/*
let actions = doc.match('(#DeviceAction|#DeviceTypeAction)');
for (let i = 0; i < actions.length; i++) {
console.log(actions.list[i].terms[0].text);
console.log(actions.list[i].terms[0].tags);
}
let doc = nlp('they\'d said').debug();
doc.verbs().toPastTense();
doc.debug();
// coming => com
// moving => mov
// joking => jok
// poking => pok
// naming => nam
// aching => ach
// tuning => tun
// bling => ble
// hazing => haz
// oozing => ooz
// gazing => gaz
// easing => eas
// dozing => doz
// raring => rar
// honing => hon
// fuming => fum
// razing => raz
// lied => ly
// shed => sh
// owed => ow
// aged => ag
// aced => ac
// axed => ax
// egged => eg
// Refactor
// Release
// Revert
// repeat
// rebuild
// reconcile
// record
// redefine
// recover
// restructure
// resolve
// nlp('pulled').verbs().toInfinitive().debug(); //pulle
// nlp('leaving').verbs().toInfinitive().debug(); //leav
// 5) sentence .topast/.toNegative/toPlural
// nlp('are really fun').verbs().toPastTense().debug();
// nlp('i am really walking on').verbs().toPastTense().debug();
// nlp('we\'re really fun').sentences().toPastTense().debug();
// console.log(nlp('we\'re really fun').verbs().data());
// console.log(nlp('i\'m really fun').verbs().data());
nlp('we\'re really fun').sentences().toPlural().debug();
*/