rough add of bundled plurals
This commit is contained in:
parent
9e41a7968c
commit
7806ce8e49
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "pashto-inflector",
|
"name": "pashto-inflector",
|
||||||
"version": "5.2.1",
|
"version": "5.3.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pashto-inflector",
|
"name": "pashto-inflector",
|
||||||
"version": "5.2.1",
|
"version": "5.3.0",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "pashto-inflector",
|
"name": "pashto-inflector",
|
||||||
"version": "5.2.1",
|
"version": "5.3.0",
|
||||||
"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",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/ps-react",
|
"name": "@lingdocs/ps-react",
|
||||||
"version": "5.2.1",
|
"version": "5.3.0",
|
||||||
"description": "Pashto inflector library module with React components",
|
"description": "Pashto inflector library module with React components",
|
||||||
"main": "dist/components/library.js",
|
"main": "dist/components/library.js",
|
||||||
"module": "dist/components/library.js",
|
"module": "dist/components/library.js",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/inflect",
|
"name": "@lingdocs/inflect",
|
||||||
"version": "5.2.1",
|
"version": "5.3.0",
|
||||||
"description": "Pashto inflector library",
|
"description": "Pashto inflector library",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/lib/library.d.ts",
|
"types": "dist/lib/library.d.ts",
|
||||||
|
|
|
@ -14,10 +14,10 @@ import {
|
||||||
} from "./pashto-inflector";
|
} from "./pashto-inflector";
|
||||||
import * as T from "../../types";
|
import * as T from "../../types";
|
||||||
|
|
||||||
const adjectives: Array<{
|
const adjectives: {
|
||||||
in: T.DictionaryEntry,
|
in: T.DictionaryEntry,
|
||||||
out: T.InflectorOutput,
|
out: T.InflectorOutput,
|
||||||
}> = [
|
}[] = [
|
||||||
// irregular adj.
|
// irregular adj.
|
||||||
{
|
{
|
||||||
in: {
|
in: {
|
||||||
|
@ -334,10 +334,10 @@ const adjectives: Array<{
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const nouns: Array<{
|
const nouns: {
|
||||||
in: T.DictionaryEntry,
|
in: T.DictionaryEntry,
|
||||||
out: T.InflectorOutput,
|
out: T.InflectorOutput,
|
||||||
}> = [
|
}[] = [
|
||||||
// ## UNISEX
|
// ## UNISEX
|
||||||
// Unisex noun irregular
|
// Unisex noun irregular
|
||||||
{
|
{
|
||||||
|
@ -453,6 +453,12 @@ const nouns: Array<{
|
||||||
[{p: "چرګانو", f: "churgáano"}],
|
[{p: "چرګانو", f: "churgáano"}],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
bundledPlural: {
|
||||||
|
masc: [
|
||||||
|
[{ p: "چرګه", f: "chúrga" }],
|
||||||
|
[{ p: "چرګو", f: "chúrgo" }],
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// with #3 pattern anim unisex
|
// with #3 pattern anim unisex
|
||||||
|
@ -603,6 +609,12 @@ const nouns: Array<{
|
||||||
[{ p: "غرونو", f: "ghróono" }],
|
[{ p: "غرونو", f: "ghróono" }],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
bundledPlural: {
|
||||||
|
masc: [
|
||||||
|
[{ p: "غره", f: "ghára" }],
|
||||||
|
[{ p: "غرو", f: "gháro" }],
|
||||||
|
],
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// should NOT do the oona plural with the squish nouns, when they're animate
|
// should NOT do the oona plural with the squish nouns, when they're animate
|
||||||
|
@ -726,6 +738,12 @@ const nouns: Array<{
|
||||||
[{ p: "کتابونو", f: "kitaabóono" }],
|
[{ p: "کتابونو", f: "kitaabóono" }],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
bundledPlural: {
|
||||||
|
masc: [
|
||||||
|
[{ p: "کتابه", f: "kitaaba" }],
|
||||||
|
[{ p: "کتابو", f: "kitaabo" }],
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -737,6 +755,12 @@ const nouns: Array<{
|
||||||
[{ p: "غاښونو", f: "ghaaxóono" }],
|
[{ p: "غاښونو", f: "ghaaxóono" }],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
bundledPlural: {
|
||||||
|
masc: [
|
||||||
|
[{ p: "غاښه", f: "gháaxa" }],
|
||||||
|
[{ p: "غاښو", f: "gháaxo" }],
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -770,6 +794,12 @@ const nouns: Array<{
|
||||||
[{ p: "لوونو", f: "lawóono" }],
|
[{ p: "لوونو", f: "lawóono" }],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
bundledPlural: {
|
||||||
|
masc: [
|
||||||
|
[{ p: "لوه", f: "láwa" }],
|
||||||
|
[{ p: "لوو", f: "láwo" }],
|
||||||
|
],
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// ## FEMININE
|
// ## FEMININE
|
||||||
|
@ -908,6 +938,12 @@ const nouns: Array<{
|
||||||
[{ p: "تبلیغونو", f: "tableeghóono" }],
|
[{ p: "تبلیغونو", f: "tableeghóono" }],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
bundledPlural: {
|
||||||
|
masc: [
|
||||||
|
[{ p: "تبلیغه", f: "tableegha" }],
|
||||||
|
[{ p: "تبلیغو", f: "tableegho" }],
|
||||||
|
],
|
||||||
|
},
|
||||||
arabicPlural: {
|
arabicPlural: {
|
||||||
masc: [
|
masc: [
|
||||||
[{ p: "تبلیغات", f: "tableegháat" }],
|
[{ p: "تبلیغات", f: "tableegháat" }],
|
||||||
|
@ -972,6 +1008,12 @@ const nouns: Array<{
|
||||||
[{ p: "حالونو", f: "haalóono" }],
|
[{ p: "حالونو", f: "haalóono" }],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
bundledPlural: {
|
||||||
|
masc: [
|
||||||
|
[{ p: "حاله", f: "háala" }],
|
||||||
|
[{ p: "حالو", f: "háalo" }],
|
||||||
|
],
|
||||||
|
},
|
||||||
arabicPlural: {
|
arabicPlural: {
|
||||||
masc: [
|
masc: [
|
||||||
[{ p: "احوال", f: "ahwáal" }],
|
[{ p: "احوال", f: "ahwáal" }],
|
||||||
|
|
|
@ -23,12 +23,15 @@ import {
|
||||||
import { makePsString, removeFVarients } from "./accent-and-ps-utils";
|
import { makePsString, removeFVarients } from "./accent-and-ps-utils";
|
||||||
import {
|
import {
|
||||||
accentFSylsOnNFromEnd,
|
accentFSylsOnNFromEnd,
|
||||||
|
accentOnNFromEnd,
|
||||||
|
countSyllables,
|
||||||
hasAccents,
|
hasAccents,
|
||||||
removeAccents,
|
removeAccents,
|
||||||
splitUpSyllables,
|
splitUpSyllables,
|
||||||
} from "./accent-helpers";
|
} from "./accent-helpers";
|
||||||
import * as T from "../../types";
|
import * as T from "../../types";
|
||||||
import { splitFIntoPhonemes } from "./phonetics-to-diacritics";
|
import { splitFIntoPhonemes } from "./phonetics-to-diacritics";
|
||||||
|
import { isNounEntry } from "./type-predicates";
|
||||||
|
|
||||||
const endingInSingleARegex = /[^a]'?’?[aá]'?’?$/;
|
const endingInSingleARegex = /[^a]'?’?[aá]'?’?$/;
|
||||||
const endingInHeyOrAynRegex = /[^ا][هع]$/;
|
const endingInHeyOrAynRegex = /[^ا][هع]$/;
|
||||||
|
@ -420,6 +423,22 @@ function makePashtoPlural(word: T.DictionaryEntryNoFVars): T.PluralInflections |
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeBundledPlural(word: T.DictionaryEntryNoFVars): T.PluralInflections | undefined {
|
||||||
|
if (!endsInConsonant(word) || !word.c?.includes("n.")) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const w = makePsString(word.p, word.f);
|
||||||
|
const base = countSyllables(w) === 1
|
||||||
|
? accentOnNFromEnd(w, 0)
|
||||||
|
: w;
|
||||||
|
return {
|
||||||
|
masc: [
|
||||||
|
[concatPsString(base, { p: "ه", f: "a" })],
|
||||||
|
[concatPsString(base, { p: "و", f: "o" })],
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function makeArabicPlural(word: T.DictionaryEntryNoFVars): T.PluralInflections | undefined {
|
function makeArabicPlural(word: T.DictionaryEntryNoFVars): T.PluralInflections | undefined {
|
||||||
if (!(word.apf && word.app)) return undefined;
|
if (!(word.apf && word.app)) return undefined;
|
||||||
const w = makePsString(word.app, word.apf);
|
const w = makePsString(word.app, word.apf);
|
||||||
|
@ -438,7 +457,7 @@ function makeArabicPlural(word: T.DictionaryEntryNoFVars): T.PluralInflections |
|
||||||
return { masc: value };
|
return { masc: value };
|
||||||
}
|
}
|
||||||
|
|
||||||
function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections } | { arabicPlural: T.PluralInflections } | undefined {
|
function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections, bundledPlural?: T.PluralInflections } | { arabicPlural: T.PluralInflections, bundledPlural?: T.PluralInflections } | undefined {
|
||||||
function addSecondInf(plur: T.ArrayOneOrMore<T.PsString> | T.PsString): T.PluralInflectionSet {
|
function addSecondInf(plur: T.ArrayOneOrMore<T.PsString> | T.PsString): T.PluralInflectionSet {
|
||||||
if (!Array.isArray(plur)) {
|
if (!Array.isArray(plur)) {
|
||||||
return addSecondInf([plur]);
|
return addSecondInf([plur]);
|
||||||
|
@ -457,6 +476,7 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections
|
||||||
}
|
}
|
||||||
const arabicPlural = makeArabicPlural(w);
|
const arabicPlural = makeArabicPlural(w);
|
||||||
const pashtoPlural = makePashtoPlural(w);
|
const pashtoPlural = makePashtoPlural(w);
|
||||||
|
const bundledPlural = makeBundledPlural(w);
|
||||||
function addMascPluralSuffix(animate?: boolean, shortSquish?: boolean): T.PluralInflectionSet {
|
function addMascPluralSuffix(animate?: boolean, shortSquish?: boolean): T.PluralInflectionSet {
|
||||||
if (shortSquish && (w.infap === undefined || w.infaf === undefined)) {
|
if (shortSquish && (w.infap === undefined || w.infaf === undefined)) {
|
||||||
throw new Error(`no irregular inflection info for ${w.p} - ${w.ts}`);
|
throw new Error(`no irregular inflection info for ${w.p} - ${w.ts}`);
|
||||||
|
@ -559,7 +579,7 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections
|
||||||
if (type === "unisex noun") {
|
if (type === "unisex noun") {
|
||||||
// doesn't need to be labelled anim - because it's only with animate nouns that you get the unisex - I THINK
|
// doesn't need to be labelled anim - because it's only with animate nouns that you get the unisex - I THINK
|
||||||
if (endsInConsonant(w) && (!w.infap)) {
|
if (endsInConsonant(w) && (!w.infap)) {
|
||||||
return { arabicPlural, plural: addAnimUnisexPluralSuffix() };
|
return { arabicPlural, bundledPlural, plural: addAnimUnisexPluralSuffix() };
|
||||||
}
|
}
|
||||||
if (shortSquish && !anim) {
|
if (shortSquish && !anim) {
|
||||||
return { arabicPlural, plural: { masc: addMascPluralSuffix(anim, shortSquish) }};
|
return { arabicPlural, plural: { masc: addMascPluralSuffix(anim, shortSquish) }};
|
||||||
|
@ -577,6 +597,7 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
arabicPlural,
|
arabicPlural,
|
||||||
|
bundledPlural,
|
||||||
plural: {
|
plural: {
|
||||||
masc: addMascPluralSuffix(anim, shortSquish),
|
masc: addMascPluralSuffix(anim, shortSquish),
|
||||||
},
|
},
|
||||||
|
@ -620,7 +641,7 @@ function makePlural(w: T.DictionaryEntryNoFVars): { plural: T.PluralInflections
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (arabicPlural) {
|
if (arabicPlural) {
|
||||||
return { arabicPlural, plural: pashtoPlural };
|
return { arabicPlural, plural: pashtoPlural, bundledPlural };
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -378,10 +378,12 @@ export type PluralInflections = GenderedSet<PluralInflectionSet>;
|
||||||
export type InflectorOutput = {
|
export type InflectorOutput = {
|
||||||
arabicPlural: PluralInflections,
|
arabicPlural: PluralInflections,
|
||||||
plural?: PluralInflections,
|
plural?: PluralInflections,
|
||||||
|
bundledPlural?: PluralInflections,
|
||||||
inflections?: Inflections,
|
inflections?: Inflections,
|
||||||
} | {
|
} | {
|
||||||
plural: PluralInflections,
|
plural: PluralInflections,
|
||||||
arabicPlural?: PluralInflections,
|
arabicPlural?: PluralInflections,
|
||||||
|
bundledPlural?: PluralInflections,
|
||||||
inflections?: Inflections,
|
inflections?: Inflections,
|
||||||
} | {
|
} | {
|
||||||
inflections: Inflections,
|
inflections: Inflections,
|
||||||
|
@ -436,7 +438,7 @@ export type Wrapper<T> = T & { __brand: "wrapped" };
|
||||||
|
|
||||||
export type ArrayOneOrMore<T> = {
|
export type ArrayOneOrMore<T> = {
|
||||||
0: T
|
0: T
|
||||||
} & Array<T>
|
} & T[];
|
||||||
|
|
||||||
export type RootsOrStemsToHighlight = ("imperfective root" | "perfective root" | "imperfective stem" | "perfective stem" | "past participle")[];
|
export type RootsOrStemsToHighlight = ("imperfective root" | "perfective root" | "imperfective stem" | "perfective stem" | "past participle")[];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue