diff --git a/javascript/src/parser.ts b/javascript/src/parser.ts index 6343ece4..ce2ae3bc 100644 --- a/javascript/src/parser.ts +++ b/javascript/src/parser.ts @@ -72,12 +72,15 @@ export class Parser { score += this.model.get('UW1')?.get(sentence.substring(i - 3, i - 2)) || 0; score += this.model.get('UW2')?.get(sentence.substring(i - 2, i - 1)) || 0; score += this.model.get('UW3')?.get(sentence.substring(i - 1, i)) || 0; + if (score > 0) { result.push(i); continue; } score += this.model.get('UW4')?.get(sentence.substring(i, i + 1)) || 0; score += this.model.get('UW5')?.get(sentence.substring(i + 1, i + 2)) || 0; score += this.model.get('UW6')?.get(sentence.substring(i + 2, i + 3)) || 0; + if (score > 0) { result.push(i); continue; } score += this.model.get('BW1')?.get(sentence.substring(i - 2, i)) || 0; score += this.model.get('BW2')?.get(sentence.substring(i - 1, i + 1)) || 0; score += this.model.get('BW3')?.get(sentence.substring(i, i + 2)) || 0; + if (score > 0) { result.push(i); continue; } score += this.model.get('TW1')?.get(sentence.substring(i - 3, i)) || 0; score += this.model.get('TW2')?.get(sentence.substring(i - 2, i + 1)) || 0; score += this.model.get('TW3')?.get(sentence.substring(i - 1, i + 2)) || 0;