fixed up determiners for a beta rollout
This commit is contained in:
parent
6451cee925
commit
c5a238ab05
|
@ -30,6 +30,7 @@ jobs:
|
|||
yarn install-r
|
||||
yarn build-library
|
||||
yarn test --silent
|
||||
yarn check-all-inflections
|
||||
cp .npmrc src/lib
|
||||
cp .npmrc src/components
|
||||
cd src/lib
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "pashto-inflector",
|
||||
"version": "7.5.0",
|
||||
"version": "7.5.1",
|
||||
"author": "lingdocs.com",
|
||||
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
|
||||
"homepage": "https://verbs.lingdocs.com",
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@lingdocs/ps-react",
|
||||
"version": "7.5.0",
|
||||
"version": "7.5.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lingdocs/ps-react",
|
||||
"version": "7.5.0",
|
||||
"version": "7.5.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@formkit/auto-animate": "^1.0.0-beta.3",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lingdocs/ps-react",
|
||||
"version": "7.5.0",
|
||||
"version": "7.5.1",
|
||||
"description": "Pashto inflector library module with React components",
|
||||
"main": "dist/components/library.js",
|
||||
"module": "dist/components/library.js",
|
||||
|
|
|
@ -609,15 +609,20 @@ function Determiners({
|
|||
script: "p" | "f";
|
||||
children: T.Rendered<T.DeterminersSelection> | undefined;
|
||||
}) {
|
||||
if (!children) {
|
||||
if (!children || children.determiners.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<div className="text-center">
|
||||
Determiners here!
|
||||
{/* <Border padding={"1rem"}>{children.ps[script]}</Border>
|
||||
<div>DEM</div>
|
||||
<SubText>{children.e}</SubText> */}
|
||||
<div className={`d-flex flex-row${script === "p" ? "-reverse" : ""}`}>
|
||||
{children.determiners.map((d) => (
|
||||
<div className="mx-1">
|
||||
<Border padding={"1rem"}>{d.ps[0][script]}</Border>
|
||||
<div>{"demonstrative" in d.determiner ? "DEM" : "DET"}</div>
|
||||
<SubText>{d.e}</SubText>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -12,10 +12,16 @@ export default function DeterminersPicker({
|
|||
opts: T.TextOptions;
|
||||
negative: boolean;
|
||||
}) {
|
||||
const hasDemonstrative =
|
||||
determiners &&
|
||||
determiners.determiners.some((d) => "demonstrative" in d.determiner);
|
||||
function allowed(d: T.Determiner): boolean {
|
||||
if (d.p === "هیڅ" && !negative) {
|
||||
return false;
|
||||
}
|
||||
if (hasDemonstrative && "demonstrative" in d) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function handleWithNounChange(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
|
@ -93,7 +99,7 @@ export default function DeterminersPicker({
|
|||
checked={determiners?.withNoun}
|
||||
onChange={handleWithNounChange}
|
||||
id="withNoun"
|
||||
disabled={!determiners}
|
||||
disabled={!hasDemonstrative}
|
||||
/>
|
||||
<label className="form-check-label text-muted" htmlFor="withNoun">
|
||||
with noun
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lingdocs/inflect",
|
||||
"version": "7.5.0",
|
||||
"version": "7.5.1",
|
||||
"description": "Pashto inflector library",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/lib/library.d.ts",
|
||||
|
|
|
@ -432,6 +432,7 @@ export function removeHeetsDet<B extends T.VPSBlock[] | T.EPSBlock[]>(
|
|||
})) as B;
|
||||
}
|
||||
|
||||
// TODO: Could use lenses for this
|
||||
function removeHeetsDetFromBlock<
|
||||
B extends T.VPSBlock["block"] | T.EPSBlock["block"]
|
||||
>(block: B): B {
|
||||
|
@ -512,10 +513,7 @@ function removeHeetsFromNoun(n: T.NounSelection): T.NounSelection {
|
|||
adjectives: n.adjectives.map(removeHeetsFromAdjective),
|
||||
...(n.determiners
|
||||
? {
|
||||
determiners: {
|
||||
...n.determiners,
|
||||
determiners: removeHeetsFromDets(n.determiners.determiners),
|
||||
},
|
||||
determiners: removeHeetsFromDets(n.determiners),
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
|
@ -532,10 +530,13 @@ function removeHeetsFromNP(np: T.NPSelection): T.NPSelection {
|
|||
}
|
||||
|
||||
function removeHeetsFromDets(
|
||||
dets: T.DeterminerSelection[]
|
||||
): T.DeterminerSelection[] {
|
||||
dets: T.DeterminersSelection | undefined
|
||||
): T.DeterminersSelection | undefined {
|
||||
if (!dets) {
|
||||
return dets;
|
||||
}
|
||||
return dets.filter((d) => d.determiner.p !== "هیڅ");
|
||||
return {
|
||||
...dets,
|
||||
determiners: dets.determiners.filter((d) => d.determiner.p !== "هیڅ"),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ function getBaseWDetsAndAdjs({
|
|||
const detWOutNoun =
|
||||
"determiners" in selection &&
|
||||
selection.determiners &&
|
||||
!selection.determiners.type;
|
||||
!selection.determiners.withNoun;
|
||||
const adjs = (("adjectives" in selection && selection.adjectives) || []).map(
|
||||
(x) => x.ps
|
||||
);
|
||||
|
@ -208,10 +208,13 @@ function addArticlesAndAdjs(
|
|||
? " (f.)"
|
||||
: " (m.)"
|
||||
: "";
|
||||
const moreThanOneDet = (np.determiners?.determiners.length || 0) > 1;
|
||||
const determiners =
|
||||
np.determiners && np.determiners.determiners
|
||||
? // @ts-ignore - weird, ts is not recognizing this as rendered
|
||||
np.determiners.determiners.map((x) => `(${x.e})`).join(" ")
|
||||
? np.determiners.determiners
|
||||
// @ts-ignore - weird, ts is not recognizing this as rendered
|
||||
.map((x) => (moreThanOneDet ? `(${x.e})` : x.e))
|
||||
.join(" ")
|
||||
: "";
|
||||
const detsWithoutNoun = np.determiners && !np.determiners.withNoun;
|
||||
return `${np.determiners ? "" : articles}${determiners}${
|
||||
|
|
|
@ -225,11 +225,9 @@ function renderDeterminer({
|
|||
? "such/like these"
|
||||
: "such/like this"
|
||||
: determiner.f === "daghase"
|
||||
? number === "plural"
|
||||
? "just such/just like these"
|
||||
: "just such/just like this"
|
||||
? `just such/just like ${number === "plural" ? "these" : "this"}`
|
||||
: determiner.f === "hase"
|
||||
? `such/like ${number === "plural"} ? "those" : "that"`
|
||||
? `such/like ${number === "plural" ? "those" : "that"}`
|
||||
: number === "plural"
|
||||
? "just such/just like these"
|
||||
: "just such/just like this";
|
||||
|
|
10
src/types.ts
10
src/types.ts
|
@ -909,18 +909,18 @@ export type DeterminersSelection = {
|
|||
};
|
||||
|
||||
export const determiners = [
|
||||
{ p: "دا", f: "daa", type: "det" },
|
||||
{ p: "دغه", f: "dágha", type: "det" },
|
||||
{ p: "هغه", f: "hágha", type: "det" },
|
||||
{ p: "دا", f: "daa", type: "det", demonstrative: true },
|
||||
{ p: "دغه", f: "dágha", type: "det", demonstrative: true },
|
||||
{ p: "هغه", f: "hágha", type: "det", demonstrative: true },
|
||||
{ p: "کوم", f: "koom", type: "det" },
|
||||
{ p: "داسې", f: "dáase", type: "det" },
|
||||
{ p: "دغسې", f: "daghase", type: "det" },
|
||||
{ p: "هسې", f: "hase", type: "det" },
|
||||
{ p: "هغسې", f: "hagháse", type: "det" },
|
||||
{ p: "کوم", f: "koom", type: "det" },
|
||||
{ p: "هر", f: "har", type: "det" },
|
||||
{ p: "ټول", f: "Tol", type: "det" },
|
||||
{ p: "هیڅ", f: "heets", type: "det", noInf: true },
|
||||
{ p: "بل", f: "bul", type: "det" },
|
||||
{ p: "هیڅ", f: "heets", type: "det", noInf: true },
|
||||
] as const;
|
||||
|
||||
export type Determiner = (typeof determiners)[number];
|
||||
|
|
Loading…
Reference in New Issue