finishing parsing noun words
This commit is contained in:
parent
32f7618fff
commit
1abc83ee01
|
@ -67,7 +67,7 @@ function parsePattern1(
|
|||
dictionary
|
||||
.queryP(p)
|
||||
.filter(andSuccTp(tp.isFemNounEntry, tp.isPattern1Entry));
|
||||
const plain = first.s.endsWith("ه")
|
||||
const plain = ["ه", "ع"].some((v) => first.s.endsWith(v))
|
||||
? p1Lookup(first.s).map<FemNounBaseParse>((entry) => ({
|
||||
inflection: [0],
|
||||
gender: ["fem"],
|
||||
|
@ -84,12 +84,21 @@ function parsePattern1(
|
|||
}))
|
||||
: [];
|
||||
const inflected = first.s.endsWith("ې")
|
||||
? p1Lookup(first.s.slice(0, -1) + "ه").map<FemNounBaseParse>((entry) => ({
|
||||
inflection: [1],
|
||||
gender: ["fem"],
|
||||
entry,
|
||||
given: first.s,
|
||||
}))
|
||||
? (() => {
|
||||
const base = first.s.slice(0, -1);
|
||||
const lookups = [
|
||||
...p1Lookup(base + "ه"),
|
||||
...(["ح", "ع"].some((v) => first.s.at(-2) === v)
|
||||
? p1Lookup(base)
|
||||
: []),
|
||||
];
|
||||
return lookups.map<FemNounBaseParse>((entry) => ({
|
||||
inflection: [1],
|
||||
gender: ["fem"],
|
||||
entry,
|
||||
given: first.s,
|
||||
}));
|
||||
})()
|
||||
: [];
|
||||
const doubleInflected = first.s.endsWith("و")
|
||||
? p1Lookup(first.s.slice(0, -1) + "ه").map<FemNounBaseParse>((entry) => ({
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import * as T from "../../../types";
|
||||
import { DictionaryAPI } from "../dictionary/dictionary";
|
||||
import { endsInConsonant } from "../p-text-helpers";
|
||||
import * as tp from "../type-predicates";
|
||||
import { returnParseResults } from "./utils";
|
||||
|
||||
|
@ -16,7 +17,10 @@ export function parseIrregularPlural(
|
|||
.filter(tp.isNounEntry)
|
||||
.map<T.ParsedNounWord<T.NounEntry>>((entry) => ({
|
||||
entry,
|
||||
gender: tp.isFemNounEntry(entry) ? "fem" : "masc",
|
||||
gender:
|
||||
tp.isFemNounEntry(entry) && !hasMasculineArabicPlural(entry)
|
||||
? "fem"
|
||||
: "masc",
|
||||
inflected: false,
|
||||
given: first.s,
|
||||
plural: true,
|
||||
|
@ -75,3 +79,8 @@ export function parseIrregularPlural(
|
|||
...inflectedAfterLongSep,
|
||||
];
|
||||
}
|
||||
|
||||
function hasMasculineArabicPlural(e: T.FemNounEntry): boolean {
|
||||
if (!e.app || !e.apf) return false;
|
||||
return endsInConsonant({ p: e.app, f: e.apf });
|
||||
}
|
||||
|
|
|
@ -44,10 +44,12 @@ const zooy = testDictionary.nounLookup("زوی")[0];
|
|||
const loor = testDictionary.nounLookup("لور")[0];
|
||||
const nabee = testDictionary.nounLookup("نبي")[0];
|
||||
const lafz = testDictionary.nounLookup("لفظ")[0];
|
||||
const fatha = testDictionary.nounLookup("فتح")[0];
|
||||
const nafa = testDictionary.nounLookup("نفع")[0];
|
||||
const tajraba = testDictionary.nounLookup("تجربه")[0];
|
||||
|
||||
// TODO: test for adjective errors etc
|
||||
// bundled plural
|
||||
// TODO: منابع
|
||||
|
||||
const tests: {
|
||||
category: string;
|
||||
|
@ -216,6 +218,93 @@ const tests: {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
category: "pattern 1 fem nouns with ح ه etc",
|
||||
cases: [
|
||||
{
|
||||
input: "فتح",
|
||||
output: [
|
||||
{
|
||||
inflected: false,
|
||||
selection: {
|
||||
...makeNounSelection(fatha, undefined),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "فتحې",
|
||||
output: [
|
||||
{
|
||||
inflected: true,
|
||||
selection: {
|
||||
...makeNounSelection(fatha, undefined),
|
||||
},
|
||||
},
|
||||
{
|
||||
inflected: false,
|
||||
selection: {
|
||||
...makeNounSelection(fatha, undefined),
|
||||
number: "plural",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "فتحو",
|
||||
output: [
|
||||
{
|
||||
inflected: true,
|
||||
selection: {
|
||||
...makeNounSelection(fatha, undefined),
|
||||
number: "plural",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "نفع",
|
||||
output: [
|
||||
{
|
||||
inflected: false,
|
||||
selection: {
|
||||
...makeNounSelection(nafa, undefined),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "نفعې",
|
||||
output: [
|
||||
{
|
||||
inflected: true,
|
||||
selection: {
|
||||
...makeNounSelection(nafa, undefined),
|
||||
},
|
||||
},
|
||||
{
|
||||
inflected: false,
|
||||
selection: {
|
||||
...makeNounSelection(nafa, undefined),
|
||||
number: "plural",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "نفعو",
|
||||
output: [
|
||||
{
|
||||
inflected: true,
|
||||
selection: {
|
||||
...makeNounSelection(nafa, undefined),
|
||||
number: "plural",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
category: "group/plural nouns",
|
||||
// to do fem plural تسبیج, هټکرۍ, مایع
|
||||
|
@ -1625,6 +1714,19 @@ const tests: {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
input: "تجارب",
|
||||
output: [
|
||||
{
|
||||
inflected: false,
|
||||
selection: {
|
||||
...makeNounSelection(tajraba, undefined),
|
||||
number: "plural",
|
||||
gender: "masc",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
|
@ -47,4 +47,7 @@ export const entries: T.DictionaryEntry["ts"][] = [
|
|||
1527812582, // دعا
|
||||
1591803598624, // هتکړۍ
|
||||
1527812861, // لور - loor
|
||||
1589023873660, // فتح - fatha
|
||||
1527814342, // نفع - nafa
|
||||
1527815329, // تجربه
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue