aboutsummaryrefslogtreecommitdiff
path: root/search
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-07-10 18:58:15 +0200
committerlonkaars <loek@pipeframe.xyz>2023-07-10 18:58:15 +0200
commit65e7b2260d728a9c747d126f828e90ae34f05b40 (patch)
tree80bce68628fc763b8d24b97a089d79ef5c0d039c /search
parentf7bfb89d7f400b48539b6f0712040caa6c6d3165 (diff)
constrain deinflection test cases more
Diffstat (limited to 'search')
-rw-r--r--search/tags.ts26
1 files changed, 17 insertions, 9 deletions
diff --git a/search/tags.ts b/search/tags.ts
index 92279c5..fa70fe8 100644
--- a/search/tags.ts
+++ b/search/tags.ts
@@ -180,29 +180,37 @@ export function parseTags(input: string) {
var tags = input.replaceAll(/ +/g, " ").trim().split(" ") as TokenTag[];
var filteredTags: TokenTag[] = [];
var negationCount = 0;
- for (var tag of tags) {
+ var lastTag = "";
+ var tag = "";
+ let i = 0;
+ for (i = 0, tag = tags[i]; i < tags.length; lastTag = tags[i], i++, tag = tags[i]) {
// conjugations that are used as "stepping stones" for others should be
// filtered in this loop. checking if a combination of tags is valid should
// be done in ./parser.ts
// skip past tense tag if used as step for -te and -tari inflection
- if (tag == Tag.Inflection.Tense.Past &&
- filteredTags.anyOf([Tag.Inflection.Suffix.Te, Tag.Inflection.Suffix.Tari])) continue;
+ if (tag == Tag.Inflection.Tense.Past && [
+ Tag.Inflection.Suffix.Te,
+ Tag.Inflection.Suffix.Tari
+ ].includes(lastTag as any)) continue;
// skip -te suffix tag if used for
- if (tag == Tag.Inflection.Suffix.Te && filteredTags.anyOf([
+ if (tag == Tag.Inflection.Suffix.Te && [
Tag.Inflection.Tense.Continuous, // base for continuous tense
Tag.Inflection.Obligatory, // base for obligatory inflection
Tag.Inflection.Attempt.Miru, // base for 〜みる attempt
- ])) continue;
+ ].includes(lastTag as any)) continue;
// skip volitional tag if used for 〜とする attempt
- if (tag == Tag.Inflection.Desirable.Volitional &&
- filteredTags.anyOf([Tag.Inflection.Attempt.ToSuru])) continue;
+ if (tag == Tag.Inflection.Desirable.Volitional && [
+ Tag.Inflection.Attempt.ToSuru,
+ ].includes(lastTag as any)) continue;
// skip conditional 〜ば if used for obligatory inflection
- if (tag == Tag.Inflection.Conditional.Ba &&
- filteredTags.anyOf([Tag.Inflection.Obligatory])) continue;
+ if (tag == Tag.Inflection.Conditional.Ba && [
+ Tag.Inflection.Obligatory,
+ Tag.Inflection.Temporary.ObligatoryResult,
+ ].includes(lastTag as any)) continue;
// normalize multiple Inflection.Negative to single Inflection.Affirmative or Inflection.Negative
if (tag == Tag.Inflection.Negative) {