File tree Expand file tree Collapse file tree 7 files changed +28
-17
lines changed Expand file tree Collapse file tree 7 files changed +28
-17
lines changed Original file line number Diff line number Diff line change @@ -80,11 +80,12 @@ export type Clause =
80
80
> ;
81
81
export type ContextClause =
82
82
| Clause
83
- | ( Readonly < { type : "nanpa" } > & Nanpa ) ;
83
+ | ( Readonly < { type : "nanpa" } > & Nanpa )
84
+ | ( Readonly < { type : "anu" ; anu : HeadedWordUnit } > ) ;
84
85
export type Sentence =
85
86
| Readonly < {
86
87
type : "default" ;
87
- kinOrTaso : null | HeadedWordUnit ;
88
+ startingParticle : null | HeadedWordUnit ;
88
89
laClauses : ReadonlyArray < ContextClause > ;
89
90
finalClause : Clause ;
90
91
anuSeme : null | HeadedWordUnit ;
Original file line number Diff line number Diff line change @@ -176,6 +176,8 @@ export function contextClause(contextClause: ContextClause): string {
176
176
switch ( contextClause . type ) {
177
177
case "nanpa" :
178
178
return nanpa ( contextClause ) ;
179
+ case "anu" :
180
+ return wordUnit ( contextClause . anu ) ;
179
181
default :
180
182
return clause ( contextClause ) ;
181
183
}
@@ -185,7 +187,7 @@ export function sentence(sentence: Sentence): string {
185
187
switch ( sentence . type ) {
186
188
case "default" :
187
189
text = [
188
- ...nullableAsArray ( sentence . kinOrTaso ) . map ( wordUnit ) ,
190
+ ...nullableAsArray ( sentence . startingParticle ) . map ( wordUnit ) ,
189
191
...sentence . laClauses
190
192
. map ( contextClause )
191
193
. map ( ( clause ) => `${ clause } la` ) ,
Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ export function everyWordUnitInContextClause(
104
104
switch ( contextClause . type ) {
105
105
case "nanpa" :
106
106
return everyWordUnitInNanpa ( contextClause ) ;
107
+ case "anu" :
108
+ return [ contextClause . anu ] ;
107
109
default :
108
110
return everyWordUnitInClause ( contextClause ) ;
109
111
}
@@ -114,7 +116,7 @@ export function everyWordUnitInSentence(
114
116
switch ( sentence . type ) {
115
117
case "default" :
116
118
return [
117
- ...nullableAsArray ( sentence . kinOrTaso ) ,
119
+ ...nullableAsArray ( sentence . startingParticle ) ,
118
120
...sentence . laClauses . flatMap ( everyWordUnitInContextClause ) ,
119
121
...everyWordUnitInClause ( sentence . finalClause ) ,
120
122
...nullableAsArray ( sentence . anuSeme ) ,
Original file line number Diff line number Diff line change @@ -301,20 +301,21 @@ export const SENTENCE_RULE: ReadonlyArray<(sentence: Sentence) => boolean> = [
301
301
( sentence ) => {
302
302
if ( sentence . type === "default" ) {
303
303
if (
304
- sentence . kinOrTaso != null && sentence . kinOrTaso . type === "x ala x"
304
+ sentence . startingParticle != null &&
305
+ sentence . startingParticle . type === "x ala x"
305
306
) {
306
- const { kinOrTaso : { word } } = sentence ;
307
+ const { startingParticle : { word } } = sentence ;
307
308
throw new UnrecognizedError ( `"${ word } ala ${ word } "` ) ;
308
309
}
309
310
}
310
311
return true ;
311
312
} ,
312
- // If there is "la", there can't be "taso" or "kin"
313
+ // If there is "la", there can't be starting particle e.g. taso
313
314
( sentence ) =>
314
315
sentence . type !== "default" || sentence . laClauses . length === 0 ||
315
- sentence . kinOrTaso == null || throwError (
316
+ sentence . startingParticle == null || throwError (
316
317
new UnrecognizedError (
317
- `${ sentence . kinOrTaso . word } particle with "la"` ,
318
+ `${ sentence . startingParticle . word } particle with "la"` ,
318
319
) ,
319
320
) ,
320
321
Original file line number Diff line number Diff line change @@ -605,6 +605,7 @@ const clause = choice<Clause>(
605
605
. filter ( filter ( CLAUSE_RULE ) ) ;
606
606
const contextClause = choice < ContextClause > (
607
607
nanpa . map ( ( nanpa ) => ( { ...nanpa , type : "nanpa" } ) ) ,
608
+ wordUnit ( new Set ( [ "anu" ] ) , '"anu"' ) . map ( ( anu ) => ( { type : "anu" , anu } ) ) ,
608
609
clause ,
609
610
) ;
610
611
const la = choice (
@@ -652,7 +653,8 @@ const anuSeme = choice(
652
653
const sentence = choice < Sentence > (
653
654
sequence (
654
655
optional (
655
- wordUnit ( new Set ( [ "kin" , "taso" ] ) , "taso/kin" ) . skip ( optionalComma ) ,
656
+ wordUnit ( new Set ( [ "taso" , "kin" , "anu" ] ) , "taso/kin/anu" )
657
+ . skip ( optionalComma ) ,
656
658
) ,
657
659
many ( contextClause . skip ( la ) ) ,
658
660
clause ,
@@ -668,7 +670,7 @@ const sentence = choice<Sentence>(
668
670
. map < Sentence & { type : "default" } > (
669
671
(
670
672
[
671
- kinOrTaso ,
673
+ startingParticle ,
672
674
laClauses ,
673
675
finalClause ,
674
676
anuSeme ,
@@ -678,7 +680,7 @@ const sentence = choice<Sentence>(
678
680
) => {
679
681
const sentence : Sentence & { type : "default" } = {
680
682
type : "default" ,
681
- kinOrTaso ,
683
+ startingParticle ,
682
684
laClauses,
683
685
finalClause,
684
686
anuSeme,
Original file line number Diff line number Diff line change @@ -209,7 +209,10 @@ export function contextClause(
209
209
) : ArrayResult < English . Clause > {
210
210
switch ( contextClause . type ) {
211
211
case "nanpa" :
212
- return new ArrayResult ( new TranslationTodoError ( "nanpa context clause" ) ) ;
212
+ case "anu" :
213
+ return new ArrayResult (
214
+ new TranslationTodoError ( `${ contextClause . type } context clause` ) ,
215
+ ) ;
213
216
default :
214
217
return clause ( contextClause ) ;
215
218
}
Original file line number Diff line number Diff line change @@ -144,18 +144,18 @@ function sentence(
144
144
clause,
145
145
} ) )
146
146
) ;
147
- if ( sentence . kinOrTaso != null ) {
147
+ if ( sentence . startingParticle != null ) {
148
148
return new ArrayResult (
149
149
new TranslationTodoError (
150
- `"${ sentence . kinOrTaso . word } " starting particle` ,
150
+ `"${ sentence . startingParticle . word } " starting particle` ,
151
151
) ,
152
152
) ;
153
153
}
154
154
const lastEngClause = clause ( sentence . finalClause ) ;
155
155
const right = nullableAsArray ( sentence . anuSeme ) . map ( anuSeme ) ;
156
156
const interjectionClause =
157
- sentence . laClauses . length === 0 && sentence . kinOrTaso == null &&
158
- sentence . kinOrTaso == null
157
+ sentence . laClauses . length === 0 && sentence . startingParticle == null &&
158
+ sentence . startingParticle == null
159
159
? interjection ( sentence . finalClause )
160
160
: new ArrayResult < English . Clause > ( ) ;
161
161
const engClauses = ArrayResult . combine (
You can’t perform that action at this time.
0 commit comments