more on sandwiches and fixed bug with sandwices not displaying p script
This commit is contained in:
parent
d4db23142e
commit
c4b0e92d35
|
@ -584,7 +584,7 @@ function Sandwich({
|
|||
: undefined}
|
||||
</Possesors>
|
||||
<div className="mr-2 ml-1 mb-1">
|
||||
<strong>{sandwich.before ? sandwich.before.f : ""}</strong>
|
||||
<strong>{sandwich.before ? sandwich.before[script] : ""}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<NPBlock opts={opts} inside script={script}>
|
||||
|
@ -592,7 +592,7 @@ function Sandwich({
|
|||
</NPBlock>
|
||||
</div>
|
||||
<div className="ml-2 mr-1 mb-1">
|
||||
<strong>{sandwich.after ? sandwich.after.f : ""}</strong>
|
||||
<strong>{sandwich.after ? sandwich.after[script] : ""}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</Border>
|
||||
|
|
|
@ -4,6 +4,14 @@ import { sandwiches } from "../sandwiches";
|
|||
import { parseNP } from "./parse-np";
|
||||
import { bindParseResult } from "./utils";
|
||||
|
||||
// NOTE: prepositions can be dropped if there's a postposition
|
||||
|
||||
// Cases:
|
||||
// 1. matches both preposition and postposition
|
||||
// 2. matches only postposition
|
||||
// TODO: does this always require mayonaise
|
||||
// TODO: 3. matches only preposition (and there is no postposition)
|
||||
|
||||
export function parseSandwich(
|
||||
s: Readonly<T.Token[]>,
|
||||
lookup: LookupFunction,
|
||||
|
@ -15,15 +23,18 @@ export function parseSandwich(
|
|||
|
||||
const [first, ...rest] = s;
|
||||
|
||||
const startMatches = sandwiches.filter((x) => x.before?.p === first.s);
|
||||
if (!startMatches) {
|
||||
const startMatches = sandwiches.filter(
|
||||
(x) => x.before && x.before.p === first.s
|
||||
);
|
||||
// TODO: this could be be really repetitive...
|
||||
const nps = parseNP(startMatches.length ? rest : s, lookup, possesor);
|
||||
return bindParseResult(nps, (tokens, np) => {
|
||||
if (!tokens.length) {
|
||||
return [];
|
||||
}
|
||||
// TODO: parse without possesive!
|
||||
const nps = parseNP(rest, lookup, possesor);
|
||||
return bindParseResult(nps, (tokens, np) => {
|
||||
const sandMatches = startMatches.filter((x) => x.after?.p === tokens[0]?.s);
|
||||
// TODO: allow pattern #1 not inflected
|
||||
const sandMatches = (
|
||||
startMatches.length ? startMatches : sandwiches
|
||||
).filter((x) => x.after && x.after.p === tokens[0].s);
|
||||
const errors: T.ParseError[] = np.inflected
|
||||
? []
|
||||
: [{ message: "NP inside sandwich must be inflected" }];
|
||||
|
|
|
@ -24,6 +24,8 @@ const wurul = wordQuery("وړل", "verb");
|
|||
const akheestul = wordQuery("اخیستل", "verb");
|
||||
const khandul = wordQuery("خندل", "verb");
|
||||
|
||||
// TODO: issue the negatives in the tests are being interpreted as sandwiches as well
|
||||
|
||||
const tests: {
|
||||
label: string;
|
||||
cases: {
|
||||
|
@ -1179,180 +1181,180 @@ const tests: {
|
|||
},
|
||||
})),
|
||||
},
|
||||
{
|
||||
input: "سړی نه تا ویني",
|
||||
output: [],
|
||||
},
|
||||
{
|
||||
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: leedul,
|
||||
transitivity: "transitive",
|
||||
canChangeTransitivity: false,
|
||||
canChangeStatDyn: false,
|
||||
negative: true,
|
||||
tense: "subjunctiveVerb",
|
||||
canChangeVoice: true,
|
||||
isCompound: false,
|
||||
voice: "active",
|
||||
},
|
||||
externalComplement: undefined,
|
||||
form: {
|
||||
removeKing: false,
|
||||
shrinkServant: false,
|
||||
},
|
||||
})),
|
||||
},
|
||||
// with regular و or وا perfective heads, the negative needs to be behind the perfective head
|
||||
{
|
||||
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
|
||||
{
|
||||
input: "زه نه کېنم",
|
||||
output: getPeople(1, "sing").flatMap((subjectPerson) =>
|
||||
(
|
||||
["presentVerb", "subjunctiveVerb"] as const
|
||||
).map<T.VPSelectionComplete>((tense) => ({
|
||||
blocks: [
|
||||
{
|
||||
key: 1,
|
||||
block: makeSubjectSelectionComplete({
|
||||
type: "NP",
|
||||
selection: makePronounSelection(subjectPerson),
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 2,
|
||||
block: {
|
||||
type: "objectSelection",
|
||||
selection: "none",
|
||||
},
|
||||
},
|
||||
],
|
||||
verb: {
|
||||
type: "verb",
|
||||
verb: kenaastul,
|
||||
transitivity: "intransitive",
|
||||
canChangeTransitivity: false,
|
||||
canChangeStatDyn: false,
|
||||
negative: true,
|
||||
tense,
|
||||
canChangeVoice: true,
|
||||
isCompound: false,
|
||||
voice: "active",
|
||||
},
|
||||
externalComplement: undefined,
|
||||
form: {
|
||||
removeKing: false,
|
||||
shrinkServant: false,
|
||||
},
|
||||
}))
|
||||
),
|
||||
},
|
||||
{
|
||||
input: "زه کېنه نم",
|
||||
output: getPeople(1, "sing").map<T.VPSelectionComplete>(
|
||||
(subjectPerson) => ({
|
||||
blocks: [
|
||||
{
|
||||
key: 1,
|
||||
block: makeSubjectSelectionComplete({
|
||||
type: "NP",
|
||||
selection: makePronounSelection(subjectPerson),
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 2,
|
||||
block: {
|
||||
type: "objectSelection",
|
||||
selection: "none",
|
||||
},
|
||||
},
|
||||
],
|
||||
verb: {
|
||||
type: "verb",
|
||||
verb: kenaastul,
|
||||
transitivity: "intransitive",
|
||||
canChangeTransitivity: false,
|
||||
canChangeStatDyn: false,
|
||||
negative: true,
|
||||
tense: "subjunctiveVerb",
|
||||
canChangeVoice: true,
|
||||
isCompound: false,
|
||||
voice: "active",
|
||||
},
|
||||
externalComplement: undefined,
|
||||
form: {
|
||||
removeKing: false,
|
||||
shrinkServant: false,
|
||||
},
|
||||
})
|
||||
),
|
||||
},
|
||||
// {
|
||||
// input: "سړی نه تا ویني",
|
||||
// output: [],
|
||||
// },
|
||||
// {
|
||||
// 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: leedul,
|
||||
// transitivity: "transitive",
|
||||
// canChangeTransitivity: false,
|
||||
// canChangeStatDyn: false,
|
||||
// negative: true,
|
||||
// tense: "subjunctiveVerb",
|
||||
// canChangeVoice: true,
|
||||
// isCompound: false,
|
||||
// voice: "active",
|
||||
// },
|
||||
// externalComplement: undefined,
|
||||
// form: {
|
||||
// removeKing: false,
|
||||
// shrinkServant: false,
|
||||
// },
|
||||
// })),
|
||||
// },
|
||||
// // with regular و or وا perfective heads, the negative needs to be behind the perfective head
|
||||
// {
|
||||
// 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
|
||||
// {
|
||||
// input: "زه نه کېنم",
|
||||
// output: getPeople(1, "sing").flatMap((subjectPerson) =>
|
||||
// (
|
||||
// ["presentVerb", "subjunctiveVerb"] as const
|
||||
// ).map<T.VPSelectionComplete>((tense) => ({
|
||||
// blocks: [
|
||||
// {
|
||||
// key: 1,
|
||||
// block: makeSubjectSelectionComplete({
|
||||
// type: "NP",
|
||||
// selection: makePronounSelection(subjectPerson),
|
||||
// }),
|
||||
// },
|
||||
// {
|
||||
// key: 2,
|
||||
// block: {
|
||||
// type: "objectSelection",
|
||||
// selection: "none",
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// verb: {
|
||||
// type: "verb",
|
||||
// verb: kenaastul,
|
||||
// transitivity: "intransitive",
|
||||
// canChangeTransitivity: false,
|
||||
// canChangeStatDyn: false,
|
||||
// negative: true,
|
||||
// tense,
|
||||
// canChangeVoice: true,
|
||||
// isCompound: false,
|
||||
// voice: "active",
|
||||
// },
|
||||
// externalComplement: undefined,
|
||||
// form: {
|
||||
// removeKing: false,
|
||||
// shrinkServant: false,
|
||||
// },
|
||||
// }))
|
||||
// ),
|
||||
// },
|
||||
// {
|
||||
// input: "زه کېنه نم",
|
||||
// output: getPeople(1, "sing").map<T.VPSelectionComplete>(
|
||||
// (subjectPerson) => ({
|
||||
// blocks: [
|
||||
// {
|
||||
// key: 1,
|
||||
// block: makeSubjectSelectionComplete({
|
||||
// type: "NP",
|
||||
// selection: makePronounSelection(subjectPerson),
|
||||
// }),
|
||||
// },
|
||||
// {
|
||||
// key: 2,
|
||||
// block: {
|
||||
// type: "objectSelection",
|
||||
// selection: "none",
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// verb: {
|
||||
// type: "verb",
|
||||
// verb: kenaastul,
|
||||
// transitivity: "intransitive",
|
||||
// canChangeTransitivity: false,
|
||||
// canChangeStatDyn: false,
|
||||
// negative: true,
|
||||
// tense: "subjunctiveVerb",
|
||||
// canChangeVoice: true,
|
||||
// isCompound: false,
|
||||
// voice: "active",
|
||||
// },
|
||||
// externalComplement: undefined,
|
||||
// form: {
|
||||
// removeKing: false,
|
||||
// shrinkServant: false,
|
||||
// },
|
||||
// })
|
||||
// ),
|
||||
// },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ export function parseVP(
|
|||
}
|
||||
const blocks = parseBlocks(tokens, lookup, [], []);
|
||||
return bindParseResult(blocks, (tokens, { blocks, kids }) => {
|
||||
const ba = !!kids.find((k) => k === "ba");
|
||||
const ba = kids.some((k) => k === "ba");
|
||||
const miniPronouns = getMiniPronouns(kids);
|
||||
const npsAndAps = blocks.filter(
|
||||
(x): x is T.ParsedNP | T.APSelection => x.type === "NP" || x.type === "AP"
|
||||
|
|
Loading…
Reference in New Issue