Skip to content

Commit 8bfc9b5

Browse files
committed
implement "nanpa X la" translation
1 parent 7fdf43d commit 8bfc9b5

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

src/translator/clause.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { predicate } from "./predicate.ts";
99
import { nounAsPreposition, preposition } from "./preposition.ts";
1010
import { addModalToAll, noAdverbs, verb } from "./verb.ts";
1111
import { noEmphasis } from "./word.ts";
12+
import { nanpa } from "./modifier.ts";
1213

1314
function phraseClause(
1415
phrases: TokiPona.MultiplePhrases,
@@ -215,6 +216,14 @@ export function contextClause(
215216
}))
216217
);
217218
case "nanpa":
219+
return nanpa(contextClause)
220+
.map((object) => [{
221+
type: "preposition",
222+
adverb: [],
223+
preposition: noEmphasis("at"),
224+
object,
225+
emphasis: false,
226+
}]);
218227
case "anu":
219228
return new ArrayResult(
220229
new TranslationTodoError(`${contextClause.type} context clause`),

src/translator/modifier.ts

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type ModifierTranslation =
2828
| Readonly<{ type: "determiner"; determiner: English.Determiner }>
2929
| Readonly<{ type: "adverb"; adverb: English.Word }>
3030
| Readonly<{ type: "name"; name: string }>
31-
| Readonly<{ type: "in position phrase"; noun: English.NounPhrase }>;
31+
| Readonly<{ type: "position phrase"; noun: English.NounPhrase }>;
3232
export type AdjectivalModifier = Readonly<{
3333
nounPreposition:
3434
| null
@@ -146,7 +146,7 @@ export function defaultModifier(
146146
}
147147
}
148148
}
149-
export function piModifier(
149+
export function pi(
150150
insidePhrase: TokiPona.Phrase,
151151
): ArrayResult<ModifierTranslation> {
152152
return phrase({
@@ -163,9 +163,9 @@ export function piModifier(
163163
modifier.type !== "adjective" || modifier.inWayPhrase == null
164164
) as ArrayResult<ModifierTranslation>;
165165
}
166-
function nanpaModifier(
166+
export function nanpa(
167167
nanpa: TokiPona.Modifier & { type: "nanpa" },
168-
): ArrayResult<ModifierTranslation> {
168+
): ArrayResult<English.NounPhrase> {
169169
return phrase({
170170
phrase: nanpa.phrase,
171171
place: "object",
@@ -184,22 +184,19 @@ function nanpaModifier(
184184
throw new FilteredError('preposition within "in position" phrase');
185185
} else {
186186
return {
187-
type: "in position phrase",
187+
type: "simple",
188+
determiner: [],
189+
adjective: [],
188190
noun: {
189-
type: "simple",
190-
determiner: [],
191-
adjective: [],
192-
noun: {
193-
word: "position",
194-
emphasis: nanpa.nanpa.emphasis != null,
195-
},
196-
quantity: "singular",
197-
perspective: "third",
198-
postCompound: phrase.noun,
199-
postAdjective: null,
200-
preposition: [],
201-
emphasis: false,
191+
word: "position",
192+
emphasis: nanpa.nanpa.emphasis != null,
202193
},
194+
quantity: "singular",
195+
perspective: "third",
196+
postCompound: phrase.noun,
197+
postAdjective: null,
198+
preposition: [],
199+
emphasis: false,
203200
};
204201
}
205202
});
@@ -213,9 +210,10 @@ function modifier(
213210
case "proper words":
214211
return new ArrayResult([{ type: "name", name: modifier.words }]);
215212
case "pi":
216-
return piModifier(modifier.phrase);
213+
return pi(modifier.phrase);
217214
case "nanpa":
218-
return nanpaModifier(modifier);
215+
return nanpa(modifier)
216+
.map((noun) => ({ type: "position phrase", noun }));
219217
}
220218
}
221219
export function multipleModifiers(
@@ -247,7 +245,7 @@ export function multipleModifiers(
247245
.flatMap((modifier) => modifier.type === "name" ? [modifier.name] : []);
248246

249247
const inPositionPhrase = modifiers.flatMap((modifier) =>
250-
modifier.type === "in position phrase" ? [modifier.noun] : []
248+
modifier.type === "position phrase" ? [modifier.noun] : []
251249
);
252250

253251
let adjectival: ArrayResult<MultipleModifierTranslation>;

0 commit comments

Comments
 (0)