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