humanReadableInflectionPattern

This commit is contained in:
lingdocs 2022-09-17 18:36:15 +04:00
parent 7efc30bbb7
commit 383902b3b2
5 changed files with 61 additions and 40 deletions

View File

@ -1,3 +1,3 @@
[build]
command = "yarn build-website"
publish = "build"
publish = "build/"

View File

@ -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",

View File

@ -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;
}

View File

@ -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
? <span>#1 Basic</span>
: p === 2
? <span>#2 Unstressed <InlinePs opts={textOptions}>{{ p: "ی", f: "ey", e: "" }}</InlinePs></span>
: p === 3
? <span>#3 Stressed <InlinePs opts={textOptions}>{{ p: "ی", f: "éy", e: "" }}</InlinePs></span>
: p === 4
? <span>#4 "Pashtoon"</span>
: p === 5
? <span>#5 Short Squish</span>
: p === 6
? <span>#6 Fem. inan. <InlinePs opts={textOptions}>{{ p: "ي", f: "ee", e: "" }}</InlinePs></span>
: null;
}

View File

@ -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,