messy working with grammatically transitive verbs
This commit is contained in:
parent
a3dbf550f0
commit
77d20ecf02
|
@ -29,6 +29,8 @@ import { LookupFunction } from "./lookup";
|
|||
// TODO: learn how to yank / use plugin for JSON neovim
|
||||
// learn to use jq to edit selected json in vim ?? COOOL
|
||||
|
||||
// TODO: test grammatically transitive stuff
|
||||
|
||||
export function parseVP(
|
||||
tokens: Readonly<T.Token[]>,
|
||||
lookup: LookupFunction
|
||||
|
@ -74,13 +76,14 @@ export function parseVP(
|
|||
}
|
||||
const tense = getTenseFromRootsStems(ba, verb.info.base, verb.info.aspect);
|
||||
const isPast = isPastTense(tense);
|
||||
|
||||
const transitivities = getTransitivities(verb.info.verb);
|
||||
const results: T.ParseResult<T.VPSelectionComplete>[] = [];
|
||||
// eww... pretty imperative way of doing this...
|
||||
for (let transitivity of transitivities) {
|
||||
const v: T.VerbSelectionComplete = {
|
||||
type: "verb",
|
||||
verb: verb.info.verb,
|
||||
transitivity: verb.info.verb.entry.c.includes("intrans")
|
||||
? "intransitive"
|
||||
: "transitive",
|
||||
transitivity,
|
||||
canChangeTransitivity: false,
|
||||
canChangeStatDyn: false,
|
||||
negative,
|
||||
|
@ -91,8 +94,7 @@ export function parseVP(
|
|||
};
|
||||
|
||||
const nps = blocks.filter((x): x is T.ParsedNP => x.type === "NP");
|
||||
// TODO: check that verb and PH match
|
||||
if (verb.info.verb.entry.c.includes("intrans")) {
|
||||
if (transitivity === "intransitive") {
|
||||
const errors: T.ParseError[] = [];
|
||||
if (getMiniPronouns(kids).length) {
|
||||
errors.push({
|
||||
|
@ -100,7 +102,7 @@ export function parseVP(
|
|||
});
|
||||
}
|
||||
if (nps.length > 1) {
|
||||
return [];
|
||||
continue;
|
||||
}
|
||||
if (nps.length === 0) {
|
||||
const blocks: T.VPSBlockComplete[] = [
|
||||
|
@ -119,9 +121,9 @@ export function parseVP(
|
|||
},
|
||||
},
|
||||
];
|
||||
return returnParseResult(
|
||||
results.push({
|
||||
tokens,
|
||||
{
|
||||
body: {
|
||||
blocks,
|
||||
verb: v,
|
||||
externalComplement: undefined,
|
||||
|
@ -130,8 +132,9 @@ export function parseVP(
|
|||
shrinkServant: false,
|
||||
},
|
||||
} as T.VPSelectionComplete,
|
||||
errors
|
||||
);
|
||||
errors,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (getPersonFromNP(nps[0].selection) !== verb.person) {
|
||||
errors.push({ message: "subject must agree with intransitive verb" });
|
||||
|
@ -154,9 +157,9 @@ export function parseVP(
|
|||
},
|
||||
},
|
||||
];
|
||||
return returnParseResult(
|
||||
results.push({
|
||||
tokens,
|
||||
{
|
||||
body: {
|
||||
blocks,
|
||||
verb: v,
|
||||
externalComplement: undefined,
|
||||
|
@ -165,12 +168,13 @@ export function parseVP(
|
|||
shrinkServant: false,
|
||||
},
|
||||
} as T.VPSelectionComplete,
|
||||
errors
|
||||
);
|
||||
} else {
|
||||
errors,
|
||||
});
|
||||
continue;
|
||||
} else if (transitivity === "transitive") {
|
||||
// transitive
|
||||
if (nps.length > 2) {
|
||||
return [];
|
||||
continue;
|
||||
}
|
||||
if (nps.length === 0) {
|
||||
// present:
|
||||
|
@ -223,7 +227,7 @@ export function parseVP(
|
|||
},
|
||||
]
|
||||
);
|
||||
return blockOpts.flatMap((blocks) =>
|
||||
const toAdd = blockOpts.flatMap((blocks) =>
|
||||
returnParseResult(
|
||||
tokens,
|
||||
{
|
||||
|
@ -240,6 +244,8 @@ export function parseVP(
|
|||
: errors
|
||||
)
|
||||
);
|
||||
toAdd.forEach((r) => results.push(r));
|
||||
continue;
|
||||
}
|
||||
if (nps.length === 1) {
|
||||
const np = nps[0];
|
||||
|
@ -250,7 +256,7 @@ export function parseVP(
|
|||
// past:
|
||||
// - no king (np is servant)
|
||||
// - shrunken servant (np is king)
|
||||
return (
|
||||
const res = (
|
||||
[
|
||||
{
|
||||
removeKing: true,
|
||||
|
@ -352,9 +358,11 @@ export function parseVP(
|
|||
: errors,
|
||||
}));
|
||||
});
|
||||
res.forEach((r) => results.push(r));
|
||||
continue;
|
||||
} else {
|
||||
if (isPast) {
|
||||
return (
|
||||
const res = (
|
||||
[
|
||||
[nps[0], nps[1], false],
|
||||
[nps[1], nps[0], true],
|
||||
|
@ -416,8 +424,10 @@ export function parseVP(
|
|||
errors
|
||||
);
|
||||
});
|
||||
res.forEach((r) => results.push(r));
|
||||
continue;
|
||||
} else {
|
||||
return (
|
||||
const res = (
|
||||
[
|
||||
[nps[0], nps[1], false],
|
||||
[nps[1], nps[0], true],
|
||||
|
@ -488,9 +498,114 @@ export function parseVP(
|
|||
errors
|
||||
);
|
||||
});
|
||||
res.forEach((r) => results.push(r));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// grammatically transitive
|
||||
const errors: T.ParseError[] = [];
|
||||
if (nps.length === 1) {
|
||||
if (getMiniPronouns(kids).length) {
|
||||
errors.push({
|
||||
message: "unknown mini-pronoun",
|
||||
});
|
||||
}
|
||||
if (verb.person !== T.Person.ThirdPlurMale) {
|
||||
errors.push({
|
||||
message:
|
||||
"grammatically transitive verb must be 3rd pers. masc. plur.",
|
||||
});
|
||||
}
|
||||
if (!nps[0].inflected) {
|
||||
errors.push({
|
||||
message:
|
||||
"subject of grammatically transitive verb must be inflected",
|
||||
});
|
||||
}
|
||||
const blocks: T.VPSBlockComplete[] = [
|
||||
{
|
||||
key: 1,
|
||||
block: makeSubjectSelectionComplete(nps[0].selection),
|
||||
},
|
||||
{
|
||||
key: 2,
|
||||
block: {
|
||||
type: "objectSelection",
|
||||
selection: T.Person.ThirdPlurMale,
|
||||
},
|
||||
},
|
||||
];
|
||||
results.push({
|
||||
tokens,
|
||||
body: {
|
||||
blocks,
|
||||
verb: v,
|
||||
externalComplement: undefined,
|
||||
form: {
|
||||
removeKing: false,
|
||||
shrinkServant: false,
|
||||
},
|
||||
} as T.VPSelectionComplete,
|
||||
errors,
|
||||
});
|
||||
continue;
|
||||
} else if (nps.length === 0) {
|
||||
const miniPronouns = getMiniPronouns(kids);
|
||||
if (miniPronouns.length > 1) {
|
||||
errors.push({
|
||||
message: "unknown mini-pronoun",
|
||||
});
|
||||
}
|
||||
if (miniPronouns.length === 0) {
|
||||
errors.push({
|
||||
message: "subject required for grammatically transitive verb",
|
||||
});
|
||||
}
|
||||
if (verb.person !== T.Person.ThirdPlurMale) {
|
||||
errors.push({
|
||||
message:
|
||||
"grammatically transitive verb must be 3rd pers. masc. plur.",
|
||||
});
|
||||
}
|
||||
getPeopleFromMiniPronouns(kids).forEach((person) => {
|
||||
const blocks: T.VPSBlockComplete[] = [
|
||||
{
|
||||
key: 1,
|
||||
block: makeSubjectSelectionComplete({
|
||||
type: "NP",
|
||||
selection: makePronounSelection(person),
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 2,
|
||||
block: {
|
||||
type: "objectSelection",
|
||||
selection: T.Person.ThirdPlurMale,
|
||||
},
|
||||
},
|
||||
];
|
||||
results.push({
|
||||
tokens,
|
||||
body: {
|
||||
blocks,
|
||||
verb: v,
|
||||
externalComplement: undefined,
|
||||
form: {
|
||||
removeKing: false,
|
||||
shrinkServant: false,
|
||||
},
|
||||
} as T.VPSelectionComplete,
|
||||
errors,
|
||||
});
|
||||
});
|
||||
continue;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -588,3 +703,18 @@ function pronounConflictInBlocks(blocks: T.VPSBlockComplete[]): boolean {
|
|||
}
|
||||
return isInvalidSubjObjCombo(subjPerson, objPerson);
|
||||
}
|
||||
|
||||
function getTransitivities(v: T.VerbEntry): T.Transitivity[] {
|
||||
const transitivities: T.Transitivity[] = [];
|
||||
const opts = v.entry.c.split("/");
|
||||
opts.forEach((opt) => {
|
||||
if (opt.includes("gramm. trans")) {
|
||||
transitivities.push("grammatically transitive");
|
||||
} else if (opt.includes("intran")) {
|
||||
transitivities.push("intransitive");
|
||||
} else if (opt.includes("trans")) {
|
||||
transitivities.push("transitive");
|
||||
}
|
||||
});
|
||||
return transitivities;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue