Skip to content

Commit ebc28f4

Browse files
committed
remove verb filter parameter
1 parent a538e7c commit ebc28f4

File tree

6 files changed

+21
-48
lines changed

6 files changed

+21
-48
lines changed

src/translator/clause.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function phraseClause(phrases: TokiPona.MultiplePhrases) {
1919
place: "object",
2020
includeGerund: true,
2121
andParticle: "en",
22-
includeVerb: false,
2322
})
2423
.map((phrase): English.Clause => {
2524
switch (phrase.type) {
@@ -78,7 +77,7 @@ export function subject(
7877
andParticle: string;
7978
}>,
8079
): IterableResult<English.NounPhrase> {
81-
return multiplePhrases({ ...options, includeVerb: false })
80+
return multiplePhrases({ ...options })
8281
.map((phrase) =>
8382
phrase.type === "noun"
8483
? phrase.noun
@@ -203,7 +202,6 @@ export function clause(
203202
place: "object",
204203
includeGerund: true,
205204
andParticle: "en",
206-
includeVerb: false,
207205
})
208206
.map((phrase) =>
209207
phrase.type === "noun"

src/translator/modifier.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,11 @@ function pi(
151151
phrase: insidePhrase,
152152
place: "object",
153153
includeGerund: true,
154-
includeVerb: false,
155154
})
156155
.filter((modifier) =>
157-
modifier.type !== "adjective" || modifier.inWayPhrase == null
158-
) as IterableResult<
159-
PhraseTranslation & { type: Exclude<PhraseTranslation["type"], "verb"> }
160-
>;
156+
modifier.type !== "verb" &&
157+
(modifier.type !== "adjective" || modifier.inWayPhrase == null)
158+
);
161159
}
162160
function modifier(modifier: TokiPona.Modifier) {
163161
switch (modifier.type) {

src/translator/nanpa.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export function nanpa(
1212
phrase: nanpa.phrase,
1313
place: "object",
1414
includeGerund: true,
15-
includeVerb: false,
1615
})
1716
.map((phrase) =>
1817
phrase.type !== "noun"

src/translator/phrase.ts

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { extractNegativeFromMultipleAdverbs, NOT } from "./adverb.ts";
1111
import * as English from "./ast.ts";
1212
import { getNumber } from "./determiner.ts";
13-
import { ExhaustedError, FilteredError, UntranslatableError } from "./error.ts";
13+
import { ExhaustedError, FilteredError } from "./error.ts";
1414
import { CONJUNCTION } from "./misc.ts";
1515
import {
1616
AdjectivalModifier,
@@ -196,10 +196,9 @@ function defaultPhrase(
196196
phrase: TokiPona.Phrase & { type: "simple" };
197197
place: Place;
198198
includeGerund: boolean;
199-
includeVerb: boolean;
200199
}>,
201200
) {
202-
const { phrase, includeVerb } = options;
201+
const { phrase } = options;
203202
const emphasis = phrase.emphasis != null;
204203
return IterableResult.combine(
205204
wordUnit({ ...options, wordUnit: phrase.headWord }),
@@ -221,7 +220,7 @@ function defaultPhrase(
221220
type: "adjective",
222221
});
223222
} else if (
224-
includeVerb && headWord.type === "verb" && modifier.type === "adverbial"
223+
headWord.type === "verb" && modifier.type === "adverbial"
225224
) {
226225
return IterableResult.from(() =>
227226
IterableResult.single<PhraseTranslation>({
@@ -286,7 +285,6 @@ function preverb(
286285
phrase: preverb.phrase,
287286
place: "object",
288287
includeGerund: false,
289-
includeVerb: true,
290288
}),
291289
)
292290
.filterMap(([verb, predicate]): null | PartialSimpleVerb => {
@@ -345,38 +343,25 @@ export function phrase(
345343
phrase: TokiPona.Phrase;
346344
place: Place;
347345
includeGerund: boolean;
348-
includeVerb: boolean;
349346
}>,
350347
): IterableResult<PhraseTranslation> {
351-
const { phrase, includeVerb } = options;
348+
const { phrase } = options;
352349
switch (phrase.type) {
353350
case "simple":
354351
return defaultPhrase({ ...options, phrase });
355352
case "preposition":
356-
if (includeVerb) {
357-
return preposition(phrase)
358-
.map(prepositionAsVerb)
359-
.map((verb): PhraseTranslation => ({
360-
type: "verb",
361-
verb: { ...verb, type: "simple" },
362-
}));
363-
} else {
364-
return IterableResult.errors([
365-
new UntranslatableError("preposition", "noun or adjective"),
366-
]);
367-
}
353+
return preposition(phrase)
354+
.map(prepositionAsVerb)
355+
.map((verb): PhraseTranslation => ({
356+
type: "verb",
357+
verb: { ...verb, type: "simple" },
358+
}));
368359
case "preverb":
369-
if (includeVerb) {
370-
return preverb(phrase)
371-
.map((verb): PhraseTranslation => ({
372-
type: "verb",
373-
verb: { ...verb, type: "simple" },
374-
}));
375-
} else {
376-
return IterableResult.errors([
377-
new UntranslatableError("preverb", "noun or adjective"),
378-
]);
379-
}
360+
return preverb(phrase)
361+
.map((verb): PhraseTranslation => ({
362+
type: "verb",
363+
verb: { ...verb, type: "simple" },
364+
}));
380365
}
381366
}
382367
export function phraseAsVerb(
@@ -443,10 +428,9 @@ export function multiplePhrases(
443428
place: Place;
444429
includeGerund: boolean;
445430
andParticle: null | string;
446-
includeVerb: boolean;
447431
}>,
448432
): IterableResult<PhraseTranslation> {
449-
const { phrases, andParticle, includeVerb } = options;
433+
const { phrases, andParticle } = options;
450434
switch (phrases.type) {
451435
case "simple":
452436
return phrase({ ...options, phrase: phrases.phrase });
@@ -488,7 +472,7 @@ export function multiplePhrases(
488472
inWayPhrase: null,
489473
};
490474
}
491-
} else if (includeVerb) {
475+
} else {
492476
return {
493477
type: "verb",
494478
verb: {
@@ -500,8 +484,6 @@ export function multiplePhrases(
500484
prepositions: [],
501485
},
502486
};
503-
} else {
504-
return null;
505487
}
506488
})
507489
.addErrorWhenNone(() =>

src/translator/predicate.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ export function predicate(
165165
phrase: tokiPonaPredicate.predicate,
166166
place: "object",
167167
includeGerund: false,
168-
includeVerb: true,
169168
})
170169
.map(phraseAsVerb);
171170
case "associated": {
@@ -174,7 +173,6 @@ export function predicate(
174173
place: "object",
175174
includeGerund: false,
176175
andParticle,
177-
includeVerb: true,
178176
});
179177
const object = IterableResult.single(tokiPonaPredicate.objects)
180178
.flatMap((object) => {
@@ -184,7 +182,6 @@ export function predicate(
184182
place: "object",
185183
includeGerund: true,
186184
andParticle: "e",
187-
includeVerb: false,
188185
});
189186
} else {
190187
return IterableResult.single(null);

src/translator/preposition.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export function preposition(
3131
place: "object",
3232
includeGerund: true,
3333
andParticle: null,
34-
includeVerb: false,
3534
})
3635
.map((phrases) =>
3736
phrases.type === "noun"

0 commit comments

Comments
 (0)