Skip to content

Commit 29cc053

Browse files
committed
separate nanpa
1 parent 91c586c commit 29cc053

File tree

3 files changed

+47
-44
lines changed

3 files changed

+47
-44
lines changed

src/translator/clause.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ArrayResult } from "../array_result.ts";
33
import * as TokiPona from "../parser/ast.ts";
44
import * as English from "./ast.ts";
55
import { FilteredError, TranslationTodoError } from "./error.ts";
6-
import { nanpa } from "./modifier.ts";
6+
import { nanpa } from "./nanpa.ts";
77
import { perspective } from "./noun.ts";
88
import { multiplePhrases, multiplePhrasesAsNoun } from "./phrase.ts";
99
import { predicate } from "./predicate.ts";

src/translator/modifier.ts

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import * as Composer from "../parser/composer.ts";
55
import { adjective, compoundAdjective } from "./adjective.ts";
66
import * as English from "./ast.ts";
77
import { determiner } from "./determiner.ts";
8-
import {
9-
ExhaustedError,
10-
FilteredError,
11-
TranslationTodoError,
12-
} from "./error.ts";
8+
import { ExhaustedError, TranslationTodoError } from "./error.ts";
9+
import { nanpa } from "./nanpa.ts";
1310
import { noun } from "./noun.ts";
1411
import { number } from "./number.ts";
1512
import { phrase } from "./phrase.ts";
@@ -163,44 +160,6 @@ export function pi(
163160
modifier.type !== "adjective" || modifier.inWayPhrase == null
164161
) as ArrayResult<ModifierTranslation>;
165162
}
166-
export function nanpa(
167-
nanpa: TokiPona.Modifier & { type: "nanpa" },
168-
): ArrayResult<English.NounPhrase> {
169-
return phrase({
170-
phrase: nanpa.phrase,
171-
place: "object",
172-
includeGerund: true,
173-
includeVerb: false,
174-
})
175-
.map((phrase) => {
176-
if (phrase.type !== "noun") {
177-
throw new FilteredError(
178-
`${phrase.type} within "in position" phrase`,
179-
);
180-
} else if (
181-
(phrase.noun as English.NounPhrase & { type: "simple" })
182-
.preposition.length > 0
183-
) {
184-
throw new FilteredError('preposition within "in position" phrase');
185-
} else {
186-
return {
187-
type: "simple",
188-
determiner: [],
189-
adjective: [],
190-
noun: {
191-
word: "position",
192-
emphasis: nanpa.nanpa.emphasis != null,
193-
},
194-
quantity: "singular",
195-
perspective: "third",
196-
postCompound: phrase.noun,
197-
postAdjective: null,
198-
preposition: [],
199-
emphasis: false,
200-
};
201-
}
202-
});
203-
}
204163
function modifier(
205164
modifier: TokiPona.Modifier,
206165
): ArrayResult<ModifierTranslation> {

src/translator/nanpa.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { ArrayResult } from "../array_result.ts";
2+
import * as TokiPona from "../parser/ast.ts";
3+
import * as English from "./ast.ts";
4+
import { FilteredError } from "./error.ts";
5+
import { phrase } from "./phrase.ts";
6+
7+
export function nanpa(
8+
nanpa: TokiPona.Modifier & { type: "nanpa" },
9+
): ArrayResult<English.NounPhrase> {
10+
return phrase({
11+
phrase: nanpa.phrase,
12+
place: "object",
13+
includeGerund: true,
14+
includeVerb: false,
15+
})
16+
.map((phrase) => {
17+
if (phrase.type !== "noun") {
18+
throw new FilteredError(
19+
`${phrase.type} within "in position" phrase`,
20+
);
21+
} else if (
22+
(phrase.noun as English.NounPhrase & { type: "simple" })
23+
.preposition.length > 0
24+
) {
25+
throw new FilteredError('preposition within "in position" phrase');
26+
} else {
27+
return {
28+
type: "simple",
29+
determiner: [],
30+
adjective: [],
31+
noun: {
32+
word: "position",
33+
emphasis: nanpa.nanpa.emphasis != null,
34+
},
35+
quantity: "singular",
36+
perspective: "third",
37+
postCompound: phrase.noun,
38+
postAdjective: null,
39+
preposition: [],
40+
emphasis: false,
41+
};
42+
}
43+
});
44+
}

0 commit comments

Comments
 (0)