From 383902b3b2fcad873468a615a9365acafb805327 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Sat, 17 Sep 2022 18:36:15 +0400 Subject: [PATCH] humanReadableInflectionPattern --- netlify.toml | 2 +- package.json | 22 ++++++++--------- src/lib/inflection-pattern.ts | 27 --------------------- src/lib/inflection-pattern.tsx | 44 ++++++++++++++++++++++++++++++++++ src/library.ts | 6 ++++- 5 files changed, 61 insertions(+), 40 deletions(-) delete mode 100644 src/lib/inflection-pattern.ts create mode 100644 src/lib/inflection-pattern.tsx diff --git a/netlify.toml b/netlify.toml index 10728f9..fa8460e 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,3 +1,3 @@ [build] command = "yarn build-website" - publish = "build" + publish = "build/" diff --git a/package.json b/package.json index 2a574b2..5f1ce04 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,19 @@ { "name": "@lingdocs/pashto-inflector", - "version": "3.9.4", + "version": "3.9.5", "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", + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject", + "build-website": "node get-words.js && npm run build", + "build-library": "node get-words.js && rimraf dist && rimraf dist-cjs && tsc --project library-tsconfig.json && node library-post-build.js && rollup -c", + "test-ci": "npm run test -- --watchAll=false", + "get-words": "node get-words.js" + }, "license": "MIT", "main": "dist-cjs/library.js", "module": "dist/library.js", @@ -63,16 +73,6 @@ "react-bootstrap": "^1.5.1", "react-dom": "^17.0.1" }, - "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject", - "build-website": "node get-words.js && npm run build", - "build-library": "node get-words.js && rimraf dist && rimraf dist-cjs && tsc --project library-tsconfig.json && node library-post-build.js && rollup -c", - "test-ci": "npm run test -- --watchAll=false", - "get-words": "node get-words.js" - }, "eslintConfig": { "extends": [ "react-app", diff --git a/src/lib/inflection-pattern.ts b/src/lib/inflection-pattern.ts deleted file mode 100644 index 5a1fda9..0000000 --- a/src/lib/inflection-pattern.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { AdjectiveEntry, InflectionPattern, NounEntry } from "../types"; -import { - isFemNounEntry, - isNounEntry, - isPattern1Entry, - isPattern2Entry, - isPattern3Entry, - isPattern4Entry, - isPattern5Entry, - isPattern6FemEntry, -} from "./type-predicates"; - -export function getInflectionPattern(e: NounEntry | AdjectiveEntry): InflectionPattern { - return isPattern1Entry(e) - ? InflectionPattern.Basic - : isPattern2Entry(e) - ? InflectionPattern.UnstressedEy - : isPattern3Entry(e) - ? InflectionPattern.StressedEy - : isPattern4Entry(e) - ? InflectionPattern.Pashtun - : isPattern5Entry(e) - ? InflectionPattern.Squish - : isNounEntry(e) && isFemNounEntry(e) && isPattern6FemEntry(e) - ? InflectionPattern.FemInanEe - : InflectionPattern.None; -} \ No newline at end of file diff --git a/src/lib/inflection-pattern.tsx b/src/lib/inflection-pattern.tsx new file mode 100644 index 0000000..beb834b --- /dev/null +++ b/src/lib/inflection-pattern.tsx @@ -0,0 +1,44 @@ +import * as T from "../types"; +import { + isFemNounEntry, + isNounEntry, + isPattern1Entry, + isPattern2Entry, + isPattern3Entry, + isPattern4Entry, + isPattern5Entry, + isPattern6FemEntry, +} from "./type-predicates"; +import InlinePs from "../components/InlinePs"; + +export function getInflectionPattern(e: T.NounEntry | T.AdjectiveEntry): T.InflectionPattern { + return isPattern1Entry(e) + ? T.InflectionPattern.Basic + : isPattern2Entry(e) + ? T.InflectionPattern.UnstressedEy + : isPattern3Entry(e) + ? T.InflectionPattern.StressedEy + : isPattern4Entry(e) + ? T.InflectionPattern.Pashtun + : isPattern5Entry(e) + ? T.InflectionPattern.Squish + : isNounEntry(e) && isFemNounEntry(e) && isPattern6FemEntry(e) + ? T.InflectionPattern.FemInanEe + : T.InflectionPattern.None; +} + +export function humanReadableInflectionPattern(p: T.InflectionPattern, textOptions: T.TextOptions): JSX.Element | null { + return p === 1 + ? #1 Basic + : p === 2 + ? #2 Unstressed {{ p: "ی", f: "ey", e: "" }} + : p === 3 + ? #3 Stressed {{ p: "ی", f: "éy", e: "" }} + : p === 4 + ? #4 "Pashtoon" + : p === 5 + ? #5 Short Squish + : p === 6 + ? #6 Fem. inan. {{ p: "ي", f: "ee", e: "" }} + : null; +} \ No newline at end of file diff --git a/src/library.ts b/src/library.ts index 1a667d9..2ad7005 100644 --- a/src/library.ts +++ b/src/library.ts @@ -39,7 +39,10 @@ import Block, { NPBlock, APBlock } from "./components/blocks/Block"; import { roleIcon } from "./components/vp-explorer/VPExplorerExplanationModal"; import CompiledPTextDisplay from "./components/CompiledPTextDisplay"; import RenderedBlocksDisplay from "./components/RenderedBlocksDisplay"; -import { getInflectionPattern } from "./lib/inflection-pattern"; +import { + getInflectionPattern, + humanReadableInflectionPattern, +} from "./lib/inflection-pattern"; import { makePsString, removeFVarients, @@ -254,6 +257,7 @@ export { getEnglishVerb, humanReadableVerbForm, humanReadableEquativeTense, + humanReadableInflectionPattern, ensureNonComboVerbInfo, roleIcon, vpsReducer,