@@ -5,9 +5,10 @@ import * as English from "./ast.ts";
5
5
import { FilteredError , TranslationTodoError } from "./error.ts" ;
6
6
import { nanpa } from "./nanpa.ts" ;
7
7
import { perspective , quantity } from "./noun.ts" ;
8
- import { multiplePhrases , multiplePhrasesAsNoun } from "./phrase.ts" ;
8
+ import { multiplePhrases } from "./phrase.ts" ;
9
9
import { predicate } from "./predicate.ts" ;
10
10
import { nounAsPreposition , preposition } from "./preposition.ts" ;
11
+ import { Place } from "./pronoun.ts" ;
11
12
import { addModalToAll , noAdverbs , verb } from "./verb.ts" ;
12
13
import { noEmphasis } from "./word.ts" ;
13
14
import { fromSimpleDefinition } from "./word_unit.ts" ;
@@ -69,9 +70,24 @@ function phraseClause(phrases: TokiPona.MultiplePhrases) {
69
70
}
70
71
} ) ;
71
72
}
73
+ export function subject (
74
+ options : Readonly < {
75
+ phrases : TokiPona . MultiplePhrases ;
76
+ place : Place ;
77
+ includeGerund : boolean ;
78
+ andParticle : string ;
79
+ } > ,
80
+ ) : IterableResult < English . NounPhrase > {
81
+ return multiplePhrases ( { ...options , includeVerb : false } )
82
+ . map ( ( phrase ) =>
83
+ phrase . type === "noun"
84
+ ? phrase . noun
85
+ : throwError ( new FilteredError ( `${ phrase . type } as subject` ) )
86
+ ) ;
87
+ }
72
88
function liClause ( clause : TokiPona . Clause & { type : "li clause" } ) {
73
89
return IterableResult . combine (
74
- multiplePhrasesAsNoun ( {
90
+ subject ( {
75
91
phrases : clause . subjects ,
76
92
place : "subject" ,
77
93
includeGerund : true ,
@@ -129,8 +145,8 @@ function iWish(
129
145
} ;
130
146
}
131
147
function oClause ( clause : TokiPona . Clause & { type : "o clause" } ) {
132
- const subject = clause . subjects != null
133
- ? multiplePhrasesAsNoun ( {
148
+ const useSubject = clause . subjects != null
149
+ ? subject ( {
134
150
phrases : clause . subjects ,
135
151
place : "subject" ,
136
152
includeGerund : true ,
@@ -148,7 +164,7 @@ function oClause(clause: TokiPona.Clause & { type: "o clause" }) {
148
164
prepositions : [ ] ,
149
165
emphasis : false ,
150
166
} ) ;
151
- return IterableResult . combine ( subject , predicate ( clause . predicates , "o" ) )
167
+ return IterableResult . combine ( useSubject , predicate ( clause . predicates , "o" ) )
152
168
. flatMap ( ( [ subject , predicate ] ) => {
153
169
const subjectPerspective = perspective ( subject ) ;
154
170
const subjectQuantity = quantity ( subject ) ;
0 commit comments