Skip to content

Commit

Permalink
English: don't get confused by early adjuncts
Browse files Browse the repository at this point in the history
  • Loading branch information
lynn committed Aug 26, 2023
1 parent 7a670a8 commit c451bc4
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/english.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class ClauseTranslator {
toaqAspect: string = 'tam';
negative: boolean = false;
subject?: string = undefined;
earlyAdjuncts: string[] = [];
objects: string[] = [];
lateAdjuncts: string[] = [];
modals: string[] = [];
constructor(toaqSpeechAct?: string) {
this.toaqSpeechAct = toaqSpeechAct;
Expand All @@ -66,11 +68,24 @@ class ClauseTranslator {
if ('children' in node) {
if (node.label !== '*𝘷P') throw new Error('non-*𝘷P Rose');
this.verb = serialToEnglish(node.children[0]);
if (node.children[1]) {
this.subject = treeToEnglish(node.children[1]);
}
for (let i = 2; i < node.children.length; i++) {
this.objects.push(treeToEnglish(node.children[i]));
let late = false;
for (let i = 1; i < node.children.length; i++) {
const child = node.children[i];
const english = treeToEnglish(child);
if (child.label === 'AdjunctP') {
if (late) {
this.lateAdjuncts.push(english);
} else {
this.earlyAdjuncts.push(english);
}
} else {
if (this.subject) {
this.objects.push(english);
} else {
this.subject = english;
}
late = true;
}
}
break;
} else if ('left' in node) {
Expand Down Expand Up @@ -189,19 +204,23 @@ class ClauseTranslator {
tense,
aspect,
auxiliary,
...this.earlyAdjuncts,
this.subject ?? '',
this.verb ?? '',
...this.objects,
...this.lateAdjuncts,
];
} else {
order = [
complementizer,
...this.earlyAdjuncts,
this.subject ?? '',
tense,
aspect,
auxiliary ?? '',
this.verb ?? '',
...this.objects,
...this.lateAdjuncts,
];
}

Expand Down

0 comments on commit c451bc4

Please sign in to comment.