@@ -10,6 +10,7 @@ import {
10
10
ExhaustedError ,
11
11
FilteredError ,
12
12
TranslationTodoError ,
13
+ UntranslatableError ,
13
14
} from "./error.ts" ;
14
15
import { CONJUNCTION } from "./misc.ts" ;
15
16
import {
@@ -18,7 +19,7 @@ import {
18
19
multipleModifiers ,
19
20
} from "./modifier.ts" ;
20
21
import { fromNounForms , PartialNoun } from "./noun.ts" ;
21
- import { nounAsPreposition } from "./preposition.ts" ;
22
+ import { nounAsPreposition , preposition } from "./preposition.ts" ;
22
23
import { Place } from "./pronoun.ts" ;
23
24
import { PartialCompoundVerb , PartialVerb } from "./verb.ts" ;
24
25
import { wordUnit } from "./word_unit.ts" ;
@@ -205,6 +206,27 @@ function defaultPhrase(
205
206
} )
206
207
. addErrorWhenNone ( ( ) => new ExhaustedError ( Composer . phrase ( phrase ) ) ) ;
207
208
}
209
+ function prepositionAsVerb ( preposition : English . Preposition ) : PartialVerb {
210
+ return {
211
+ modal : null ,
212
+ adverb : [ ] ,
213
+ first : {
214
+ presentPlural : "are" ,
215
+ presentSingular : "is" ,
216
+ past : "were" ,
217
+ } ,
218
+ reduplicationCount : 1 ,
219
+ wordEmphasis : false ,
220
+ rest : [ ] ,
221
+ subjectComplement : null ,
222
+ object : null ,
223
+ objectComplement : null ,
224
+ preposition : [ preposition ] ,
225
+ forObject : false ,
226
+ predicateType : null ,
227
+ phraseEmphasis : false ,
228
+ } ;
229
+ }
208
230
export function phrase (
209
231
options : Readonly < {
210
232
phrase : TokiPona . Phrase ;
@@ -213,12 +235,24 @@ export function phrase(
213
235
includeVerb : boolean ;
214
236
} > ,
215
237
) : ArrayResult < PhraseTranslation > {
216
- const { phrase } = options ;
238
+ const { phrase, includeVerb } = options ;
217
239
switch ( phrase . type ) {
218
240
case "default" :
219
241
return defaultPhrase ( { ...options , phrase } ) ;
220
- case "preverb" :
221
242
case "preposition" :
243
+ if ( includeVerb ) {
244
+ return preposition ( phrase )
245
+ . map ( prepositionAsVerb )
246
+ . map < PhraseTranslation > ( ( verb ) => ( {
247
+ type : "verb" ,
248
+ verb : { ...verb , type : "simple" } ,
249
+ } ) ) ;
250
+ } else {
251
+ return new ArrayResult (
252
+ new UntranslatableError ( "preposition" , "noun or adjective" ) ,
253
+ ) ;
254
+ }
255
+ case "preverb" :
222
256
return new ArrayResult ( new TranslationTodoError ( phrase . type ) ) ;
223
257
}
224
258
}
@@ -346,7 +380,9 @@ export function multiplePhrases(
346
380
phrase . type === "adjective" && phrase . inWayPhrase != null
347
381
)
348
382
) {
349
- throw new FilteredError ( "in [adjective] way phrase within compound" ) ;
383
+ throw new FilteredError (
384
+ "in [adjective] way phrase within compound" ,
385
+ ) ;
350
386
}
351
387
if ( phrase . every ( ( phrase ) => phrase . type === "noun" ) ) {
352
388
return {
0 commit comments