fix phrase bugs and expose renderAP
This commit is contained in:
parent
fdf8714207
commit
e3b3b9f2b6
|
@ -24,7 +24,6 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@formkit/auto-animate": "^1.0.0-beta.1",
|
"@formkit/auto-animate": "^1.0.0-beta.1",
|
||||||
"assert-never": "^1.2.1",
|
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"jsurl2": "^2.1.0",
|
"jsurl2": "^2.1.0",
|
||||||
"lz-string": "^1.4.4",
|
"lz-string": "^1.4.4",
|
||||||
|
|
|
@ -279,7 +279,7 @@ function App() {
|
||||||
opts={textOptions}
|
opts={textOptions}
|
||||||
/>
|
/>
|
||||||
</div>}
|
</div>}
|
||||||
<h4>🆕 Equative Phrase Builder</h4>
|
<h4>Equative Phrase Builder</h4>
|
||||||
<EPExplorer
|
<EPExplorer
|
||||||
opts={textOptions}
|
opts={textOptions}
|
||||||
entryFeeder={entryFeeder}
|
entryFeeder={entryFeeder}
|
||||||
|
|
|
@ -401,7 +401,8 @@ function compileEnglishEP(EP: T.EPRendered): string[] | undefined {
|
||||||
function insertEWords(e: string, { subject, predicate, APs }: { subject: string, predicate: string, APs: string }): string {
|
function insertEWords(e: string, { subject, predicate, APs }: { subject: string, predicate: string, APs: string }): string {
|
||||||
return e.replace("$SUBJ", subject).replace("$PRED", predicate || "") + APs;
|
return e.replace("$SUBJ", subject).replace("$PRED", predicate || "") + APs;
|
||||||
}
|
}
|
||||||
const engSubj = getRenderedSubjectSelection(EP.blocks).selection.e;
|
const engSubjR = getRenderedSubjectSelection(EP.blocks).selection;
|
||||||
|
const engSubj = getEnglishFromRendered(engSubjR);
|
||||||
const engPred = getEnglishFromRendered(EP.predicate);
|
const engPred = getEnglishFromRendered(EP.predicate);
|
||||||
const engAPs = getEnglishAPs(EP.blocks);
|
const engAPs = getEnglishAPs(EP.blocks);
|
||||||
// require all English parts for making the English phrase
|
// require all English parts for making the English phrase
|
||||||
|
@ -559,10 +560,11 @@ export function findPossesivesToShrinkInEP(EP: T.EPRendered): FoundNP[] {
|
||||||
? []
|
? []
|
||||||
: (EP.predicate.type === "adjective")
|
: (EP.predicate.type === "adjective")
|
||||||
? findPossesivesInAdjective(EP.predicate)
|
? findPossesivesInAdjective(EP.predicate)
|
||||||
: findPossesivesInNP(
|
: EP.predicate.type === "sandwich"
|
||||||
// @ts-ignore - ts being dumb
|
? findPossesivesInNP(EP.predicate.inside)
|
||||||
EP.predicate as T.NPSelection
|
: EP.predicate.type === "pronoun"
|
||||||
)).map(np => ({ np, from: "predicate" }));
|
? []
|
||||||
|
: findPossesivesInNP(EP.predicate)).map(np => ({ np, from: "predicate" }));
|
||||||
return [
|
return [
|
||||||
...inBlocks,
|
...inBlocks,
|
||||||
...inPredicate,
|
...inPredicate,
|
||||||
|
|
|
@ -201,12 +201,13 @@ export function getEnglishFromRendered(r: T.Rendered<T.NPSelection | T.EqCompSel
|
||||||
if (r.type === "adjective") {
|
if (r.type === "adjective") {
|
||||||
return getEnglishFromRenderedAdjective(r);
|
return getEnglishFromRenderedAdjective(r);
|
||||||
}
|
}
|
||||||
if (r.type !== "pronoun") {
|
if (r.type === "pronoun") {
|
||||||
// TODO: shouldn't have to do this 'as' - should be automatically narrowing
|
|
||||||
const np = r as T.Rendered<T.NounSelection>;
|
|
||||||
return addPossesors(np.possesor?.np, addArticlesAndAdjs(np), r.type);
|
|
||||||
}
|
|
||||||
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<T.SandwichSelection<T.Sandwich>>): string | undefined {
|
function getEnglishFromRenderedSandwich(r: T.Rendered<T.SandwichSelection<T.Sandwich>>): string | undefined {
|
||||||
|
|
|
@ -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<T.APSelection> {
|
||||||
|
if (ap.type === "sandwich") {
|
||||||
|
return renderSandwich(ap);
|
||||||
|
}
|
||||||
|
// if (ap.type === "adverb") {
|
||||||
|
return renderAdverbSelection(ap);
|
||||||
|
// }
|
||||||
|
}
|
|
@ -23,8 +23,7 @@ import { renderEnglishVPBase } from "./english-vp-rendering";
|
||||||
import { personGender } from "../../lib/misc-helpers";
|
import { personGender } from "../../lib/misc-helpers";
|
||||||
import { renderNPSelection } from "./render-np";
|
import { renderNPSelection } from "./render-np";
|
||||||
import { getObjectSelection, getSubjectSelection } from "./blocks-utils";
|
import { getObjectSelection, getSubjectSelection } from "./blocks-utils";
|
||||||
import { renderSandwich } from "./render-sandwich";
|
import { renderAP } from "./render-ap";
|
||||||
import { renderAdverbSelection } from "./render-ep";
|
|
||||||
|
|
||||||
// TODO: ISSUE GETTING SPLIT HEAD NOT MATCHING WITH FUTURE VERBS
|
// TODO: ISSUE GETTING SPLIT HEAD NOT MATCHING WITH FUTURE VERBS
|
||||||
|
|
||||||
|
@ -78,26 +77,21 @@ function renderVPBlocks(blocks: T.VPSBlockComplete[], config: {
|
||||||
king: "subject" | "object",
|
king: "subject" | "object",
|
||||||
}): T.RenderedVPSBlock[] {
|
}): T.RenderedVPSBlock[] {
|
||||||
return blocks.map(({ block }): 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") {
|
if (block.type === "subjectSelection") {
|
||||||
return {
|
return {
|
||||||
type: "subjectSelection",
|
type: "subjectSelection",
|
||||||
selection: renderNPSelection(block.selection, config.inflectSubject, false, "subject", config.king === "subject" ? "king" : "servant"),
|
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 object = typeof block === "object" ? block.selection : block;
|
||||||
const selection = renderNPSelection(object, config.inflectObject, true, "object", config.king === "object" ? "king" : "servant");
|
const selection = renderNPSelection(object, config.inflectObject, true, "object", config.king === "object" ? "king" : "servant");
|
||||||
return {
|
return {
|
||||||
type: "objectSelection",
|
type: "objectSelection",
|
||||||
selection,
|
selection,
|
||||||
};
|
};
|
||||||
// }
|
}
|
||||||
|
return renderAP(block);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,9 @@ import {
|
||||||
compileEP,
|
compileEP,
|
||||||
compileVP,
|
compileVP,
|
||||||
} from "./lib/phrase-building/compile";
|
} from "./lib/phrase-building/compile";
|
||||||
|
import {
|
||||||
|
renderAP,
|
||||||
|
} from "./lib/phrase-building/render-ap";
|
||||||
import NPPicker from "./components/np-picker/NPPicker";
|
import NPPicker from "./components/np-picker/NPPicker";
|
||||||
import EPExplorer from "./components/ep-explorer/EPExplorer";
|
import EPExplorer from "./components/ep-explorer/EPExplorer";
|
||||||
import shuffleArray from "./lib/shuffle-array";
|
import shuffleArray from "./lib/shuffle-array";
|
||||||
|
@ -219,6 +222,7 @@ export {
|
||||||
renderNPSelection,
|
renderNPSelection,
|
||||||
getEnglishFromRendered,
|
getEnglishFromRendered,
|
||||||
getPashtoFromRendered,
|
getPashtoFromRendered,
|
||||||
|
renderAP,
|
||||||
// protobuf helpers
|
// protobuf helpers
|
||||||
readDictionary,
|
readDictionary,
|
||||||
writeDictionary,
|
writeDictionary,
|
||||||
|
|
|
@ -2762,11 +2762,6 @@ asn1.js@^5.2.0:
|
||||||
minimalistic-assert "^1.0.0"
|
minimalistic-assert "^1.0.0"
|
||||||
safer-buffer "^2.1.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:
|
assert@^1.1.1:
|
||||||
version "1.5.0"
|
version "1.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/assert/-/assert-1.5.0.tgz#55c109aaf6e0aefdb3dc4b71240c70bf574b18eb"
|
resolved "https://registry.yarnpkg.com/assert/-/assert-1.5.0.tgz#55c109aaf6e0aefdb3dc4b71240c70bf574b18eb"
|
||||||
|
|
Loading…
Reference in New Issue