From 4c199b8f8b8a1195bd7e36771f0cb562ee0a0766 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Mon, 29 Aug 2022 17:55:58 +0400 Subject: [PATCH] more humanReadable --- package.json | 2 +- src/lib/human-readable.ts | 26 ++++++++++++++++++-------- src/library.ts | 8 ++++++-- src/types.ts | 4 +++- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 2e490c3..9c6cbbd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "3.8.1", + "version": "3.8.2", "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", diff --git a/src/lib/human-readable.ts b/src/lib/human-readable.ts index dddbd9b..89bdbba 100644 --- a/src/lib/human-readable.ts +++ b/src/lib/human-readable.ts @@ -54,12 +54,22 @@ function humanReadableImperativeTense(tense: T.ImperativeTense): string { : "perfective imperative"; } -export function humanReadableTense(tense: T.VerbTense | T.PerfectTense | T.ModalTense | T.ImperativeTense): string { - return isModalTense(tense) - ? humanReadableModalTense(tense) - : isPerfectTense(tense) - ? humanReadablePerfectTense(tense) - : isImperativeTense(tense) - ? humanReadableImperativeTense(tense as T.ImperativeTense) - : humanReadableVerbTense(tense); +export function humanReadableVerbForm(f: T.VerbFormName): string { + return isModalTense(f) + ? humanReadableModalTense(f) + : isPerfectTense(f) + ? humanReadablePerfectTense(f) + : isImperativeTense(f) + ? humanReadableImperativeTense(f as T.ImperativeTense) + : humanReadableVerbTense(f); +} + +export function humanReadableEquativeTense(f: T.EquativeTense): string { + return (f === "pastSubjunctive" + ? "past subjunctive" + : f === "wouldBe" + ? `"would be"` + : f === "wouldHaveBeen" + ? `"would have been"` + : f) + " equative"; } \ No newline at end of file diff --git a/src/library.ts b/src/library.ts index 8af94a4..907c38c 100644 --- a/src/library.ts +++ b/src/library.ts @@ -157,7 +157,10 @@ import { import { renderAPSelection, } from "./lib/phrase-building/render-ap"; -import { humanReadableTense } from "./lib/human-readable"; +import { + humanReadableVerbForm, + humanReadableEquativeTense, +} from "./lib/human-readable"; import NPPicker from "./components/np-picker/NPPicker"; import EPPicker from "./components/ep-explorer/EPPicker"; import EPExplorer from "./components/ep-explorer/EPExplorer"; @@ -244,7 +247,8 @@ export { getPashtoFromRendered, renderAPSelection, getEnglishVerb, - humanReadableTense, + humanReadableVerbForm, + humanReadableEquativeTense, roleIcon, vpsReducer, makeVPSelectionState, diff --git a/src/types.ts b/src/types.ts index a5d26e5..298d0f8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -582,8 +582,10 @@ export type VPSelectionComplete = { form: FormVersion, }; +export type VerbFormName = VerbTense | PerfectTense | ModalTense | ImperativeTense; + export type VerbSelectionComplete = Omit & { - tense: VerbTense | PerfectTense | ModalTense | ImperativeTense, + tense: VerbFormName, } export type VerbSelection = {