deinflect static method
- String source
Give the possible deinflections given source text.
Implementation
static List<Deinflection> deinflect(String source) {
List<Deinflection> results = [
Deinflection(term: source, rules: 0, reasons: [])
];
for (int i = 0; i < results.length; ++i) {
Deinflection result = results[i];
for (NormalizedReason normalizedReason
in normalizeReasons(deinflectRules)) {
for (Variant variant in normalizedReason.variants) {
if ((result.rules != 0 && (result.rules & variant.rulesIn) == 0) ||
!result.term.endsWith(variant.kanaIn) ||
(result.term.length -
variant.kanaIn.length +
variant.kanaOut.length) <=
0) {
continue;
}
results.add(Deinflection(
term: result.term.substring(
0, result.term.length - variant.kanaIn.length) +
variant.kanaOut,
rules: variant.rulesOut,
reasons: [normalizedReason.reason, ...result.reasons]));
}
}
}
return results;
}