Compare commits

..

No commits in common. "eca395bd5d032b4fe7eaec72bc8cbb136581d56e" and "c9f369de09ba5e87c45fb6d8eafee3c7581717df" have entirely different histories.

12 changed files with 109 additions and 147 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "pashto-inflector", "name": "pashto-inflector",
"version": "7.0.8", "version": "7.0.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "pashto-inflector", "name": "pashto-inflector",
"version": "7.0.8", "version": "7.0.3",
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "pashto-inflector", "name": "pashto-inflector",
"version": "7.0.8", "version": "7.0.3",
"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",

View File

@ -1,12 +1,12 @@
{ {
"name": "@lingdocs/ps-react", "name": "@lingdocs/ps-react",
"version": "7.0.8", "version": "7.0.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lingdocs/ps-react", "name": "@lingdocs/ps-react",
"version": "7.0.8", "version": "7.0.3",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@formkit/auto-animate": "^1.0.0-beta.3", "@formkit/auto-animate": "^1.0.0-beta.3",

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/ps-react", "name": "@lingdocs/ps-react",
"version": "7.0.8", "version": "7.0.3",
"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",

View File

@ -12,66 +12,48 @@ import * as T from "../../types";
type PsStringWSub = T.PsString & { sub?: any }; type PsStringWSub = T.PsString & { sub?: any };
function EnglishContent({ function EnglishContent({ children }: { children: (string | JSX.Element)[] | (string | JSX.Element) }) {
children,
}: {
children: (string | JSX.Element)[] | (string | JSX.Element);
}) {
if (Array.isArray(children)) { if (Array.isArray(children)) {
return ( return <>
<> {children.map((x) => <EnglishContent>{x}</EnglishContent>)}
{children.map((x) => (
<EnglishContent>{x}</EnglishContent>
))}
</> </>
);
} }
return ( return <div className="text-muted">
<div className="text-muted" lang="en">
{children} {children}
</div> </div>;
);
} }
function Examples( function Examples(props: ({
props: ( ex: T.PsJSX | T.PsJSX[] | PsStringWSub | PsStringWSub[],
| { } | {
ex: T.PsJSX | T.PsJSX[] | PsStringWSub | PsStringWSub[]; children: T.PsJSX | T.PsJSX[] | PsStringWSub | PsStringWSub[],
} }) & {
| { opts: T.TextOptions,
children: T.PsJSX | T.PsJSX[] | PsStringWSub | PsStringWSub[]; lineHeight?: 0 | 1 | 2 | 3 | 4,
} }) {
) & {
opts: T.TextOptions;
lineHeight?: 0 | 1 | 2 | 3 | 4;
}
) {
const examples = "children" in props ? props.children : props.ex; const examples = "children" in props ? props.children : props.ex;
const Example = ({ children: text }: { children: PsStringWSub }) => ( const Example = ({ children: text }: { children: PsStringWSub }) => (
<div <div className={props.lineHeight !== undefined ? `mb-${props.lineHeight}` : `mt-1 mb-3`}>
className={
props.lineHeight !== undefined ? `mb-${props.lineHeight}` : `mt-1 mb-3`
}
>
<div> <div>
<Pashto opts={props.opts}>{text}</Pashto> <Pashto opts={props.opts}>{text}</Pashto>
</div> </div>
<div> <div>
<Phonetics opts={props.opts}>{text}</Phonetics> <Phonetics opts={props.opts}>{text}</Phonetics>
</div> </div>
{text.e && <EnglishContent>{text.e}</EnglishContent>} {text.e && <EnglishContent>
{text.sub && <div className="small text-muted">{text.sub}</div>} {text.e}
</EnglishContent>}
{text.sub && <div className="small text-muted">
{text.sub}
</div>}
</div> </div>
); );
return Array.isArray(examples) ? ( return Array.isArray(examples) ?
<div> <div>
{examples.map((example, i) => ( {examples.map((example, i) => <Example key={i}>{example as PsStringWSub}</Example>)}
<Example key={i}>{example as PsStringWSub}</Example>
))}
</div> </div>
) : ( :
<Example>{examples as PsStringWSub}</Example> <Example>{examples as PsStringWSub}</Example>;
);
} }
export default Examples; export default Examples;

View File

@ -6,35 +6,40 @@
* *
*/ */
import { convertSpelling } from "../../lib/src/convert-spelling"; import {
import { phoneticsToDiacritics } from "../../lib/src/phonetics-to-diacritics"; convertSpelling,
} from "../../lib/src/convert-spelling";
import {
phoneticsToDiacritics
} from "../../lib/src/phonetics-to-diacritics";
import { psJSXMap } from "./jsx-map"; import { psJSXMap } from "./jsx-map";
import * as T from "../../types"; import * as T from "../../types";
const Pashto = ({ const Pashto = ({ opts, children: text }: {
opts, opts: T.TextOptions,
children: text, children: T.PsString | T.PsJSX,
}: {
opts: T.TextOptions;
children: T.PsString | T.PsJSX;
}) => { }) => {
function convertText(ps: T.PsString, opts: T.TextOptions): string { function convertText(ps: T.PsString, opts: T.TextOptions): string {
const p = opts.diacritics const p = opts.diacritics
? phoneticsToDiacritics(ps.p, ps.f) || ps.p ? (phoneticsToDiacritics(ps.p, ps.f) || ps.p)
: ps.p; : ps.p;
return convertSpelling(p, opts.spelling); return convertSpelling(p, opts.spelling);
} }
const style = const style = opts.pTextSize === "normal"
opts.pTextSize === "normal"
? undefined ? undefined
: { fontSize: opts.pTextSize === "larger" ? "large" : "larger" }; : { fontSize: opts.pTextSize === "larger" ? "large" : "larger" };
return ( return (
<span className="p-text" dir="rtl" style={style} lang="ps"> <span className="p-text" dir="rtl" style={style}>
{typeof text.p !== "string" && typeof text.f !== "string" {(typeof text.p !== "string" && typeof text.f !== "string")
? psJSXMap(text as T.PsJSX, "p", (ps: T.PsString) => ?
convertText(ps, opts) psJSXMap(
text as T.PsJSX,
"p",
(ps: T.PsString) => convertText(ps, opts),
) )
: convertText(text as T.PsString, opts)} :
convertText(text as T.PsString, opts)
}
</span> </span>
); );
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/inflect", "name": "@lingdocs/inflect",
"version": "7.0.8", "version": "7.0.3",
"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",

View File

@ -57,17 +57,12 @@ export const dynamicAuxVerbs: Array<{
{ {
entry: { entry: {
ts: 1527813914, ts: 1527813914,
i: 15179,
p: "ورکول", p: "ورکول",
f: "wărkawul", f: "wărkawul",
g: "warkawul", g: "",
e: "to give (to him/her/it - towards third person)", e: "to give (to him, her, them, others)",
r: 4,
c: "v. trans.", c: "v. trans.",
pprtp: "ورکړی", i: 12350,
pprtf: "wărkúRay",
ec: "give,gives,giving,gave,given",
a: 1,
}, },
}, },
{ {
@ -547,17 +542,4 @@ export const dynamicAuxVerbs: Array<{
noOo: true, noOo: true,
}, },
}, },
{
entry: {
ts: 1527812458,
i: 567,
p: "استول",
f: "astawul",
g: "astawul",
e: "to send",
r: 4,
c: "v. trans.",
ec: "send,sends,sending,sent,sent",
},
},
]; ];

View File

@ -310,9 +310,6 @@ export function parseEc(ec: string): T.EnglishVerbConjugationEc {
if (s === "be") { if (s === "be") {
return ["am", "is", "being", "was", "been"]; return ["am", "is", "being", "was", "been"];
} }
if (s === "give") {
return ["give", "gives", "giving", "gave", "gave"];
}
if (s.slice(-1) === "y" && !isVowel(s.slice(-2)[0])) { if (s.slice(-1) === "y" && !isVowel(s.slice(-2)[0])) {
const b = s.slice(0, -1); const b = s.slice(0, -1);
return [`${s}`, `${b}ies`, `${s}ing`, `${b}ied`, `${b}ied`]; return [`${s}`, `${b}ies`, `${s}ing`, `${b}ied`, `${b}ied`];

View File

@ -768,10 +768,7 @@ describe("perfective stems", () => {
type: "NComp", type: "NComp",
comp: { comp: {
type: "AdjComp", type: "AdjComp",
ps: { ps: { p: "خفه", f: "khufa" },
p: "خفه",
f: "khufá",
},
gender: "fem", gender: "fem",
number: "plural", number: "plural",
}, },

View File

@ -1142,9 +1142,7 @@ function getDynamicAuxVerb(entry: T.DictionaryEntryNoFVars): {
const auxWordResult = dynamicAuxVerbs.find((a) => a.entry.p === auxWord); const auxWordResult = dynamicAuxVerbs.find((a) => a.entry.p === auxWord);
/* istanbul ignore next */ /* istanbul ignore next */
if (!auxWordResult) { if (!auxWordResult) {
throw new Error( throw new Error("unknown auxilary verb for dynamic compound");
`${entry.p} - ${entry.ts} unknown auxilary verb ${auxWord} for dynamic compound`
);
} }
return { return {
entry: removeFVarients(auxWordResult.entry), entry: removeFVarients(auxWordResult.entry),

View File

@ -5,6 +5,7 @@ module.exports = [
{ ts: 1527816692, e: `glasses, spectacles` }, // اینکې - aynake { ts: 1527816692, e: `glasses, spectacles` }, // اینکې - aynake
{ ts: 1527819286, e: `stairs, steps, staircase` }, // پاشتقې - paashtáqe { ts: 1527819286, e: `stairs, steps, staircase` }, // پاشتقې - paashtáqe
{ ts: 1527816299, e: `money (plural of پېسې)` }, // پیسې - peyse { ts: 1527816299, e: `money (plural of پېسې)` }, // پیسې - peyse
{ ts: 1527814529, e: `buttermilk` }, // تروې - turwe
{ ts: 1527816369, e: `widow, woman` }, // تورسرې - torsăre { ts: 1527816369, e: `widow, woman` }, // تورسرې - torsăre
{ ts: 1577408787088, e: `sprey (as in a medicinal spray)` }, // سپرې - spre { ts: 1577408787088, e: `sprey (as in a medicinal spray)` }, // سپرې - spre
{ ts: 1527822255, e: `break of dawn, first light of day, sunrise` }, // سپېدې - spedé { ts: 1527822255, e: `break of dawn, first light of day, sunrise` }, // سپېدې - spedé