diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-07-06 16:22:26 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-07-06 16:22:26 +0200 |
commit | cb78013884e3aa3b1e1a91722f5eeb78c62f6796 (patch) | |
tree | 72a40258a246607ecb59eb596e417f81181b59a7 /test/deinflection | |
parent | 4e32a1942ff2478b557af1b900b3f3282d7ce55b (diff) |
update tests
Diffstat (limited to 'test/deinflection')
-rw-r--r-- | test/deinflection/cases.ts | 31 | ||||
-rw-r--r-- | test/deinflection/test.ts | 24 |
2 files changed, 55 insertions, 0 deletions
diff --git a/test/deinflection/cases.ts b/test/deinflection/cases.ts new file mode 100644 index 0000000..04df2bd --- /dev/null +++ b/test/deinflection/cases.ts @@ -0,0 +1,31 @@ +import { TokenTags, Tag } from "../../language/tags.ts"; +const { Inflection } = Tag; + +interface Test { + input: string; + tags: 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.Imperative ], }, + { input: "取るな", tags: [ Inflection.Negative, Inflection.Imperative ], }, +] satisfies Test[]; + diff --git a/test/deinflection/test.ts b/test/deinflection/test.ts new file mode 100644 index 0000000..3dc702b --- /dev/null +++ b/test/deinflection/test.ts @@ -0,0 +1,24 @@ +import DirectCoreClient from '../../core/direct/client.ts'; +import cases from "./cases.ts"; + +var core = new DirectCoreClient(); +await core.ready; + +cases.forEach(({ input, tags }) => { + Deno.test(`deinflection - ${input}`, async () => { + var { tokens } = await core.parseSentence(input); + + if (tokens.length == 0) + throw new Error("No parsed tokens for input"); + + // console.log(tokens); + var result = tokens.find(t => t.source == input); + if (!result) + throw new Error("No deconjugation found for input"); + + for (var tag of tags) + if (!result.tags.includes(tag)) + throw new Error(`Deconjugation doesn't include tag ${tag}`); + }); +}) + |