;
+}
+
+export function SubjectSelector({ state, dispatch }: {
+ state: ExplorerState,
+ dispatch: (action: ExplorerReducerAction) => void,
+}) {
+ function onTypeSelect(e: React.ChangeEvent
) {
+ const t = e.target.value as SubjectType;
+ dispatch({ type: "setSubjectType", payload: t });
+ }
+ function onSubjectSelect(e: React.ChangeEvent) {
+ const ts = parseInt(e.target.value);
+ dispatch({ type: "setSubject", payload: ts });
+ }
+ const pluralNounSelected = (
+ state.subjectType === "noun" && isPluralEntry(state.subjectsSelected.noun)
+ )
+ return
+
+
+
+
+
+
+
+
+
+ {state.subjectType !== "pronouns" &&
+ <>
+
+
dispatch({ type: "setSubjectPlural", payload: p === "plural" ? true : false })}
+ />
+ >
+ }
+ ;
}
\ No newline at end of file
diff --git a/src/components/equative-explorer/explorer-types.ts b/src/components/equative-explorer/explorer-types.ts
index 58188e5..31fd7a9 100644
--- a/src/components/equative-explorer/explorer-types.ts
+++ b/src/components/equative-explorer/explorer-types.ts
@@ -1,6 +1,11 @@
+import { Types as T } from "@lingdocs/pashto-inflector";
+
export type PredicateType = keyof PredicatesSelected;
+export type SubjectType = "noun" | "pronouns";
export type ExplorerState = {
+ subjectType: SubjectType,
+ subjectsSelected: SubjectSelected,
predicateType: PredicateType,
predicatesSelected: PredicatesSelected,
};
@@ -8,9 +13,22 @@ type PredicatesSelected = {
adjective: Adjective,
unisexNoun: UnisexNoun,
};
+type SubjectSelected = {
+ noun: Noun,
+ info: {
+ plural: boolean,
+ gender: T.Gender,
+ },
+};
export type ExplorerReducerAction = {
type: "setPredicateType", payload: PredicateType,
} | {
type: "setPredicate", payload: number,
+} | {
+ type: "setSubjectType", payload: SubjectType,
+} | {
+ type: "setSubject", payload: number,
+} | {
+ type: "setSubjectPlural", payload: boolean,
};
\ No newline at end of file
diff --git a/src/lib/equative-machine.test.ts b/src/lib/equative-machine.test.ts
index 14dcfe8..94bd8bf 100644
--- a/src/lib/equative-machine.test.ts
+++ b/src/lib/equative-machine.test.ts
@@ -26,6 +26,7 @@ import {
// Person | Participle ✔
// Noun | Noun ✔
// Noun | Adjective ✔
+// Plural Noun | Adjective ✔
// Noun | Participle ✔
// Noun | Specified Unisex Noun ✔
// Specified Unisex Noun | Noun ✔
@@ -146,7 +147,7 @@ const abilities: {
{
in: {
subject: {
- entry: { "ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m." },
+ entry: { "ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m." } as SingularEntry,
plural: false,
},
predicate: {"ts":1527815451,"i":7193,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"} as Adjective,
@@ -160,7 +161,7 @@ const abilities: {
{
in: {
subject: {
- entry: { "ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m." },
+ entry: { "ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m." } as SingularEntry,
plural: true,
},
predicate: {"ts":1527815451,"i":7193,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"} as Adjective,
@@ -174,7 +175,7 @@ const abilities: {
{
in: {
subject: {
- entry: {"ts":1527812797,"i":8542,"p":"ښځه","f":"xúdza","g":"xudza","e":"woman, wife","c":"n. f. anim.","ec":"woman","ep":"women"},
+ entry: {"ts":1527812797,"i":8542,"p":"ښځه","f":"xúdza","g":"xudza","e":"woman, wife","c":"n. f. anim.","ec":"woman","ep":"women"} as SingularEntry,
plural: false,
},
predicate: {"ts":1527815451,"i":7193,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"} as Adjective,
@@ -188,7 +189,7 @@ const abilities: {
{
in: {
subject: {
- entry: {"ts":1527812797,"i":8542,"p":"ښځه","f":"xúdza","g":"xudza","e":"woman, wife","c":"n. f. anim.","ec":"woman","ep":"women"},
+ entry: {"ts":1527812797,"i":8542,"p":"ښځه","f":"xúdza","g":"xudza","e":"woman, wife","c":"n. f. anim.","ec":"woman","ep":"women"} as SingularEntry,
plural: true,
},
predicate: {"ts":1527815451,"i":7193,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"} as Adjective,
@@ -203,7 +204,7 @@ const abilities: {
{
in: {
subject: {
- entry: {"ts":1527812797,"i":8542,"p":"ښځه","f":"xúdza","g":"xudza","e":"woman, wife","c":"n. f. anim.","ec":"woman","ep":"women"},
+ entry: {"ts":1527812797,"i":8542,"p":"ښځه","f":"xúdza","g":"xudza","e":"woman, wife","c":"n. f. anim.","ec":"woman","ep":"women"} as SingularEntry,
plural: true,
},
predicate: {"ts":1527812798,"i":5595,"p":"خفه","f":"khufa","g":"khufa","e":"sad, upset, angry; choked, suffocated","c":"adj."} as Adjective,
@@ -216,6 +217,39 @@ const abilities: {
},
],
},
+ {
+ label: "SUBJECT: Plural Noun Predicate: Adjective",
+ tests: [
+ {
+ in: {
+ subject: {
+ entry: {"ts":1527815008,"i":8433,"p":"شودې","f":"shoodé","g":"shoode","e":"milk","c":"n. f. pl."} as PluralEntry,
+ plural: true,
+ },
+ predicate: {"ts":1527812796,"i":8578,"p":"ښه","f":"xu","g":"xu","e":"good","c":"adj."} as Adjective,
+ },
+ out: {
+ subject: [{ p: "شودې", f: "shoodé", e: "(The) milk" }],
+ predicate: [{ p: "ښې", f: "xe", e: "good" }],
+ equative: [{ p: "دي", f: "dee", e: "is" }],
+ },
+ },
+ {
+ in: {
+ subject: {
+ entry: {"ts":1527817330,"i":9204,"p":"غنم","f":"ghanúm","g":"ghanum","e":"wheat","c":"n. m. pl."} as PluralEntry,
+ plural: true,
+ },
+ predicate: {"ts":1527815451,"i":7192,"p":"زوړ","f":"zoR","g":"zoR","e":"old","c":"adj. irreg.","infap":"زاړه","infaf":"zaaRu","infbp":"زړ","infbf":"zaR"} as Adjective,
+ },
+ out: {
+ subject: [{ p: "غنم", f: "ghanúm", e: "(The) wheat" }],
+ predicate: [{ p: "زاړه", f: "zaaRu", e: "old" }],
+ equative: [{ p: "دي", f: "dee", e: "is" }],
+ },
+ },
+ ],
+ },
{
label: "SUBJECT: Participle PREDICATE: Adjective",
tests: [
@@ -276,11 +310,11 @@ const abilities: {
{
in: {
subject: {
- entry: {"ts":1527813477,"i":5790,"p":"خوشحالي","f":"khosh`haalee","g":"khoshhaalee","e":"happiness, joy","c":"n. f."},
+ entry: {"ts":1527813477,"i":5790,"p":"خوشحالي","f":"khosh`haalee","g":"khoshhaalee","e":"happiness, joy","c":"n. f."} as SingularEntry,
plural: false,
},
predicate: {
- entry: {"ts":1527812788,"i":5729,"p":"خوراک","f":"khoráak, khwaráak","g":"khoraak,khwaraak","e":"food","c":"n. m."},
+ entry: {"ts":1527812788,"i":5729,"p":"خوراک","f":"khoráak, khwaráak","g":"khoraak,khwaraak","e":"food","c":"n. m."} as SingularEntry,
plural: false,
},
},
@@ -298,7 +332,7 @@ const abilities: {
{
in: {
subject: {
- entry: {"ts":1527822878,"i":14157,"p":"وروروالی","f":"wrorwaaley","g":"wrorwaaley","e":"brotherhood, comradery, tight and good friendship","c":"n. m."},
+ entry: {"ts":1527822878,"i":14157,"p":"وروروالی","f":"wrorwaaley","g":"wrorwaaley","e":"brotherhood, comradery, tight and good friendship","c":"n. m."} as SingularEntry,
plural: false,
},
predicate: {"ts":1527816064,"i":7097,"p":"زغمل","f":"zghamul","g":"zghamul","e":"to endure, bear, tolerate, take on, digest","c":"v. trans.","tppp":"زغامه","tppf":"zghaamu","ec":"endure"} as ParticipleInput,
@@ -318,7 +352,7 @@ const abilities: {
in: {
subject: {"ts":1527812856,"i":11521,"p":"لیکل","f":"leekul","g":"leekul","e":"to write","c":"v. trans.","ec":"write,writes,writing,wrote,wrote"} as ParticipleInput,
predicate: {
- entry: {"ts":1527813477,"i":5790,"p":"خوشحالي","f":"khosh`haalee","g":"khoshhaalee","e":"happiness, joy","c":"n. f."},
+ entry: {"ts":1527813477,"i":5790,"p":"خوشحالي","f":"khosh`haalee","g":"khoshhaalee","e":"happiness, joy","c":"n. f."} as SingularEntry,
plural: false,
},
},
@@ -352,11 +386,11 @@ const abilities: {
{
in: {
subject: {
- entry: {"ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m."},
+ entry: {"ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m."} as SingularEntry,
plural: true,
},
predicate: {
- entry: {"ts":1527815127,"i":13259,"p":"نرس","f":"nars, nursa","g":"nars,nursa","e":"nurse","c":"n. m. anim. unisex"},
+ entry: {"ts":1527815127,"i":13259,"p":"نرس","f":"nars, nursa","g":"nars,nursa","e":"nurse","c":"n. m. anim. unisex"} as SingularEntry,
plural: false,
gender: "fem",
},
@@ -375,7 +409,7 @@ const abilities: {
{
in: {
subject: {
- entry: {"ts":1527815127,"i":13259,"p":"نرس","f":"nars, nursa","g":"nars,nursa","e":"nurse","c":"n. m. anim. unisex"},
+ entry: {"ts":1527815127,"i":13259,"p":"نرس","f":"nars, nursa","g":"nars,nursa","e":"nurse","c":"n. m. anim. unisex"} as SingularEntry,
plural: true,
gender: "fem",
},
@@ -398,12 +432,12 @@ const abilities: {
{
in: {
subject: {
- entry: {"ts":1527815127,"i":13259,"p":"نرس","f":"nars, nursa","g":"nars,nursa","e":"nurse","c":"n. m. anim. unisex"},
+ entry: {"ts":1527815127,"i":13259,"p":"نرس","f":"nars, nursa","g":"nars,nursa","e":"nurse","c":"n. m. anim. unisex"} as SingularEntry,
plural: false,
gender: "fem",
},
predicate: {
- entry: {"ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m."},
+ entry: {"ts":1527812817,"i":9921,"p":"کتاب","f":"kitáab","g":"kitaab","e":"book","c":"n. m."} as SingularEntry,
plural: true,
},
},
@@ -421,7 +455,7 @@ const abilities: {
{
in: {
subject: {
- entry: {"ts":1527815127,"i":13259,"p":"نرس","f":"nars, nursa","g":"nars,nursa","e":"nurse","c":"n. m. anim. unisex"},
+ entry: {"ts":1527815127,"i":13259,"p":"نرس","f":"nars, nursa","g":"nars,nursa","e":"nurse","c":"n. m. anim. unisex"} as SingularEntry,
plural: false,
gender: "fem",
},
@@ -442,7 +476,7 @@ const abilities: {
in: {
subject: {"ts":1527812856,"i":11521,"p":"لیکل","f":"leekul","g":"leekul","e":"to write","c":"v. trans.","ec":"write,writes,writing,wrote,wrote"} as ParticipleInput,
predicate: {
- entry: {"ts":1527815127,"i":13259,"p":"نرس","f":"nars, nursa","g":"nars,nursa","e":"nurse","c":"n. m. anim. unisex"},
+ entry: {"ts":1527815127,"i":13259,"p":"نرس","f":"nars, nursa","g":"nars,nursa","e":"nurse","c":"n. m. anim. unisex"} as SingularEntry,
plural: false,
gender: "fem",
},
diff --git a/src/lib/equative-machine.ts b/src/lib/equative-machine.ts
index bd45fdd..8c552c2 100644
--- a/src/lib/equative-machine.ts
+++ b/src/lib/equative-machine.ts
@@ -14,7 +14,7 @@ import {
concatPsString,
} from "@lingdocs/pashto-inflector";
import {
- isArrayOneOrMore,
+ isArrayOneOrMore, isPluralEntry,
} from "./type-predicates";
export type EquativeMachineOutput = {
@@ -24,8 +24,11 @@ export type EquativeMachineOutput = {
};
export type NounInput = {
- entry: T.DictionaryEntry,
+ entry: SingularEntry,
plural: boolean,
+} | {
+ entry: PluralEntry,
+ plural: true,
};
export type ParticipleInput = T.DictionaryEntry & { __brand: "a participle" };
@@ -44,7 +47,7 @@ export function equativeMachine(sub: SubjectInput, pred: PredicateInput): Equati
const predPerson = getInputPerson(pred, "predicate") || subjPerson;
const subject = makeEntity(sub);
const predicate = makeEntity(pred, subjPerson);
- const equative = makeEquative(subjPerson, predPerson, isParticipleInput(sub));
+ const equative = makeEquative(subjPerson, predPerson, sub);
return {
subject,
predicate,
@@ -52,11 +55,11 @@ export function equativeMachine(sub: SubjectInput, pred: PredicateInput): Equati
};
}
-export function assembleEquativeOutput(o: EquativeMachineOutput): T.SingleOrLengthOpts {
+export function assembleEquativeOutput(o: EquativeMachineOutput): T.SingleOrLengthOpts> {
if ("long" in o.equative) {
return {
- long: assembleEquativeOutput({ ...o, equative: o.equative.long }) as T.PsString[],
- short: assembleEquativeOutput({ ...o, equative: o.equative.short }) as T.PsString[],
+ long: assembleEquativeOutput({ ...o, equative: o.equative.long }) as T.ArrayOneOrMore,
+ short: assembleEquativeOutput({ ...o, equative: o.equative.short }) as T.ArrayOneOrMore,
}
}
// get all possible combinations of subject, predicate, and equative
@@ -71,7 +74,7 @@ export function assembleEquativeOutput(o: EquativeMachineOutput): T.SingleOrLeng
))
));
const e = `${o.subject[0].e} ${o.equative[0].e} ${o.predicate[0].e}`;
- return ps.map(x => ({ ...x, e }));
+ return ps.map(x => ({ ...x, e })) as T.ArrayOneOrMore;
}
// LEVEL 2 FUNCTIONS
@@ -117,12 +120,16 @@ function makeEntity(e: EntityInput, subjPerson?: T.Person): T.PsString[] {
throw new Error(`invalid entity in ${subjPerson ? "predicate" : "subject"}`);
}
-function makeEquative(subj: T.Person, pred: T.Person, subjIsParticipleInput: boolean): T.SentenceForm {
+function makeEquative(subj: T.Person, pred: T.Person, subjectInput: SubjectInput): T.SentenceForm {
+ const isPluralNoun = isNounInput(subjectInput) && isPluralEntry(subjectInput.entry);
// The subject's person information, for the English equative
- const [sRow, sCol] = getVerbBlockPosFromPerson(subjIsParticipleInput ? T.Person.ThirdSingMale : subj);
+ const [eeRow, eeCol] = getVerbBlockPosFromPerson(
+ (isParticipleInput(subjectInput) || isPluralNoun)
+ ? T.Person.ThirdSingMale
+ : subj
+ );
return addEnglish(
- // english agrees with subject
- grammarUnits.englishEquative.present[sRow][sCol],
+ grammarUnits.englishEquative.present[eeRow][eeCol],
// pashto agrees with predicate (if possible)
getPersonFromVerbForm(grammarUnits.equativeEndings.present, pred),
);
diff --git a/src/lib/type-predicates.ts b/src/lib/type-predicates.ts
index c1a7d8b..9e56254 100644
--- a/src/lib/type-predicates.ts
+++ b/src/lib/type-predicates.ts
@@ -134,6 +134,14 @@ export function isPattern6FemNoun(e: FemNoun): e is Pattern6FemNoun {
return e.p.slice(-1) === "ي";
}
+export function isPluralEntry(e: U): e is PluralEntry {
+ return e.c.includes("pl.");
+}
+
+export function isSingularEntry(e: U): e is SingularEntry {
+ return !isPluralEntry(e);
+}
+
export function isArrayOneOrMore(a: U[]): a is T.ArrayOneOrMore {
return a.length > 0;
}
diff --git a/src/types.d.ts b/src/types.d.ts
index 9dffdba..f5fbd8f 100644
--- a/src/types.d.ts
+++ b/src/types.d.ts
@@ -32,6 +32,9 @@ type Verb = {
complement?: import("@lingdocs/pashto-inflector").Types.DictionaryEntry,
};
+type SingularEntry = T & { __brand7: "a singular noun - as opposed to an always plural noun" };
+type PluralEntry = T & { __brand7: "a noun that is always plural" };
+
type RawWord = T.DictionaryEntry | {
entry: T.DictionaryEntry,
complement?: T.DictionaryEntry,