@@ -28,34 +28,34 @@ export const WORD_UNIT_RULES: ReadonlyArray<(wordUnit: WordUnit) => boolean> = [
28
28
] ;
29
29
export const NANPA_RULES : ReadonlyArray < ( nanpa : Nanpa ) => boolean > = [
30
30
// disallow "nanpa ala nanpa"
31
- ( modifier ) =>
32
- modifier . nanpa . type !== "x ala x" ||
31
+ ( { nanpa : { type } } ) =>
32
+ type !== "x ala x" ||
33
33
throwError ( new UnrecognizedError ( '"nanpa ala nanpa"' ) ) ,
34
34
35
35
// nanpa construction cannot contain preposition
36
- ( modifier ) =>
37
- modifier . phrase . type !== "preposition" ||
36
+ ( { phrase : { type } } ) =>
37
+ type !== "preposition" ||
38
38
throwError ( new UnrecognizedError ( "preposition inside nanpa" ) ) ,
39
39
40
40
// nanpa construction cannot contain preverb
41
- ( modifier ) =>
42
- modifier . phrase . type !== "preverb" ||
41
+ ( { phrase : { type } } ) =>
42
+ type !== "preverb" ||
43
43
throwError ( new UnrecognizedError ( "preverb inside nanpa" ) ) ,
44
44
45
45
// nanpa construction cannot contain pi
46
- ( modifier ) =>
47
- modifier . phrase . type !== "default" ||
48
- modifier . phrase . modifiers . every ( ( modifier ) => modifier . type !== "pi" ) ||
46
+ ( { phrase } ) =>
47
+ phrase . type !== "default" ||
48
+ phrase . modifiers . every ( ( { type } ) => type !== "pi" ) ||
49
49
throwError ( new UnrecognizedError ( "pi inside nanpa" ) ) ,
50
50
51
51
// nanpa construction cannot contain nanpa
52
- ( modifier ) =>
53
- modifier . phrase . type !== "default" ||
54
- modifier . phrase . modifiers . every ( ( modifier ) => modifier . type !== "nanpa" ) ||
52
+ ( { phrase } ) =>
53
+ phrase . type !== "default" ||
54
+ phrase . modifiers . every ( ( { type } ) => type !== "nanpa" ) ||
55
55
throwError ( new UnrecognizedError ( "nanpa inside nanpa" ) ) ,
56
56
57
57
// nanpa cannot have emphasis particle
58
- ( modifier ) => modifier . phrase . emphasis == null ,
58
+ ( { phrase : { emphasis } } ) => emphasis == null ,
59
59
] ;
60
60
export const MODIFIER_RULES : ReadonlyArray < ( modifier : Modifier ) => boolean > = [
61
61
// pi cannot contain preposition
@@ -101,18 +101,18 @@ export const MULTIPLE_MODIFIERS_RULES: ReadonlyArray<
101
101
> = [
102
102
// // no multiple pi
103
103
// (modifiers) =>
104
- // modifiers.filter((modifier ) => modifier. type === "pi").length <= 1 ||
104
+ // modifiers.filter(({type} ) => type === "pi").length <= 1 ||
105
105
// throwError(new UnrecognizedError("multiple pi")),
106
106
107
107
// no multiple nanpa
108
108
( modifiers ) =>
109
- modifiers . filter ( ( modifier ) => modifier . type === "nanpa" ) . length <= 1 ||
109
+ modifiers . filter ( ( { type } ) => type === "nanpa" ) . length <= 1 ||
110
110
throwError ( new UnrecognizedError ( "multiple nanpa" ) ) ,
111
111
112
112
// no multiple proper words
113
113
( modifiers ) =>
114
114
modifiers
115
- . filter ( ( modifier ) => modifier . type === "proper words" )
115
+ . filter ( ( { type } ) => type === "proper words" )
116
116
. length <= 1 ||
117
117
throwError ( new UnrecognizedError ( "multiple proper words" ) ) ,
118
118
@@ -188,7 +188,7 @@ export const PHRASE_RULE: ReadonlyArray<(phrase: Phrase) => boolean> = [
188
188
if (
189
189
phrase . emphasis == null ||
190
190
everyWordUnitInPhrase ( phrase )
191
- . every ( ( wordUnit ) => wordUnit . emphasis == null )
191
+ . every ( ( { emphasis } ) => emphasis == null )
192
192
) {
193
193
return true ;
194
194
} else {
@@ -224,7 +224,7 @@ export const PREPOSITION_RULE: ReadonlyArray<(phrase: Preposition) => boolean> =
224
224
( preposition ) =>
225
225
preposition . emphasis == null ||
226
226
everyWordUnitInPreposition ( preposition )
227
- . every ( ( wordUnit ) => wordUnit . emphasis == null ) ||
227
+ . every ( ( { emphasis } ) => emphasis == null ) ||
228
228
throwError ( new UnrecognizedError ( "nested emphasis" ) ) ,
229
229
] ;
230
230
export const CLAUSE_RULE : ReadonlyArray < ( clause : Clause ) => boolean > = [
@@ -320,7 +320,7 @@ export const SENTENCE_RULE: ReadonlyArray<(sentence: Sentence) => boolean> = [
320
320
321
321
// There can't be more than 1 "x ala x" or "seme"
322
322
( sentence ) => {
323
- if ( sentence . interrogative ) {
323
+ if ( sentence . interrogative != null ) {
324
324
const interrogative = everyWordUnitInSentence ( sentence )
325
325
. filter ( ( wordUnit ) => {
326
326
switch ( wordUnit . type ) {
@@ -347,7 +347,7 @@ export const MULTIPLE_SENTENCES_RULE: ReadonlyArray<
347
347
> = [
348
348
// Only allow at most 2 sentences
349
349
( sentences ) =>
350
- sentences . filter ( ( sentence ) => sentence . type !== "filler" ) . length <= 2 ||
350
+ sentences . filter ( ( { type } ) => type !== "filler" ) . length <= 2 ||
351
351
throwError ( new UnrecognizedError ( "multiple sentences" ) ) ,
352
352
] ;
353
353
export function filter < T > (
0 commit comments