fix tests

This commit is contained in:
adueck 2023-10-02 16:39:36 -04:00
parent 91c2b4a354
commit 8c336e8a71
1 changed files with 186 additions and 177 deletions

View File

@ -21,6 +21,7 @@ const maashoom = wordQuery("ماشوم", "noun");
const leedul = wordQuery("لیدل", "verb"); const leedul = wordQuery("لیدل", "verb");
const kenaastul = wordQuery("کېناستل", "verb"); const kenaastul = wordQuery("کېناستل", "verb");
const wurul = wordQuery("وړل", "verb"); const wurul = wordQuery("وړل", "verb");
const wahul = wordQuery("وهل", "verb");
const akheestul = wordQuery("اخیستل", "verb"); const akheestul = wordQuery("اخیستل", "verb");
const khandul = wordQuery("خندل", "verb"); const khandul = wordQuery("خندل", "verb");
@ -28,6 +29,7 @@ const khandul = wordQuery("خندل", "verb");
const tests: { const tests: {
label: string; label: string;
ignoreAPs?: boolean;
cases: { cases: {
input: string; input: string;
output: T.VPSelectionComplete[]; output: T.VPSelectionComplete[];
@ -1142,9 +1144,52 @@ const tests: {
}, },
{ {
label: "negatives and ordering", label: "negatives and ordering",
ignoreAPs: true,
cases: [ cases: [
{ {
input: "سړی تا نه ویني", input: "سړی تا نه وهي",
output: [...getPeople(2, "sing")].flatMap((objectPerson) => ({
blocks: [
{
key: 1,
block: makeSubjectSelectionComplete({
type: "NP",
selection: makeNounSelection(sarey, undefined),
}),
},
{
key: 2,
block: makeObjectSelectionComplete({
type: "NP",
selection: makePronounSelection(objectPerson),
}),
},
],
verb: {
type: "verb",
verb: wahul,
transitivity: "transitive",
canChangeTransitivity: false,
canChangeStatDyn: false,
negative: true,
tense: "presentVerb",
canChangeVoice: true,
isCompound: false,
voice: "active",
},
externalComplement: undefined,
form: {
removeKing: false,
shrinkServant: false,
},
})),
},
{
input: "سړی نه تا ویني",
output: [],
},
{
input: "سړی تا ونه ویني",
output: [...getPeople(2, "sing")].flatMap((objectPerson) => ({ output: [...getPeople(2, "sing")].flatMap((objectPerson) => ({
blocks: [ blocks: [
{ {
@ -1169,7 +1214,7 @@ const tests: {
canChangeTransitivity: false, canChangeTransitivity: false,
canChangeStatDyn: false, canChangeStatDyn: false,
negative: true, negative: true,
tense: "presentVerb", tense: "subjunctiveVerb",
canChangeVoice: true, canChangeVoice: true,
isCompound: false, isCompound: false,
voice: "active", voice: "active",
@ -1181,180 +1226,138 @@ const tests: {
}, },
})), })),
}, },
// { // with regular و or وا perfective heads, the negative needs to be behind the perfective head
// input: "سړی نه تا ویني", {
// output: [], input: "سړی تا نه وویني",
// }, output: [],
// { },
// input: "سړی تا ونه ویني", {
// output: [...getPeople(2, "sing")].flatMap((objectPerson) => ({ input: "سړي وانه خیستله",
// blocks: [ output: [
// { {
// key: 1, blocks: [
// block: makeSubjectSelectionComplete({ {
// type: "NP", key: 1,
// selection: makeNounSelection(sarey, undefined), block: makeSubjectSelectionComplete({
// }), type: "NP",
// }, selection: makeNounSelection(sarey, undefined),
// { }),
// key: 2, },
// block: makeObjectSelectionComplete({ {
// type: "NP", key: 2,
// selection: makePronounSelection(objectPerson), block: makeObjectSelectionComplete({
// }), type: "NP",
// }, selection: makePronounSelection(T.Person.ThirdSingFemale),
// ], }),
// verb: { },
// type: "verb", ],
// verb: leedul, verb: {
// transitivity: "transitive", type: "verb",
// canChangeTransitivity: false, verb: akheestul,
// canChangeStatDyn: false, transitivity: "transitive",
// negative: true, canChangeTransitivity: false,
// tense: "subjunctiveVerb", canChangeStatDyn: false,
// canChangeVoice: true, negative: true,
// isCompound: false, tense: "perfectivePast",
// voice: "active", canChangeVoice: true,
// }, isCompound: false,
// externalComplement: undefined, voice: "active",
// form: { },
// removeKing: false, externalComplement: undefined,
// shrinkServant: false, form: {
// }, removeKing: true,
// })), shrinkServant: false,
// }, },
// // with regular و or وا perfective heads, the negative needs to be behind the perfective head },
// { ],
// input: "سړی تا نه وویني", },
// output: [], {
// }, input: "سړي نه واخیستله",
// { output: [],
// input: "سړي وانه خیستله", },
// output: [
// {
// blocks: [
// {
// key: 1,
// block: makeSubjectSelectionComplete({
// type: "NP",
// selection: makeNounSelection(sarey, undefined),
// }),
// },
// {
// key: 2,
// block: makeObjectSelectionComplete({
// type: "NP",
// selection: makePronounSelection(T.Person.ThirdSingFemale),
// }),
// },
// ],
// verb: {
// type: "verb",
// verb: akheestul,
// transitivity: "transitive",
// canChangeTransitivity: false,
// canChangeStatDyn: false,
// negative: true,
// tense: "perfectivePast",
// canChangeVoice: true,
// isCompound: false,
// voice: "active",
// },
// externalComplement: undefined,
// form: {
// removeKing: true,
// shrinkServant: false,
// },
// },
// ],
// },
// {
// input: "سړي نه واخیستله",
// output: [],
// },
// // but for other perfective heads, the negative can go before or after // // but for other perfective heads, the negative can go before or after
// { {
// input: "زه نه کېنم", input: "زه نه کېنم",
// output: getPeople(1, "sing").flatMap((subjectPerson) => output: getPeople(1, "sing").flatMap((subjectPerson) =>
// ( (
// ["presentVerb", "subjunctiveVerb"] as const ["presentVerb", "subjunctiveVerb"] as const
// ).map<T.VPSelectionComplete>((tense) => ({ ).map<T.VPSelectionComplete>((tense) => ({
// blocks: [ blocks: [
// { {
// key: 1, key: 1,
// block: makeSubjectSelectionComplete({ block: makeSubjectSelectionComplete({
// type: "NP", type: "NP",
// selection: makePronounSelection(subjectPerson), selection: makePronounSelection(subjectPerson),
// }), }),
// }, },
// { {
// key: 2, key: 2,
// block: { block: {
// type: "objectSelection", type: "objectSelection",
// selection: "none", selection: "none",
// }, },
// }, },
// ], ],
// verb: { verb: {
// type: "verb", type: "verb",
// verb: kenaastul, verb: kenaastul,
// transitivity: "intransitive", transitivity: "intransitive",
// canChangeTransitivity: false, canChangeTransitivity: false,
// canChangeStatDyn: false, canChangeStatDyn: false,
// negative: true, negative: true,
// tense, tense,
// canChangeVoice: true, canChangeVoice: true,
// isCompound: false, isCompound: false,
// voice: "active", voice: "active",
// }, },
// externalComplement: undefined, externalComplement: undefined,
// form: { form: {
// removeKing: false, removeKing: false,
// shrinkServant: false, shrinkServant: false,
// }, },
// })) }))
// ), ),
// }, },
// { {
// input: "زه کېنه نم", input: "زه کېنه نم",
// output: getPeople(1, "sing").map<T.VPSelectionComplete>( output: getPeople(1, "sing").map<T.VPSelectionComplete>(
// (subjectPerson) => ({ (subjectPerson) => ({
// blocks: [ blocks: [
// { {
// key: 1, key: 1,
// block: makeSubjectSelectionComplete({ block: makeSubjectSelectionComplete({
// type: "NP", type: "NP",
// selection: makePronounSelection(subjectPerson), selection: makePronounSelection(subjectPerson),
// }), }),
// }, },
// { {
// key: 2, key: 2,
// block: { block: {
// type: "objectSelection", type: "objectSelection",
// selection: "none", selection: "none",
// }, },
// }, },
// ], ],
// verb: { verb: {
// type: "verb", type: "verb",
// verb: kenaastul, verb: kenaastul,
// transitivity: "intransitive", transitivity: "intransitive",
// canChangeTransitivity: false, canChangeTransitivity: false,
// canChangeStatDyn: false, canChangeStatDyn: false,
// negative: true, negative: true,
// tense: "subjunctiveVerb", tense: "subjunctiveVerb",
// canChangeVoice: true, canChangeVoice: true,
// isCompound: false, isCompound: false,
// voice: "active", voice: "active",
// }, },
// externalComplement: undefined, externalComplement: undefined,
// form: { form: {
// removeKing: false, removeKing: false,
// shrinkServant: false, shrinkServant: false,
// }, },
// }) })
// ), ),
// }, },
], ],
}, },
{ {
@ -1651,11 +1654,13 @@ const tests: {
}, },
]; ];
tests.forEach(({ label, cases }) => { tests.forEach(({ label, cases, ignoreAPs }) => {
test(label, () => { test(label, () => {
cases.forEach(({ input, output, error }) => { cases.forEach(({ input, output, error }) => {
const tokens = tokenizer(input); const tokens = tokenizer(input);
const parsed = parseVP(tokens, lookup); const parsed = parseVP(tokens, lookup).filter(
ignoreAPs ? hasNoAps : (x) => x
);
if (error) { if (error) {
expect(parsed.filter((x) => x.errors.length).length).toBeTruthy(); expect(parsed.filter((x) => x.errors.length).length).toBeTruthy();
} else { } else {
@ -1667,3 +1672,7 @@ tests.forEach(({ label, cases }) => {
}); });
}); });
}); });
function hasNoAps(r: T.ParseResult<T.VPSelectionComplete>): boolean {
return !r.body.blocks.some((b) => b.block.type === "AP");
}