1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.init = exports.AdjectiveOptimizer = void 0;
|
4 | const mod_1 = require("../mod");
|
5 | const COLORS_1 = require("../mod/COLORS");
|
6 |
|
7 |
|
8 |
|
9 | class AdjectiveOptimizer extends mod_1.SubSModuleOptimizer {
|
10 | constructor() {
|
11 | super(...arguments);
|
12 | this.name = 'AdjectiveOptimizer';
|
13 | }
|
14 | doOptimize(words) {
|
15 | const POSTAG = this._POSTAG;
|
16 | let index = 0;
|
17 | while (index < words.length) {
|
18 | const word = words[index];
|
19 | const nextword = words[index + 1];
|
20 | if (nextword) {
|
21 |
|
22 | if (nextword.p & POSTAG.D_U && COLORS_1.COLOR_ALL[word.w]) {
|
23 | word.op = word.op || word.p;
|
24 | word.p |= POSTAG.D_A;
|
25 | this.debugToken(word, {
|
26 | [this.name]: true,
|
27 | });
|
28 | }
|
29 |
|
30 | if (word.p & POSTAG.D_N && this.isNominal(nextword.p) && COLORS_1.COLOR_ALL[word.w]) {
|
31 | word.op = word.op || word.p;
|
32 | word.p |= POSTAG.D_A;
|
33 | word.p |= POSTAG.D_N;
|
34 | this.debugToken(word, {
|
35 | [this.name]: true,
|
36 | });
|
37 | }
|
38 | }
|
39 |
|
40 | index += 1;
|
41 | }
|
42 | return words;
|
43 | }
|
44 | isNominal(pos) {
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | const POSTAG = this._POSTAG;
|
52 | return (pos === POSTAG.D_N ||
|
53 | pos === POSTAG.A_NT ||
|
54 | pos === POSTAG.A_NX ||
|
55 | pos === POSTAG.A_NZ ||
|
56 | pos === POSTAG.A_NR ||
|
57 | pos === POSTAG.A_NS ||
|
58 | pos === POSTAG.URL);
|
59 | }
|
60 | }
|
61 | exports.AdjectiveOptimizer = AdjectiveOptimizer;
|
62 | exports.init = AdjectiveOptimizer.init.bind(AdjectiveOptimizer);
|
63 | exports.default = AdjectiveOptimizer;
|
64 |
|
\ | No newline at end of file |