diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-07-08 23:43:14 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-07-08 23:43:14 +0200 |
commit | d36cefb50ddf67daa08a221d2de4d3eaae9e2492 (patch) | |
tree | bf8139bd668f1d99304f3f92ec01e9172a67e463 /test/deinflection | |
parent | 92bc1ed78859984486336d95641ddbdca8d02841 (diff) |
more deinflections
Diffstat (limited to 'test/deinflection')
-rw-r--r-- | test/deinflection/cases.ts | 55 | ||||
-rw-r--r-- | test/deinflection/test.ts | 13 |
2 files changed, 43 insertions, 25 deletions
diff --git a/test/deinflection/cases.ts b/test/deinflection/cases.ts index 4bff5e3..e0b2137 100644 --- a/test/deinflection/cases.ts +++ b/test/deinflection/cases.ts @@ -3,30 +3,43 @@ const { Inflection } = Tag; interface Test { input: string; - tags: TokenTags; + mustHave: TokenTags; + mustNotHave: TokenTags; }; export default [ - { input: "取る", tags: [], }, - { input: "取らない", tags: [ Inflection.Negative ], }, - { input: "取ります", tags: [ Inflection.Polite.Masu ], }, - { input: "取りません", tags: [ Inflection.Negative, Inflection.Polite.Masu ], }, - { input: "取った", tags: [ Inflection.Tense.Past ], }, - { input: "取らなかった", tags: [ Inflection.Negative, Inflection.Tense.Past ], }, - { input: "取りました", tags: [ Inflection.Polite.Masu, Inflection.Tense.Past ], }, - { input: "取りませんでした", tags: [ Inflection.Negative, Inflection.Polite.Masu, Inflection.Tense.Past ], }, - { input: "取って", tags: [ Inflection.Suffix.Te ], }, - { input: "取らなくて", tags: [ Inflection.Negative, Inflection.Suffix.Te ], }, - { input: "取れる", tags: [ Inflection.Potential ], }, - { input: "取れない", tags: [ Inflection.Negative, Inflection.Potential ], }, - { input: "取られる", tags: [ Inflection.Passive ], }, - { input: "取られない", tags: [ Inflection.Negative, Inflection.Passive ], }, - { input: "取らせる", tags: [ Inflection.Causative ], }, - { input: "取らせない", tags: [ Inflection.Negative, Inflection.Causative ], }, - { input: "取らせられる", tags: [ Inflection.Causative, Inflection.Passive ], }, - { input: "取らせられない", tags: [ Inflection.Negative, Inflection.Causative, Inflection.Passive ], }, - { input: "取れ", tags: [ Inflection.Command ], }, - { input: "取るな", tags: [ Inflection.Negative, Inflection.Command ], }, + // jisho.org generated conjugations for 取る (u-verb) + { input: "取る", mustHave: [], mustNotHave: [], }, + { input: "取らない", mustHave: [ Inflection.Negative ], mustNotHave: [], }, + { input: "取ります", mustHave: [ Inflection.Polite.Masu ], mustNotHave: [], }, + { input: "取りません", mustHave: [ Inflection.Negative, Inflection.Polite.Masu ], mustNotHave: [], }, + { input: "取った", mustHave: [ Inflection.Tense.Past ], mustNotHave: [], }, + { input: "取らなかった", mustHave: [ Inflection.Negative, Inflection.Tense.Past ], mustNotHave: [], }, + { input: "取りました", mustHave: [ Inflection.Polite.Masu, Inflection.Tense.Past ], mustNotHave: [], }, + { input: "取りませんでした", mustHave: [ Inflection.Negative, Inflection.Polite.Masu, Inflection.Tense.Past ], mustNotHave: [], }, + { input: "取って", mustHave: [ Inflection.Suffix.Te ], mustNotHave: [], }, + { input: "取らなくて", mustHave: [ Inflection.Negative, Inflection.Suffix.Te ], mustNotHave: [], }, + { input: "取れる", mustHave: [ Inflection.Potential ], mustNotHave: [], }, + { input: "取れない", mustHave: [ Inflection.Negative, Inflection.Potential ], mustNotHave: [], }, + { input: "取られる", mustHave: [ Inflection.Passive ], mustNotHave: [], }, + { input: "取られない", mustHave: [ Inflection.Negative, Inflection.Passive ], mustNotHave: [], }, + { input: "取らせる", mustHave: [ Inflection.Causative ], mustNotHave: [], }, + { input: "取らせない", mustHave: [ Inflection.Negative, Inflection.Causative ], mustNotHave: [], }, + { input: "取らせられる", mustHave: [ Inflection.Causative, Inflection.Passive ], mustNotHave: [], }, + { input: "取らせられない", mustHave: [ Inflection.Negative, Inflection.Causative, Inflection.Passive ], mustNotHave: [], }, + { input: "取れ", mustHave: [ Inflection.Command ], mustNotHave: [], }, + { input: "取るな", mustHave: [ Inflection.Negative, Inflection.Command ], mustNotHave: [], }, + // other tests + { input: "取ったり", mustHave: [ Inflection.Suffix.Tari ], mustNotHave: [ Inflection.Tense.Past ], }, + { input: "早く", mustHave: [ Inflection.Adverb ], mustNotHave: [], }, + { input: "遊んだり", mustHave: [ Inflection.Suffix.Tari ], mustNotHave: [ Inflection.Tense.Past ], }, + { input: "聞け", mustHave: [ Inflection.Command ], mustNotHave: [], }, + { input: "⾷べさせる", mustHave: [ Inflection.Causative ], mustNotHave: [], }, + { input: "落ちられる", mustHave: [ Inflection.Potential ], mustNotHave: [], }, + { input: "言われる", mustHave: [ Inflection.Passive ], mustNotHave: [], }, + { input: "喋っている", mustHave: [ Inflection.Tense.Continuous ], mustNotHave: [ Inflection.Suffix.Te ], }, + { input: "泳げれば", mustHave: [ Inflection.Suffix.Ba ], mustNotHave: [], }, + { input: "取らなければ", mustHave: [ Inflection.Potential, Inflection.Negative ], mustNotHave: [], }, // TODO: りゃ for いることは // TODO: じゃ for では // TODO: なきゃ + なくちゃ diff --git a/test/deinflection/test.ts b/test/deinflection/test.ts index 5a123ba..3faa6f8 100644 --- a/test/deinflection/test.ts +++ b/test/deinflection/test.ts @@ -1,8 +1,8 @@ -import DirectCoreClient from '../../core/direct/client.ts'; import cases from "./cases.ts"; import { core } from '../base.ts'; +import { TokenTag } from '../../language/tags.ts'; -cases.forEach(({ input, tags }) => { +cases.forEach(({ input, mustHave, mustNotHave }) => { Deno.test(`deinflection - ${input}`, async () => { var { tokens } = await core.parseSentence(input); @@ -14,9 +14,14 @@ cases.forEach(({ input, tags }) => { if (!result) throw new Error("No deconjugation found for input"); - for (var tag of tags) + let tag: TokenTag; + for (tag of mustHave) if (!result.tags.includes(tag)) - throw new Error(`Deconjugation doesn't include tag ${tag}`); + throw new Error(`Deconjugation doesn't include required tag ${tag}`); + + for (tag of mustNotHave) + if (result.tags.includes(tag)) + throw new Error(`Deconjugation includes unallowed tag ${tag}`); }); }) |