fix stem length checking
Starting from the end and stopping at first match doesn't guarantee correctness. Starting from the beginning does.
This commit is contained in:
parent
c35a05cd62
commit
d19f447b80
@ -90,9 +90,10 @@ async function apiTextParse(text, optionsContext) {
|
|||||||
definitions = dictTermsSort(definitions);
|
definitions = dictTermsSort(definitions);
|
||||||
const {expression, source, reading} = definitions[0];
|
const {expression, source, reading} = definitions[0];
|
||||||
|
|
||||||
let stemLength = source.length;
|
let stemLength = 0;
|
||||||
while (source[stemLength - 1] !== expression[stemLength - 1]) {
|
const shortest = Math.min(source.length, expression.length);
|
||||||
--stemLength;
|
while (stemLength < shortest && source[stemLength] === expression[stemLength]) {
|
||||||
|
++stemLength;
|
||||||
}
|
}
|
||||||
const offset = source.length - stemLength;
|
const offset = source.length - stemLength;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user