aboutsummaryrefslogtreecommitdiff
path: root/language
diff options
context:
space:
mode:
Diffstat (limited to 'language')
-rw-r--r--language/parser.ts16
-rw-r--r--language/tags.ts6
2 files changed, 12 insertions, 10 deletions
diff --git a/language/parser.ts b/language/parser.ts
index 9c6bef2..9bfdc4b 100644
--- a/language/parser.ts
+++ b/language/parser.ts
@@ -52,12 +52,12 @@ export default class Parser {
if (!result.tags.anyOf(Object.values(Tag.Class.Verb))) return false;
// ignore other wrong deconjugations
- if (result.tags.has(Tag.Class.Verb.U) &&
- !result.tags.has(Tag.Inflection.Reason.U)) return false;
- if (result.tags.has(Tag.Class.Verb.Ru) &&
- !result.tags.has(Tag.Inflection.Reason.Ru)) return false;
- if (result.tags.has(Tag.Class.Verb.Suru) &&
- !result.tags.has(Tag.Inflection.Reason.Suru)) return false;
+ if (result.tags.includes(Tag.Class.Verb.U) &&
+ !result.tags.includes(Tag.Inflection.Reason.U)) return false;
+ if (result.tags.includes(Tag.Class.Verb.Ru) &&
+ !result.tags.includes(Tag.Inflection.Reason.Ru)) return false;
+ if (result.tags.includes(Tag.Class.Verb.Suru) &&
+ !result.tags.includes(Tag.Inflection.Reason.Suru)) return false;
}
// all other results should be valid grammatically
@@ -73,12 +73,12 @@ export default class Parser {
const lastTokenName = parseResult.tokens.peek()?.tags.anyOf(Object.values(Tag.Name));
// give higher priority to suffixes when last token was a name, else lower priority
- if (result.tags.has(Tag.Class.Suffix))
+ if (result.tags.includes(Tag.Class.Suffix))
result.sort *= lastTokenName ? PRIORITY_MOD_HIGHER : PRIORITY_MOD_LOWER;
// give lower priority to terms matched only by their readings, and are
// usually written in kanji
- if (!result.tags.has(Tag.Auxiliary.UsuallyKana) && !result.match.kanji)
+ if (!result.tags.includes(Tag.Auxiliary.UsuallyKana) && !result.match.kanji)
result.sort *= PRIORITY_MOD_LOWER;
return result;
diff --git a/language/tags.ts b/language/tags.ts
index d56ce98..d40904f 100644
--- a/language/tags.ts
+++ b/language/tags.ts
@@ -1,3 +1,5 @@
+import "../util/array.ts";
+
/** @constant Tags that have significant meaning to the parser */
export const Tag = {
/** @constant grammatical classes */
@@ -98,7 +100,7 @@ export const Tag = {
export type TokenTag = string; // no way around it
-export type TokenTags = Set<TokenTag>;
+export type TokenTags = Array<TokenTag>;
/** @summary parse concatenated tag string to TokenTags */
export function parseTags(input: string) {
@@ -111,6 +113,6 @@ export function parseTags(input: string) {
filteredTags.push(tag);
}
- return new Set(filteredTags) as TokenTags;
+ return filteredTags.set().arr() as TokenTags; // make sure array doesn't contain duplicates
}