add accent on uy endings

This commit is contained in:
lingdocs 2022-02-24 18:57:55 +04:00
parent 6a3fda7212
commit d2083c9c96
4 changed files with 41 additions and 16 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/pashto-inflector", "name": "@lingdocs/pashto-inflector",
"version": "1.5.0", "version": "1.5.1",
"author": "lingdocs.com", "author": "lingdocs.com",
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
"homepage": "https://verbs.lingdocs.com", "homepage": "https://verbs.lingdocs.com",

View File

@ -158,15 +158,15 @@ export function randomNumber(minInclusive: number, maxExclusive: number): number
* @param possiblePerson * @param possiblePerson
* @param existingPerson * @param existingPerson
*/ */
export function personIsAllowed(possiblePerson: T.Person, existingPerson: T.Person): boolean { export function personIsAllowed(possiblePerson: T.Person, existingPerson?: T.Person): boolean {
const isFirstPerson = (p: T.Person) => [0, 1, 6, 7].includes(p); const isFirstPerson = (p: T.Person) => [0, 1, 6, 7].includes(p);
const isSecondPerson = (p: T.Person) => [2, 3, 8, 9].includes(p); const isSecondPerson = (p: T.Person) => [2, 3, 8, 9].includes(p);
// can't have both subject and object be 1st person // can't have both subject and object be 1st person
if (isFirstPerson(possiblePerson) && isFirstPerson(existingPerson)) { if (isFirstPerson(possiblePerson) && (existingPerson && isFirstPerson(existingPerson))) {
return false; return false;
} }
// can't have both subject and object be 2nd person // can't have both subject and object be 2nd person
if (isSecondPerson(possiblePerson) && isSecondPerson(existingPerson)) { if (isSecondPerson(possiblePerson) && (existingPerson && isSecondPerson(existingPerson))) {
return false; return false;
} }
// otherwise it's ok // otherwise it's ok
@ -178,7 +178,7 @@ export function personIsAllowed(possiblePerson: T.Person, existingPerson: T.Pers
* *
* @param other * @param other
*/ */
export function randomPerson(other: T.Person): T.Person { export function randomPerson(other?: T.Person): T.Person {
let newPerson: T.Person; let newPerson: T.Person;
do { do {
newPerson = randomNumber(0, 12); newPerson = randomNumber(0, 12);

View File

@ -202,6 +202,31 @@ const adjectives: Array<{
}, },
}, },
}, },
{
in: {
ts: 1527812792,
p: "ښایسته",
f: "xaaystu",
g: "xaaystu",
e: "beautiful",
c: "adj.",
i: 1,
},
out: {
inflections: {
masc: [
[{p: "ښایسته", f: "xaaystu"}],
[{p: "ښایسته", f: "xaaystu"}],
[{p: "ښایستو", f: "xaaysto"}],
],
fem: [
[{p: "ښایسته", f: "xaaysta"}],
[{p: "ښایستې", f: "xaayste"}],
[{p: "ښایستو", f: "xaaysto"}],
],
},
},
},
// numbers should inflect just like adjectives // numbers should inflect just like adjectives
{ {
in: {"ts":1588688995113,"i":8176,"p":"شپږ","f":"shpuG","g":"shpug","e":"six","c":"num."}, in: {"ts":1588688995113,"i":8176,"p":"شپږ","f":"shpuG","g":"shpug","e":"six","c":"num."},
@ -1018,8 +1043,8 @@ const nouns: Array<{
inflections: { inflections: {
fem: [ fem: [
[{p: "دوستي", f: "dostee"}], [{p: "دوستي", f: "dostee"}],
[{p: "دوستۍ", f: "dostuy"}], [{p: "دوستۍ", f: "dostúy"}],
[{p: "دوستیو", f: "dostuyo"}], [{p: "دوستیو", f: "dostúyo"}],
], ],
}, },
}, },
@ -1038,9 +1063,9 @@ const nouns: Array<{
out: { out: {
inflections: { inflections: {
fem: [ fem: [
[{p: "کرسۍ", f: "kUrsuy"}], [{p: "کرسۍ", f: "kUrsúy"}],
[{p: "کرسۍ", f: "kUrsuy"}], [{p: "کرسۍ", f: "kUrsúy"}],
[{p: "کرسیو", f: "kUrsuyo"}, { p: "کرسو", f: "kUrso"}], [{p: "کرسیو", f: "kUrsúyo"}, { p: "کرسو", f: "kUrso"}],
], ],
}, },
}, },

View File

@ -379,21 +379,21 @@ function inflectRegularInanEeFem(p: string, f: string): T.Inflections {
return { return {
fem: [ fem: [
[{p, f}], [{p, f}],
[{p: `${baseP}ۍ`, f: `${baseF}uy`}], [{p: `${baseP}ۍ`, f: `${baseF}úy`}],
[{p: `${baseP}یو`, f: `${baseF}uyo`}], [{p: `${baseP}یو`, f: `${baseF}úyo`}],
], ],
}; };
} }
function inflectRegularUyFem(p: string, f: string): T.Inflections { function inflectRegularUyFem(p: string, f: string): T.Inflections {
const baseP = p.slice(0, -1); const baseP = p.slice(0, -1);
const baseF = f.slice(0, -2); const baseF = removeAccents(f.slice(0, -2));
return { return {
fem: [ fem: [
[{p, f}], [{p, f: `${baseF}úy`}],
[{p, f}], [{p, f: `${baseF}úy`}],
[ [
{p: `${baseP}یو`, f: `${baseF}uyo`}, {p: `${baseP}یو`, f: `${baseF}úyo`},
{p: `${baseP}و`, f: `${baseF}o`}, {p: `${baseP}و`, f: `${baseF}o`},
], ],
], ],