@indra.ai/deva.veda 0.2.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/processing/cleaner.json +1 -786
- package/data/processing/concepts.json +3 -1
- package/data/processing/groups.json +0 -1
- package/data/processing/people.json +198 -194
- package/data/processing/things.json +3 -2
- package/data/rigveda/books/01.json +1 -0
- package/data/rigveda/hymns/01003.json +1 -1
- package/func/index.js +76 -49
- package/methods/index.js +23 -15
- package/package.json +2 -2
- package/utils.js +38 -16
- package/data/manu/01.json +0 -288
- package/data/manu/02.json +0 -911
- package/data/manu/03.json +0 -1051
- package/data/manu/04.json +0 -862
- package/data/manu/05.json +0 -456
- package/data/manu/06.json +0 -316
- package/data/manu/07.json +0 -834
- package/data/manu/08.json +0 -2304
- package/data/manu/09.json +0 -1632
- package/data/manu/10.json +0 -379
- package/data/manu/11.json +0 -897
- package/data/manu/12.json +0 -274
- package/data/manu/index.js +0 -146
- package/data/rigveda/01.json +0 -1729
- package/data/rigveda/02.json +0 -397
- package/data/rigveda/03.json +0 -568
- package/data/rigveda/04.json +0 -532
- package/data/rigveda/05.json +0 -793
- package/data/rigveda/06.json +0 -685
- package/data/rigveda/07.json +0 -946
- package/data/rigveda/08.json +0 -937
- package/data/rigveda/09.json +0 -1036
- package/data/rigveda/10.json +0 -1729
package/func/index.js
CHANGED
|
@@ -3,14 +3,6 @@
|
|
|
3
3
|
// Legal Signature Required For Lawful Use.
|
|
4
4
|
// Distributed under VLA:49633069290486712918 LICENSE.md
|
|
5
5
|
|
|
6
|
-
import {laws} from '../data/manu/index.js';
|
|
7
|
-
import {avbooks} from '../data/atharvaveda/index.js';
|
|
8
|
-
|
|
9
|
-
// set the __dirname
|
|
10
|
-
import {dirname} from 'node:path';
|
|
11
|
-
import {fileURLToPath} from 'node:url';
|
|
12
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
|
-
|
|
14
6
|
export const func = {
|
|
15
7
|
/**************
|
|
16
8
|
func: menu
|
|
@@ -22,7 +14,8 @@ export const func = {
|
|
|
22
14
|
return new Promise((resolve, reject) => {
|
|
23
15
|
try {
|
|
24
16
|
const agent = this.agent();
|
|
25
|
-
const
|
|
17
|
+
const {dir} = this.info();
|
|
18
|
+
const menufile = this.lib.path.join(dir, 'data', 'menu.json');
|
|
26
19
|
const menudata = this.lib.fs.readFileSync(menufile);
|
|
27
20
|
const menujson = JSON.parse(menudata);
|
|
28
21
|
|
|
@@ -71,16 +64,20 @@ export const func = {
|
|
|
71
64
|
describe: Return a list of books based on section identifier.
|
|
72
65
|
***************/
|
|
73
66
|
books(opts) {
|
|
74
|
-
|
|
67
|
+
const {id} = opts;
|
|
68
|
+
this.action('func', `book:${id.uid}`);
|
|
75
69
|
return new Promise((resolve, reject) => {
|
|
70
|
+
this.action('try', `books:${id.uid}`); // set action try
|
|
76
71
|
try {
|
|
77
72
|
const agent = this.agent();
|
|
78
|
-
const
|
|
79
|
-
|
|
73
|
+
const {dir} = this.info();
|
|
74
|
+
this.state('data', `books:${id.uid}`); // set state data
|
|
75
|
+
const booksfile = this.lib.path.join(dir, 'data', 'rigveda', 'index.json');
|
|
80
76
|
const booksdata = this.lib.fs.readFileSync(booksfile);
|
|
81
77
|
const booksjson = JSON.parse(booksdata);
|
|
78
|
+
|
|
82
79
|
|
|
83
|
-
this.state('set',
|
|
80
|
+
this.state('set', `books:${id.uid}`);
|
|
84
81
|
const text = [
|
|
85
82
|
`::BEGIN:BOOKS:${booksjson.id}`,
|
|
86
83
|
`## ${booksjson.title}`,
|
|
@@ -91,21 +88,30 @@ export const func = {
|
|
|
91
88
|
'::begin:menu',
|
|
92
89
|
];
|
|
93
90
|
const books = [];
|
|
91
|
+
|
|
94
92
|
// loop over the data and format it into a feecting command string
|
|
95
93
|
booksjson.data.forEach((book, idx) => {
|
|
96
|
-
books.push(`button[${book.title}]:${this.askChr}${agent.key} book:${
|
|
94
|
+
books.push(`button[${book.title}]:${this.askChr}${agent.key} book:${book.key}`);
|
|
97
95
|
});
|
|
96
|
+
|
|
97
|
+
|
|
98
98
|
const booktext = books.join('\n');
|
|
99
|
-
const bookshash = this.
|
|
99
|
+
const bookshash = this.hash(booktext, 'sha256');
|
|
100
100
|
text.push(booktext);
|
|
101
101
|
text.push(`::end:menu`);
|
|
102
102
|
text.push(`::begin:hidden`);
|
|
103
103
|
text.push(`#color = {{profile.color}}`);
|
|
104
104
|
text.push(`#bgcolor = {{profile.bgcolor}}`);
|
|
105
|
-
text.push(`#bg = {{profile.background}}`);
|
|
105
|
+
text.push(`#bg = {{profile.background}}`);
|
|
106
|
+
text.push(`hash: ${bookshash}`);
|
|
107
|
+
text.push(`copyright: {{profile.copyright}}`);
|
|
106
108
|
text.push(`::end:hidden`);
|
|
107
|
-
text.push(`::END:BOOKS:${
|
|
108
|
-
|
|
109
|
+
text.push(`::END:BOOKS:${id.uid}`);
|
|
110
|
+
|
|
111
|
+
this.action('resolve', `books:${id.uid}`);
|
|
112
|
+
this.state('valid', ` books:${id.uid}`);
|
|
113
|
+
this.intent('good', ` books:${id.uid}`);
|
|
114
|
+
|
|
109
115
|
return resolve({
|
|
110
116
|
id: booksjson.id,
|
|
111
117
|
title: booksjson.title,
|
|
@@ -116,7 +122,8 @@ export const func = {
|
|
|
116
122
|
created: Date.now(),
|
|
117
123
|
});
|
|
118
124
|
} catch (e) {
|
|
119
|
-
this.
|
|
125
|
+
this.action('catch', `books:${id.uid}`);
|
|
126
|
+
this.intent('bad', ` books:${id.uid}`);
|
|
120
127
|
return reject(e);
|
|
121
128
|
}
|
|
122
129
|
});
|
|
@@ -127,37 +134,42 @@ export const func = {
|
|
|
127
134
|
describe: The book function calls the public facing api to get a listing of books to list to the user. originally this file came from sacred-texts.com but was migrated to indra.church with a json api.
|
|
128
135
|
***********/
|
|
129
136
|
book(opts) {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
this.action('func', `${section} book ${book}`);
|
|
137
|
+
const book = opts.meta.params[1] || false;
|
|
138
|
+
this.action('func', `book:${book}:${opts.id.uid}`);
|
|
133
139
|
return new Promise((resolve, reject) => {
|
|
134
140
|
if (!book) return resolve(this.vars.messages.nobook);
|
|
141
|
+
const key = book.length < 2 ? `0${book}` : book;
|
|
142
|
+
|
|
143
|
+
this.state('try', `book:${book}:${opts.id.uid}`); // set state try
|
|
135
144
|
try {
|
|
136
145
|
const agent = this.agent();
|
|
137
|
-
const
|
|
138
|
-
const filepath = this.lib.path.join(
|
|
146
|
+
const {dir} = this.info();
|
|
147
|
+
const filepath = this.lib.path.join(dir, 'data', 'rigveda', 'books', `${key}.json`)
|
|
139
148
|
const theFile = this.lib.fs.readFileSync(filepath);
|
|
140
149
|
const theJSON = JSON.parse(theFile);
|
|
141
150
|
|
|
142
|
-
const {id, title, describe,
|
|
151
|
+
const {id, title, describe, data} = theJSON;
|
|
143
152
|
|
|
144
|
-
this.state('
|
|
153
|
+
this.state('data', `book:${book}:${key}:${opts.id.uid}`);
|
|
145
154
|
const _text = [
|
|
146
155
|
`::BEGIN:BOOK:${id}`,
|
|
147
156
|
`## ${title}`,
|
|
148
157
|
`p: ${describe}`,
|
|
149
158
|
'::begin:buttons',
|
|
150
159
|
`button[🗂️ Main]:${this.askChr}${agent.key} menu`,
|
|
151
|
-
`button[📚 Books]:${this.askChr}${agent.key} books
|
|
160
|
+
`button[📚 Books]:${this.askChr}${agent.key} books`,
|
|
152
161
|
'::end:buttons',
|
|
153
162
|
'::begin:menu',
|
|
154
163
|
];
|
|
164
|
+
|
|
155
165
|
const _hymns = [];
|
|
156
|
-
|
|
157
|
-
|
|
166
|
+
|
|
167
|
+
data.forEach((hymn, idx) => {
|
|
168
|
+
_hymns.push(`button[${hymn.key} - ${hymn.title}]:#${agent.key} hymn:${hymn.key}`);
|
|
158
169
|
});
|
|
170
|
+
|
|
159
171
|
const _hymnsText = _hymns.join('\n');
|
|
160
|
-
const _hymnsHash = this.
|
|
172
|
+
const _hymnsHash = this.hash(_hymnsText, 'sha256');
|
|
161
173
|
_text.push(_hymnsText);
|
|
162
174
|
_text.push(`::end:menu`);
|
|
163
175
|
_text.push(`::begin:hidden`);
|
|
@@ -167,18 +179,18 @@ export const func = {
|
|
|
167
179
|
_text.push(`::end:hidden`);
|
|
168
180
|
_text.push(`::END:BOOK:${_hymnsHash}`);
|
|
169
181
|
|
|
170
|
-
this.
|
|
182
|
+
this.action('resolve', `book:${book}:${key}:${opts.id.uid}`);
|
|
171
183
|
return resolve({
|
|
172
184
|
id,
|
|
173
185
|
title,
|
|
174
186
|
describe,
|
|
175
187
|
text: _text.join('\n'),
|
|
176
|
-
data
|
|
177
|
-
hash: this.
|
|
188
|
+
data,
|
|
189
|
+
hash: this.hash(data, 'sha256'),
|
|
178
190
|
created: Date.now(),
|
|
179
191
|
});
|
|
180
192
|
} catch (e) {
|
|
181
|
-
this.
|
|
193
|
+
this.action('reject', `book:${key}:${opts.id.uid}`)
|
|
182
194
|
return reject(e);
|
|
183
195
|
}
|
|
184
196
|
});
|
|
@@ -189,15 +201,17 @@ export const func = {
|
|
|
189
201
|
params: packet
|
|
190
202
|
describe: The View function returns a specific hymn from one of the Books.
|
|
191
203
|
***************/
|
|
192
|
-
hymn(
|
|
193
|
-
|
|
204
|
+
hymn(opts) {
|
|
205
|
+
const {params} = opts.meta;
|
|
206
|
+
const _h = params[1];
|
|
207
|
+
this.action('func', `hymn:${_h}:${opts.id.uid}`);
|
|
194
208
|
return new Promise((resolve, reject) => {
|
|
195
|
-
if (!
|
|
196
|
-
const id = this.lib.uid();
|
|
197
|
-
const agent = this.agent();
|
|
198
|
-
|
|
209
|
+
if (!_h) return resolve(this._messages.notext);
|
|
199
210
|
try {
|
|
200
|
-
const
|
|
211
|
+
const id = this.uid();
|
|
212
|
+
const agent = this.agent();
|
|
213
|
+
const {dir} = this.info();
|
|
214
|
+
const hymnPath = this.lib.path.join(dir, 'data', 'rigveda', 'hymns', `${_h}.json`);
|
|
201
215
|
const hymnExists = this.lib.fs.existsSync(hymnPath);
|
|
202
216
|
if (!hymnExists) return resolve(this.vars.messages.notfound);
|
|
203
217
|
// parse hymns
|
|
@@ -205,7 +219,7 @@ export const func = {
|
|
|
205
219
|
const _hymn = JSON.parse(theFile);
|
|
206
220
|
const processed = this.utils.process({key:_hymn.key,title:_hymn.title,content:_hymn.orig});
|
|
207
221
|
|
|
208
|
-
this.state('set', `hymn
|
|
222
|
+
this.state('set', `hymn:${_h}:${opts.id.uid}`);
|
|
209
223
|
const hymn = [
|
|
210
224
|
`::BEGIN:HYMN:${processed.key}`,
|
|
211
225
|
`# ${processed.title}`,
|
|
@@ -214,21 +228,34 @@ export const func = {
|
|
|
214
228
|
'::end:content',
|
|
215
229
|
'::begin:meta',
|
|
216
230
|
`title: ${processed.title}`,
|
|
217
|
-
processed.people.length ? `
|
|
231
|
+
processed.people.kings.length ? `kings: ${processed.people.kings.join(', ')}` : '',
|
|
232
|
+
processed.people.male.length ? `male: ${processed.people.male.join(', ')}` : '',
|
|
233
|
+
processed.people.female.length ? `female: ${processed.people.female.join(', ')}` : '',
|
|
218
234
|
processed.places.length ? `places: ${processed.places.join(', ')}` : '',
|
|
219
235
|
processed.things.length ? `things: ${processed.things.join(', ')}` : '',
|
|
220
236
|
processed.groups.length ? `groups: ${processed.groups.join(', ')}` : '',
|
|
221
237
|
processed.concepts.length ? `concepts: ${processed.concepts.join(', ')}` : '',
|
|
238
|
+
`uid: ${opts.id.uid}`,
|
|
239
|
+
`time: ${opts.id.time}`,
|
|
240
|
+
`date: ${opts.id.date}`,
|
|
241
|
+
`fingerprint: ${opts.id.fingerprint}`,
|
|
242
|
+
`md5: ${this.hash(processed.text, 'md5')}`,
|
|
243
|
+
`sha256: ${this.hash(processed.text, 'sha256')}`,
|
|
244
|
+
`sha512: ${this.hash(processed.text, 'sha512')}`,
|
|
245
|
+
`copyright: ${opts.id.copyright}`,
|
|
222
246
|
'::end:meta',
|
|
223
247
|
`::begin:hidden`,
|
|
224
248
|
`#color = {{profile.color}}`,
|
|
225
249
|
`#bgcolor = {{profile.bgcolor}}`,
|
|
226
250
|
`#bg = {{profile.background}}`,
|
|
251
|
+
`copyright: {{profile.copyright}}`,
|
|
227
252
|
`::end:hidden`,
|
|
228
|
-
`::END:HYMN:${
|
|
253
|
+
`::END:HYMN:${processed.key}`,
|
|
229
254
|
];
|
|
230
255
|
|
|
231
|
-
this.
|
|
256
|
+
this.action('resolve', `hymn:${opts.id.uid}`)
|
|
257
|
+
this.state('valid', `hymn ${opts.id.uid}`)
|
|
258
|
+
this.intent('good', `hymn ${opts.id.uid}`)
|
|
232
259
|
return resolve({
|
|
233
260
|
id,
|
|
234
261
|
key: processed.key,
|
|
@@ -239,12 +266,12 @@ export const func = {
|
|
|
239
266
|
created: Date.now(),
|
|
240
267
|
});
|
|
241
268
|
} catch (e) {
|
|
242
|
-
this.
|
|
243
|
-
|
|
269
|
+
this.action('reject', `hymn ${opts.id.uid}`)
|
|
270
|
+
this.state('invalid', `hymn ${opts.id.uid}`)
|
|
271
|
+
this.intent('bad', `hymn ${opts.id.uid}`)
|
|
272
|
+
return this.err(e, opts, reject);
|
|
244
273
|
}
|
|
245
274
|
});
|
|
246
275
|
},
|
|
247
|
-
laws,
|
|
248
|
-
avbooks,
|
|
249
276
|
}
|
|
250
277
|
|
package/methods/index.js
CHANGED
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
// Legal Signature Required For Lawful Use.
|
|
4
4
|
// Distributed under VLA:49633069290486712918 LICENSE.md
|
|
5
5
|
|
|
6
|
-
import {manu, manuhash} from '../data/manu/index.js';
|
|
7
|
-
import {rvbooks} from '../data/rigveda/index.js';
|
|
8
|
-
import {avbooks} from '../data/atharvaveda/index.js';
|
|
9
|
-
import {svbooks} from '../data/samaveda/index.js';
|
|
10
|
-
|
|
11
6
|
import {dirname} from 'node:path';
|
|
12
7
|
import {fileURLToPath} from 'node:url';
|
|
13
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -46,22 +41,32 @@ export const methods = {
|
|
|
46
41
|
describe: Call the books function to get a listing of books.
|
|
47
42
|
***************/
|
|
48
43
|
books(packet) {
|
|
49
|
-
|
|
50
|
-
this.
|
|
44
|
+
const {id, q} = packet;
|
|
45
|
+
this.context('books', id.uid);
|
|
46
|
+
this.action('method', `books:${id.uid}`);
|
|
51
47
|
return new Promise((resolve, reject) => {
|
|
52
48
|
if (!packet) return reject(this._messages.nopacket);
|
|
53
49
|
const data = {};
|
|
54
|
-
this.func.books(
|
|
50
|
+
this.func.books(q).then(books => {
|
|
51
|
+
this.state('data', `books:${id.uid}`); // set state set
|
|
55
52
|
data.books = books;
|
|
56
53
|
return this.question(`${this.askChr}feecting parse ${books.text}`);
|
|
57
54
|
}).then(feecting => {
|
|
55
|
+
this.state('data', `feecting:${id.uid}`); // set state set
|
|
58
56
|
data.feecting = feecting;
|
|
57
|
+
|
|
58
|
+
this.action('resolve', `books:${id.uid}`); // set action resolve
|
|
59
|
+
this.state('valid', `books:${id.uid}`); // set action resolve
|
|
60
|
+
this.intent('good', `books:${id.uid}`); // set action resolve
|
|
59
61
|
return resolve({
|
|
60
62
|
text:feecting.a.text,
|
|
61
63
|
html:feecting.a.html,
|
|
62
64
|
data,
|
|
63
65
|
});
|
|
64
66
|
}).catch(err => {
|
|
67
|
+
this.action('catch', `books:${id.uid}`); // set action resolve
|
|
68
|
+
this.state('invalid', `books:${id.uid}`); // set action resolve
|
|
69
|
+
this.intent('bad', `books:${id.uid}`); // set action resolve
|
|
65
70
|
return this.error(err, packet, reject);
|
|
66
71
|
});
|
|
67
72
|
})
|
|
@@ -79,6 +84,7 @@ export const methods = {
|
|
|
79
84
|
const agent = this.agent();
|
|
80
85
|
const data = {};
|
|
81
86
|
this.func.book(packet.q).then(book => {
|
|
87
|
+
console.log('getting to resolve');
|
|
82
88
|
data.book = book;
|
|
83
89
|
return this.question(`${this.askChr}feecting parse ${book.text}`);
|
|
84
90
|
}).then(feecting => {
|
|
@@ -105,15 +111,16 @@ export const methods = {
|
|
|
105
111
|
this.context('hymn', packet.q.text);
|
|
106
112
|
const agent = this.agent();
|
|
107
113
|
let data;
|
|
108
|
-
this.func.hymn(packet.q
|
|
114
|
+
this.func.hymn(packet.q).then(hymn => {
|
|
109
115
|
data = hymn.data
|
|
110
116
|
const {text} = hymn;
|
|
111
|
-
|
|
117
|
+
|
|
112
118
|
this.talk(`chat:topic`, {
|
|
113
|
-
id: this.
|
|
119
|
+
id: this.uid(),
|
|
114
120
|
data: `Current topic is Rig Veda hymn ${text}`,
|
|
115
121
|
created: Date.now(),
|
|
116
122
|
});
|
|
123
|
+
|
|
117
124
|
return this.question(`${this.askChr}feecting parse:${agent.key} ${text}`);
|
|
118
125
|
}).then(feecting => {
|
|
119
126
|
return resolve({
|
|
@@ -122,6 +129,10 @@ export const methods = {
|
|
|
122
129
|
data,
|
|
123
130
|
});
|
|
124
131
|
}).catch(err => {
|
|
132
|
+
this.action('catch', `hymn:${packet.id.uid}`); // set action catch
|
|
133
|
+
this.state('invalid', `hymn${packet.id.uid}`); // set state invalid
|
|
134
|
+
this.intent('bad', `hymn${packet.id.uid}`); // set state invalid
|
|
135
|
+
console.log('hymn error', err);
|
|
125
136
|
return this.error(err, packet, reject);
|
|
126
137
|
});
|
|
127
138
|
});
|
|
@@ -173,7 +184,7 @@ export const methods = {
|
|
|
173
184
|
const data = [];
|
|
174
185
|
indexjson.data.forEach((item,index) => {
|
|
175
186
|
const newitem = {
|
|
176
|
-
id: this.
|
|
187
|
+
id: this.uid(),
|
|
177
188
|
key: item.key,
|
|
178
189
|
title: item.title,
|
|
179
190
|
api: `data/${packet.q.text}/books/${item.key}.json`,
|
|
@@ -198,7 +209,4 @@ export const methods = {
|
|
|
198
209
|
}
|
|
199
210
|
});
|
|
200
211
|
},
|
|
201
|
-
rvbooks,
|
|
202
|
-
avbooks,
|
|
203
|
-
svbooks,
|
|
204
212
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "49633069290486712918",
|
|
3
3
|
"name": "@indra.ai/deva.veda",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"license": "VLA:49633069290486712918 LICENSE.md",
|
|
6
6
|
"VLA": {
|
|
7
7
|
"uid": "49633069290486712918",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"homepage": "https://indra.ai",
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@indra.ai/deva": "^1.
|
|
66
|
+
"@indra.ai/deva": "^1.21.0",
|
|
67
67
|
"cheerio": "^1.0.0",
|
|
68
68
|
"he": "^1.2.0"
|
|
69
69
|
},
|
package/utils.js
CHANGED
|
@@ -76,7 +76,7 @@ export default {
|
|
|
76
76
|
|
|
77
77
|
// next here we need to check for people places and things then add them to a meta index.
|
|
78
78
|
// this will start with that we loop over he processing value key peple
|
|
79
|
-
const
|
|
79
|
+
const data = {
|
|
80
80
|
key,
|
|
81
81
|
title,
|
|
82
82
|
book,
|
|
@@ -86,56 +86,78 @@ export default {
|
|
|
86
86
|
original,
|
|
87
87
|
sanskrit,
|
|
88
88
|
},
|
|
89
|
-
people:
|
|
89
|
+
people: {
|
|
90
|
+
kings: [],
|
|
91
|
+
male: [],
|
|
92
|
+
female: [],
|
|
93
|
+
},
|
|
90
94
|
places: [],
|
|
91
95
|
things: [],
|
|
92
96
|
groups: [],
|
|
93
97
|
concepts: [],
|
|
94
98
|
};
|
|
95
99
|
|
|
96
|
-
getProcessingData('people')
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
const people = getProcessingData('people');
|
|
101
|
+
people.kings.forEach(king => {
|
|
102
|
+
const _reg = new RegExp(`(\\b)(${king})(\\b)`, 'gi');
|
|
103
|
+
const hasKing = _reg.exec(data.text);
|
|
104
|
+
if (hasKing) {
|
|
105
|
+
if (!data.people.kings.includes(king)) data.people.kings.push(king);
|
|
106
|
+
// ret.text = ret.text.replace(_reg, `$1@${person}$3`);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
people.male.forEach(male => {
|
|
110
|
+
const _reg = new RegExp(`(\\b)(${male})(\\b)`, 'gi');
|
|
111
|
+
const hasMale = _reg.exec(data.text);
|
|
112
|
+
if (hasMale) {
|
|
113
|
+
if (!data.people.male.includes(male)) data.people.male.push(male);
|
|
114
|
+
// ret.text = ret.text.replace(_reg, `$1@${person}$3`);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
people.female.forEach(female => {
|
|
119
|
+
const _reg = new RegExp(`(\\b)(${female})(\\b)`, 'gi');
|
|
120
|
+
const hasMale = _reg.exec(data.text);
|
|
121
|
+
if (hasMale) {
|
|
122
|
+
if (!data.people.female.includes(female)) data.people.female.push(female);
|
|
101
123
|
// ret.text = ret.text.replace(_reg, `$1@${person}$3`);
|
|
102
124
|
}
|
|
103
125
|
});
|
|
104
126
|
|
|
105
127
|
getProcessingData('places').forEach(place => {
|
|
106
128
|
const _reg = new RegExp(`(^|\\b)(${place})(\\b)`, 'gi');
|
|
107
|
-
const hasPlace = _reg.exec(
|
|
129
|
+
const hasPlace = _reg.exec(data.text);
|
|
108
130
|
if (hasPlace) {
|
|
109
|
-
if (!
|
|
131
|
+
if (!data.places.includes(place)) data.places.push(place);
|
|
110
132
|
// ret.text = ret.text.replace(_reg, `$1$${place}$3`);
|
|
111
133
|
}
|
|
112
134
|
});
|
|
113
135
|
|
|
114
136
|
getProcessingData('things').forEach(thing => {
|
|
115
137
|
const _reg = new RegExp(`(^|\\b)(${thing})(\\b)`, 'gi');
|
|
116
|
-
const hasThing = _reg.exec(
|
|
138
|
+
const hasThing = _reg.exec(data.text);
|
|
117
139
|
if (hasThing) {
|
|
118
|
-
if (!
|
|
140
|
+
if (!data.things.includes(thing)) data.things.push(thing);
|
|
119
141
|
// ret.text = ret.text.replace(_reg, `$1#$2$3`);
|
|
120
142
|
}
|
|
121
143
|
});
|
|
122
144
|
|
|
123
145
|
getProcessingData('groups').forEach(group => {
|
|
124
146
|
const _reg = new RegExp(`(^|\\b)(${group})(\\b)`, 'gi');
|
|
125
|
-
const hasGroup = _reg.exec(
|
|
147
|
+
const hasGroup = _reg.exec(data.text);
|
|
126
148
|
if (hasGroup) {
|
|
127
|
-
if (!
|
|
149
|
+
if (!data.groups.includes(group)) data.groups.push(group);
|
|
128
150
|
// ret.text = ret.text.replace(_reg, `$1#$2$3`);
|
|
129
151
|
}
|
|
130
152
|
});
|
|
131
153
|
|
|
132
154
|
getProcessingData('concepts').forEach(concept => {
|
|
133
155
|
const _reg = new RegExp(`(^|\\b)(${concept})(\\b)`, 'gi');
|
|
134
|
-
const hasConcept = _reg.exec(
|
|
156
|
+
const hasConcept = _reg.exec(data.text);
|
|
135
157
|
if (hasConcept) {
|
|
136
|
-
if (!
|
|
158
|
+
if (!data.concepts.includes(concept)) data.concepts.push(concept);
|
|
137
159
|
}
|
|
138
160
|
});
|
|
139
|
-
return
|
|
161
|
+
return data;
|
|
140
162
|
}
|
|
141
163
|
};
|