From 7792ce4d5a8bdfe0db8aa1d4b7b85a7fc96e3138 Mon Sep 17 00:00:00 2001 From: Lynn Date: Tue, 5 Sep 2023 19:38:03 +0200 Subject: [PATCH] =?UTF-8?q?TP-r=C3=BA-TP=20conjunction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/english.ts | 49 ++++++++++++++++++++++++++++++++++++++----------- src/grammar.ts | 10 ++++++---- src/toaq.ne | 12 +++++++----- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/english.ts b/src/english.ts index 9aa1df9..d86f3e0 100644 --- a/src/english.ts +++ b/src/english.ts @@ -24,6 +24,10 @@ function assertBranch(tree: Tree): asserts tree is Branch { } function leafToEnglish(leaf: Tree): string { + const text = leafText(leaf); + if (text === '◌́') { + return 'the'; + } return new Glosser(true).glossWord(leafText(leaf)); } @@ -31,6 +35,11 @@ function verbToEnglish(tree: Tree): string { if ('word' in tree) { return leafToEnglish(tree); } else if ('left' in tree) { + if (tree.label === 'EvAP') { + let k = new ClauseTranslator(); + k.processClause(tree.right); + return 'event of ' + k.emit(); + } const right = verbToEnglish(tree.right); if (tree.label === 'mıP') { return right.replace(/\b\w/, m => m.toUpperCase()); @@ -63,6 +72,7 @@ class ClauseTranslator { objects: Constituent[] = []; lateAdjuncts: string[] = []; modals: string[] = []; + conjunct?: string = undefined; constructor(toaqSpeechAct?: string) { this.toaqSpeechAct = toaqSpeechAct; } @@ -131,9 +141,13 @@ class ClauseTranslator { case "𝘷'": node = node.right; break; + case '&P': + this.conjunct = treeToEnglish(node.right).text; + node = node.left; + break; default: console.log(node); - throw new Error('unimplemented: ' + node.label); + throw new Error('unimplemented in processClause: ' + node.label); } } else { throw new Error('unexpected leaf in clause'); @@ -252,16 +266,19 @@ class ClauseTranslator { auxiliary += nt; } const verb = this.verb - ? conjugate(this.verb, verbForm, auxiliary ? false : past) + ? mode === 'DP' + ? this.verb + : conjugate(this.verb, verbForm, auxiliary ? false : past) : ''; + const earlyAdjuncts = this.earlyAdjuncts.map(x => x + ','); const subject = this.subject?.text ?? ''; const objects = this.objects.map(x => x.text); if (this.toaqComplementizer === 'ma') { order = [ auxiliary, - ...this.earlyAdjuncts, + ...earlyAdjuncts, subject, auxiliary2, preVerb, @@ -269,11 +286,12 @@ class ClauseTranslator { postVerb, ...objects, ...this.lateAdjuncts, + this.conjunct ?? '', ]; } else { order = [ complementizer, - ...this.earlyAdjuncts, + ...earlyAdjuncts, subject, auxiliary ?? '', auxiliary2, @@ -282,6 +300,7 @@ class ClauseTranslator { postVerb, ...objects, ...this.lateAdjuncts, + this.conjunct ?? '', ]; } @@ -309,6 +328,11 @@ function branchToEnglish(tree: Branch): Constituent { translator.processCP(tree); return { text: translator.emit() }; } + if (tree.label === 'TP') { + const translator = new ClauseTranslator(); + translator.processClause(tree); + return { text: translator.emit() }; + } if (tree.label === 'DP') { const d = tree.left; const nP = tree.right as Branch; @@ -327,7 +351,9 @@ function branchToEnglish(tree: Branch): Constituent { assertBranch(tree.right); const serial = tree.right.left; const object = tree.right.right; - return { text: serialToEnglish(serial) + ' ' + treeToEnglish(object) }; + return { + text: serialToEnglish(serial) + ' ' + treeToEnglish(object).text, + }; } else { const serial = tree.right; return { text: serialToEnglish(serial) + 'ly' }; @@ -352,14 +378,15 @@ function branchToEnglish(tree: Branch): Constituent { } } if (tree.label === '&P') { - assertBranch(tree.right); return { text: - treeToEnglish(tree.left).text + - ' ' + - leafToEnglish(tree.right.left) + - ' ' + - treeToEnglish(tree.right.right).text, + treeToEnglish(tree.left).text + ' ' + treeToEnglish(tree.right).text, + person: VerbForm.Plural, + }; + } + if (tree.label === "&'") { + return { + text: leafToEnglish(tree.left) + ' ' + treeToEnglish(tree.right).text, person: VerbForm.Plural, }; } diff --git a/src/grammar.ts b/src/grammar.ts index 67434e6..164607d 100644 --- a/src/grammar.ts +++ b/src/grammar.ts @@ -109,17 +109,19 @@ const grammar: Grammar = { {"name": "DP", "symbols": ["Focus", "DP"], "postprocess": makeBranch('FocusP')}, {"name": "nP", "symbols": ["nP", "CPrel"], "postprocess": makeBranch('nP')}, {"name": "nP", "symbols": ["CPdet"], "postprocess": makeBranchFunctionalLeft('nP', 'n')}, - {"name": "Clause", "symbols": ["MTP"], "postprocess": id}, {"name": "Clause", "symbols": ["term", "Bi", "Clause"], "postprocess": make3L('TopicP', "Topic'")}, + {"name": "Clause", "symbols": ["MTP"], "postprocess": id}, {"name": "Clause", "symbols": ["DP", "Na", "CPrelna"], "postprocess": make3L('𝘷P', "𝘷'")}, {"name": "Clause", "symbols": ["ModalP", "Na", "MTP"], "postprocess": make3L('𝘷P', "𝘷'")}, {"name": "ModalP", "symbols": ["ModalT4", "CPsub"], "postprocess": makeBranch('ModalP')}, - {"name": "MTP", "symbols": ["TP"], "postprocess": id}, - {"name": "MTP", "symbols": ["Modal", "TP"], "postprocess": makeT1ModalvP}, - {"name": "MTP", "symbols": ["Sigma", "Modal", "TP"], "postprocess": makeSigmaT1ModalvP}, + {"name": "MTP", "symbols": ["TP1"], "postprocess": id}, + {"name": "MTP", "symbols": ["Modal", "TP1"], "postprocess": makeT1ModalvP}, + {"name": "MTP", "symbols": ["Sigma", "Modal", "TP1"], "postprocess": makeSigmaT1ModalvP}, {"name": "MTPdet", "symbols": ["TPdet"], "postprocess": id}, {"name": "MTPdet", "symbols": ["Modal", "TPdet"], "postprocess": makeT1ModalvP}, {"name": "MTPdet", "symbols": ["Sigma", "Modal", "TPdet"], "postprocess": makeSigmaT1ModalvP}, + {"name": "TP1", "symbols": ["TP"], "postprocess": id}, + {"name": "TP1", "symbols": ["TP", "Conjunction", "TP1"], "postprocess": makeConn}, {"name": "TP", "symbols": ["AspP"], "postprocess": makeBranchCovertLeft('TP', 'T')}, {"name": "TP", "symbols": ["T1", "AspP"], "postprocess": makeBranch('TP')}, {"name": "TP", "symbols": ["Sigma", "T1", "AspP"], "postprocess": make3L('ΣP', 'TP')}, diff --git a/src/toaq.ne b/src/toaq.ne index 25f9f18..f226ea1 100644 --- a/src/toaq.ne +++ b/src/toaq.ne @@ -62,10 +62,10 @@ nP -> nP CPrel {% makeBranch('nP') %} # (sá) ∅ hao nP -> CPdet {% makeBranchFunctionalLeft('nP', 'n') %} -# pu hao -Clause -> MTP {% id %} # ní bï pu hao Clause -> term Bi Clause {% make3L('TopicP', "Topic'") %} +# pu hao +Clause -> MTP {% id %} # jí nä pu hao hóa Clause -> DP Na CPrelna {% make3L('𝘷P', "𝘷'") %} # shê ꝡä hao nä jıa hao @@ -75,9 +75,9 @@ ModalP -> ModalT4 CPsub {% makeBranch('ModalP') %} # "MTP" is a TP that can have a t1 modal in front. # ao pu chum hao jí -MTP -> TP {% id %} -MTP -> Modal TP {% makeT1ModalvP %} -MTP -> Sigma Modal TP {% makeSigmaT1ModalvP %} +MTP -> TP1 {% id %} +MTP -> Modal TP1 {% makeT1ModalvP %} +MTP -> Sigma Modal TP1 {% makeSigmaT1ModalvP %} # (sá) ao hao MTPdet -> TPdet {% id %} @@ -85,6 +85,8 @@ MTPdet -> Modal TPdet {% makeT1ModalvP %} MTPdet -> Sigma Modal TPdet {% makeSigmaT1ModalvP %} # pu chum hao jí +TP1 -> TP {% id %} +TP1 -> TP Conjunction TP1 {% makeConn %} TP -> AspP {% makeBranchCovertLeft('TP', 'T') %} TP -> T1 AspP {% makeBranch('TP') %} TP -> Sigma T1 AspP {% make3L('ΣP', 'TP') %}