This commit is contained in:
adueck 2024-02-08 23:07:29 +01:00
parent 221249271c
commit ae4ff6f27b
2 changed files with 23 additions and 14 deletions

View File

@ -11,7 +11,7 @@ const working = [
"phrases with simple verbs", "phrases with simple verbs",
"basic verb tenses", "basic verb tenses",
"noun phrases", "noun phrases",
"mini-pronouns for shrunken servants", "mini-pronouns",
"grammar error correction", "grammar error correction",
"negatives", "negatives",
"imperative verbs", "imperative verbs",
@ -21,14 +21,12 @@ const working = [
const todo = [ const todo = [
"compound verbs", "compound verbs",
"adjectival participles", "adjectival participles",
"adverbial phrases",
"relative clauses", "relative clauses",
"equative verbs", "equative verbs",
"ability verbs", "ability verbs",
"passive verbs", "passive verbs",
"quantifiers", "quantifiers",
"demonstrative pronouns", "demonstrative pronouns",
"mini-pronouns for possesives",
"approximate spelling", "approximate spelling",
]; ];
@ -38,7 +36,7 @@ const examples = [
"یو به مې ړلې", "یو به مې ړلې",
"د غټې ماشومې زاړه پلار ولیدم", "د غټې ماشومې زاړه پلار ولیدم",
"ستا پخواني ملګري مې ولیدل", "ستا پخواني ملګري مې ولیدل",
"پرون مې ولیدې", "پرون مې دې ملګرې ولیده",
"ما ډوډۍ خوړله", "ما ډوډۍ خوړله",
"وامې نه خیست", "وامې نه خیست",
"وبه مې وینې", "وبه مې وینې",

View File

@ -47,9 +47,8 @@ export function parseVP(
return []; return [];
} }
const blocks = parseBlocks(tokens, lookup, [], []); const blocks = parseBlocks(tokens, lookup, [], []);
const blocksWPossPossibilities = createPossesivePossibilities(blocks);
return bindParseResult( return bindParseResult(
blocksWPossPossibilities, createPossesivePossibilities(blocks),
(tokens, { blocks, kids }) => { (tokens, { blocks, kids }) => {
const ba = kids.some((k) => k === "ba"); const ba = kids.some((k) => k === "ba");
const miniPronouns = getMiniPronouns(kids); const miniPronouns = getMiniPronouns(kids);
@ -1055,6 +1054,26 @@ function mapOutnpsAndAps(
}); });
} }
/**
* Given a set of blocks and kids, produces all possible arrangements
* with the mini-pronouns being used as possesives, or not
*
* Case 1: no mini pronouns
* 1. return as is
*
* Case 2: one mini pronoun
* 1. don't use any as possesive
* 2. use the mini pronoun as a possesive (in all possible places)
*
* Case 3: two mini pronouns
* 1. don't use any as possesive
* 2. use first as possesive
* 3. use second as possesive
* 4. use both as possesives
*
* @param blocks
* @returns
*/
function createPossesivePossibilities( function createPossesivePossibilities(
blocks: T.ParseResult<{ blocks: T.ParseResult<{
kids: T.ParsedKid[]; kids: T.ParsedKid[];
@ -1064,14 +1083,6 @@ function createPossesivePossibilities(
kids: T.ParsedKid[]; kids: T.ParsedKid[];
blocks: T.ParsedBlock[]; blocks: T.ParsedBlock[];
}>[] { }>[] {
// Case 1: no mini pronouns
// Case 2: 1 mini pronoun
// - don't use any as possesive
// Case 3: 2 mini pronouns
// - don't use any as possesive
// - use first as possesive
// - use second as possesive
// - use both as possesive
function pullOutMiniPronoun( function pullOutMiniPronoun(
body: { body: {
kids: T.ParsedKid[]; kids: T.ParsedKid[];