diff --git a/website/package.json b/website/package.json index 08f245f..b09e0be 100644 --- a/website/package.json +++ b/website/package.json @@ -7,7 +7,7 @@ "private": true, "dependencies": { "@fortawesome/fontawesome-free": "^5.15.2", - "@lingdocs/pashto-inflector": "3.8.9", + "@lingdocs/pashto-inflector": "3.9.4", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", @@ -110,6 +110,6 @@ "user-event": "^4.0.0" }, "peerDependencies": { - "@lingdocs/pashto-inflector": "3.8.9" + "@lingdocs/pashto-inflector": "3.9.4" } } diff --git a/website/src/App.css b/website/src/App.css index 2ca83c8..fbbb983 100644 --- a/website/src/App.css +++ b/website/src/App.css @@ -140,6 +140,14 @@ hr { margin-left: 1rem; } +.inflections-preview-table { + table-layout: fixed; +} + +.inflections-preview-table td { + padding-right: 1rem; +} + kbd { background-color: #eee; border-radius: 3px; diff --git a/website/src/components/ExtraEntryInfo.tsx b/website/src/components/ExtraEntryInfo.tsx index 4d28668..310e931 100644 --- a/website/src/components/ExtraEntryInfo.tsx +++ b/website/src/components/ExtraEntryInfo.tsx @@ -5,14 +5,20 @@ * LICENSE file in the root directory of this source tree. * */ - -import React from "react"; -import { inflectWord, Types, InlinePs } from "@lingdocs/pashto-inflector"; +import { + inflectWord, + Types, + InlinePs, +} from "@lingdocs/pashto-inflector"; +import { isAdjectiveEntry, isNounEntry } from "@lingdocs/pashto-inflector/dist/lib/type-predicates"; const InflectionsInfo = ({ entry, textOptions }: { entry: Types.DictionaryEntry, textOptions: Types.TextOptions, }) => { + if (!isNounEntry(entry) && !isAdjectiveEntry(entry)) { + return null; + } const inf = ((): Types.InflectorOutput | false => { try { return inflectWord(entry); @@ -24,21 +30,11 @@ const InflectionsInfo = ({ entry, textOptions }: { if (!inf) { return null; } - // unisex noun / adjective - if (inf.inflections && "masc" in inf.inflections && "fem" in inf.inflections) { + if (inf.inflections) { + // TODO: would be nice if inflection pattern number was in the inflections object return (
- {inf.inflections.masc[1][0]} - {` `} - {inf.inflections.fem[0][0]} -
- ); - } - // masculine noun - if (inf.inflections && "masc" in inf.inflections) { - return ( -
- {inf.inflections.masc[1][0]} +
); } @@ -46,6 +42,13 @@ const InflectionsInfo = ({ entry, textOptions }: { return null; }; +function InflectionsPreview({ inf, opts }: { inf: Types.Inflections, opts: Types.TextOptions }) { + return
+ {"masc" in inf && {inf.masc[1][0]}} + {"fem" in inf && {inf.fem[1][0]}} +
+} + const ArabicPluralInfo = ({ entry, textOptions }: { entry: Types.DictionaryEntry, textOptions: Types.TextOptions, diff --git a/website/src/screens/IsolatedEntry.tsx b/website/src/screens/IsolatedEntry.tsx index ab68b7b..5a2eff4 100644 --- a/website/src/screens/IsolatedEntry.tsx +++ b/website/src/screens/IsolatedEntry.tsx @@ -14,6 +14,7 @@ import { InlinePs, Types as T, typePredicates as tp, + getInflectionPattern, } from "@lingdocs/pashto-inflector"; import { submissionBase, @@ -224,7 +225,13 @@ function IsolatedEntry({ state, dictionary, isolateEntry }: { } {editSubmitted &&

Thank you for your help!

} {inf && <> - {inf.inflections && } + {inf.inflections &&
+
Inflection pattern {humanReadableInflectionPattern(getInflectionPattern( + // @ts-ignore + entry + ), textOptions)}
+ +
} {"plural" in inf && inf.plural !== undefined &&
Plural
@@ -276,4 +283,20 @@ function explodeEntry(entry: T.DictionaryEntry): T.DictionaryEntry { }; } +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; +} + export default IsolatedEntry; \ No newline at end of file diff --git a/website/yarn.lock b/website/yarn.lock index 0d31d9c..d484f8e 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -1590,10 +1590,10 @@ "@types/yargs" "^16.0.0" chalk "^4.0.0" -"@lingdocs/pashto-inflector@3.8.9": - version "3.8.9" - resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-3.8.9.tgz#c023449dc13dbc32ef95cef172a68b5b0b4659bf" - integrity sha512-60hAao+ADerI5hOMeJzYmrSCliwTqCndbUlx1Ke58s2FikxDqUb9/wb700JVbhsVLyRdr6tGg+YslDf4irr5tA== +"@lingdocs/pashto-inflector@3.9.4": + version "3.9.4" + resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-3.9.4.tgz#b85bd8b9c235da1b77a04bd4178be91371a94726" + integrity sha512-bthgBbzkFHIYUOTFNUNcwWFuhCkFlX7RCPQIbZdXFPOdUoEGtlngqJkECKm+pIShQioEGuMxhW0plhXDIccA8w== dependencies: "@formkit/auto-animate" "^1.0.0-beta.1" classnames "^2.2.6"