diff --git a/package.json b/package.json index 90f40ac..bc89073 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ }, "dependencies": { "@formkit/auto-animate": "^1.0.0-beta.1", - "assert-never": "^1.2.1", "classnames": "^2.2.6", "jsurl2": "^2.1.0", "lz-string": "^1.4.4", diff --git a/src/App.tsx b/src/App.tsx index 945653e..9efae8f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -279,7 +279,7 @@ function App() { opts={textOptions} /> } -

🆕 Equative Phrase Builder

+

Equative Phrase Builder

({ np, from: "predicate" })); + : EP.predicate.type === "sandwich" + ? findPossesivesInNP(EP.predicate.inside) + : EP.predicate.type === "pronoun" + ? [] + : findPossesivesInNP(EP.predicate)).map(np => ({ np, from: "predicate" })); return [ ...inBlocks, ...inPredicate, diff --git a/src/lib/phrase-building/np-tools.ts b/src/lib/phrase-building/np-tools.ts index 8b20778..3a903d2 100644 --- a/src/lib/phrase-building/np-tools.ts +++ b/src/lib/phrase-building/np-tools.ts @@ -201,12 +201,13 @@ export function getEnglishFromRendered(r: T.Rendered; - return addPossesors(np.possesor?.np, addArticlesAndAdjs(np), r.type); + if (r.type === "pronoun") { + return r.e; } - return r.e; + if (r.type === "participle") { + return addPossesors(r.possesor?.np, r.e, r.type); + } + return addPossesors(r.possesor?.np, addArticlesAndAdjs(r), r.type); } function getEnglishFromRenderedSandwich(r: T.Rendered>): string | undefined { diff --git a/src/lib/phrase-building/render-ap.ts b/src/lib/phrase-building/render-ap.ts new file mode 100644 index 0000000..df9b471 --- /dev/null +++ b/src/lib/phrase-building/render-ap.ts @@ -0,0 +1,12 @@ +import * as T from "../../types"; +import { renderAdverbSelection } from "./render-ep"; +import { renderSandwich } from "./render-sandwich"; + +export function renderAP(ap: T.APSelection): T.Rendered { + if (ap.type === "sandwich") { + return renderSandwich(ap); + } + // if (ap.type === "adverb") { + return renderAdverbSelection(ap); + // } +} \ No newline at end of file diff --git a/src/lib/phrase-building/render-vp.ts b/src/lib/phrase-building/render-vp.ts index fcdae22..5eff791 100644 --- a/src/lib/phrase-building/render-vp.ts +++ b/src/lib/phrase-building/render-vp.ts @@ -23,8 +23,7 @@ import { renderEnglishVPBase } from "./english-vp-rendering"; import { personGender } from "../../lib/misc-helpers"; import { renderNPSelection } from "./render-np"; import { getObjectSelection, getSubjectSelection } from "./blocks-utils"; -import { renderSandwich } from "./render-sandwich"; -import { renderAdverbSelection } from "./render-ep"; +import { renderAP } from "./render-ap"; // TODO: ISSUE GETTING SPLIT HEAD NOT MATCHING WITH FUTURE VERBS @@ -78,26 +77,21 @@ function renderVPBlocks(blocks: T.VPSBlockComplete[], config: { king: "subject" | "object", }): T.RenderedVPSBlock[] { return blocks.map(({ block }): T.RenderedVPSBlock => { - if (block.type === "sandwich") { - return renderSandwich(block); - } - if (block.type === "adverb") { - return renderAdverbSelection(block); - } if (block.type === "subjectSelection") { return { type: "subjectSelection", selection: renderNPSelection(block.selection, config.inflectSubject, false, "subject", config.king === "subject" ? "king" : "servant"), } } - // if (block.type === "objectSelection") { + if (block.type === "objectSelection") { const object = typeof block === "object" ? block.selection : block; const selection = renderNPSelection(object, config.inflectObject, true, "object", config.king === "object" ? "king" : "servant"); return { type: "objectSelection", selection, }; - // } + } + return renderAP(block); }); } diff --git a/src/library.ts b/src/library.ts index 499e8db..d282a23 100644 --- a/src/library.ts +++ b/src/library.ts @@ -143,6 +143,9 @@ import { compileEP, compileVP, } from "./lib/phrase-building/compile"; +import { + renderAP, +} from "./lib/phrase-building/render-ap"; import NPPicker from "./components/np-picker/NPPicker"; import EPExplorer from "./components/ep-explorer/EPExplorer"; import shuffleArray from "./lib/shuffle-array"; @@ -219,6 +222,7 @@ export { renderNPSelection, getEnglishFromRendered, getPashtoFromRendered, + renderAP, // protobuf helpers readDictionary, writeDictionary, diff --git a/yarn.lock b/yarn.lock index c5b3fa8..6a12a11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2762,11 +2762,6 @@ asn1.js@^5.2.0: minimalistic-assert "^1.0.0" safer-buffer "^2.1.0" -assert-never@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/assert-never/-/assert-never-1.2.1.tgz#11f0e363bf146205fb08193b5c7b90f4d1cf44fe" - integrity sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw== - assert@^1.1.1: version "1.5.0" resolved "https://registry.yarnpkg.com/assert/-/assert-1.5.0.tgz#55c109aaf6e0aefdb3dc4b71240c70bf574b18eb"