aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/deinflection/cases.ts16
-rw-r--r--test/deinflection/test.ts17
2 files changed, 17 insertions, 16 deletions
diff --git a/test/deinflection/cases.ts b/test/deinflection/cases.ts
index 08517d4..c29bdf1 100644
--- a/test/deinflection/cases.ts
+++ b/test/deinflection/cases.ts
@@ -1,11 +1,11 @@
-import { TokenTags, Tag } from "../../language/tags.ts";
+import { TokenTags, Tag } from "../../search/tags.ts";
const { Inflection } = Tag;
interface Test {
input: string;
mustHave: TokenTags;
mustNotHave: TokenTags;
- forceID?: number;
+ force?: { reading: string, writing: string };
};
export default [
@@ -32,7 +32,7 @@ export default [
{ input: "取るな", mustHave: [ Inflection.Negative, Inflection.Command ], mustNotHave: [], },
// other tests
{ input: "取ったり", mustHave: [ Inflection.Suffix.Tari ], mustNotHave: [ Inflection.Tense.Past ], },
- { input: "早く", mustHave: [ Inflection.Adverb ], mustNotHave: [], },
+ { input: "早く", force: { reading: "はやい", writing: "早い" }, mustHave: [ Inflection.Adverb ], mustNotHave: [], },
{ input: "遊んだり", mustHave: [ Inflection.Suffix.Tari ], mustNotHave: [ Inflection.Tense.Past ], },
{ input: "聞け", mustHave: [ Inflection.Command ], mustNotHave: [], },
{ input: "食べさせる", mustHave: [ Inflection.Causative ], mustNotHave: [], },
@@ -51,13 +51,12 @@ export default [
{ input: "しなくてはいけなかった", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Negative ], },
{ input: "行かないとだめ", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Negative ], },
{ input: "しないといけない", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Negative ], },
- { input: "行かなければいけません", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Negative ], },
- { input: "しなければだめ", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Negative ], },
+ { input: "行かなければいけません", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Negative, Inflection.Conditional.Ba ], },
+ { input: "しなければだめ", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Negative, Inflection.Conditional.Ba ], },
{ input: "行かないと", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Negative ], },
{ input: "買いたい", mustHave: [ Inflection.Desirable.Itai ], mustNotHave: [], },
{ input: "寝よう", mustHave: [ Inflection.Desirable.Volitional ], mustNotHave: [], },
- // TODO: for this test to work, a parseSentencePart function needs to be made that returns all possible words (currently clipped)
- // { input: "しましょう", forceID: 17327, mustHave: [ Inflection.Desirable.Volitional, Inflection.Polite.Masu ], mustNotHave: [], },
+ { input: "しましょう", force: { reading: "する", writing: "為る" }, mustHave: [ Inflection.Desirable.Volitional, Inflection.Polite.Masu ], mustNotHave: [], },
{ input: "きましょう", mustHave: [ Inflection.Desirable.Volitional, Inflection.Polite.Masu ], mustNotHave: [], },
{ input: "寝ましょう", mustHave: [ Inflection.Desirable.Volitional, Inflection.Polite.Masu ], mustNotHave: [], },
{ input: "行きましょう", mustHave: [ Inflection.Desirable.Volitional, Inflection.Polite.Masu ], mustNotHave: [], },
@@ -76,9 +75,10 @@ export default [
{ input: "聞きなさい", mustHave: [ Inflection.Polite.Nasai ], mustNotHave: [], },
{ input: "座りなさい", mustHave: [ Inflection.Polite.Nasai ], mustNotHave: [], },
{ input: "食べさせられる", mustHave: [ Inflection.Passive, Inflection.Causative ], mustNotHave: [], },
+ { input: "見極めなければならない", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Conditional.Ba, Inflection.Negative ] }
// TODO: りゃ for いることは
// TODO: じゃ for では
// TODO: なきゃ + なくちゃ
// and more!
-] as Test[];
+] satisfies Test[] as Test[];
diff --git a/test/deinflection/test.ts b/test/deinflection/test.ts
index 017a5c7..1d2f172 100644
--- a/test/deinflection/test.ts
+++ b/test/deinflection/test.ts
@@ -1,17 +1,18 @@
import cases from "./cases.ts";
import { core } from '../base.ts';
-import { TokenTag } from '../../language/tags.ts';
+import { TokenTag } from "../../search/tags.ts";
-cases.forEach(({ input, mustHave, mustNotHave, forceID }) => {
+cases.forEach(({ input, mustHave, mustNotHave, force }) => {
Deno.test(`deinflection - ${input}`, async () => {
- var { tokens } = await core.parseSentence(input);
+ var terms = await core.search.terms(input);
- if (tokens.length == 0)
- throw new Error("No parsed tokens for input");
+ if (terms.length == 0)
+ throw new Error("No parsed terms for input");
- // console.log(tokens);
- var result = tokens.find(t => t.source == input);
- if (forceID) result = tokens.find(t => t.term_id == forceID);
+ // console.log(terms);
+ var result = terms.find(t => t.source == input);
+ if (force)
+ result = terms.find(t => t.reading == force.reading && t.writing == force.writing);
if (!result)
throw new Error("No deconjugation found for input");