File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { flattenError, throwError } from "../../misc/misc.ts";
3
3
import { settings } from "../settings.ts" ;
4
4
import {
5
5
Clause ,
6
+ ContextClause ,
6
7
Modifier ,
7
8
MultiplePhrases ,
8
9
Nanpa ,
@@ -227,6 +228,14 @@ export const PREPOSITION_RULE: ReadonlyArray<(phrase: Preposition) => boolean> =
227
228
. every ( ( { emphasis } ) => emphasis == null ) ||
228
229
throwError ( new UnrecognizedError ( "nested emphasis" ) ) ,
229
230
] ;
231
+ export const CONTEXT_CLAUSE_RULE : ReadonlyArray <
232
+ ( contextClause : ContextClause ) => boolean
233
+ > = [
234
+ // Prevent "anu ala anu la"
235
+ ( clause ) =>
236
+ clause . type !== "anu" || clause . anu . type !== "x ala x" ||
237
+ throwError ( new UnrecognizedError ( '"anu ala anu la"' ) ) ,
238
+ ] ;
230
239
export const CLAUSE_RULE : ReadonlyArray < ( clause : Clause ) => boolean > = [
231
240
// disallow preposition in subject
232
241
( clause ) => {
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import { cache } from "./cache.ts";
29
29
import { everyWordUnitInSentence } from "./extract.ts" ;
30
30
import {
31
31
CLAUSE_RULE ,
32
+ CONTEXT_CLAUSE_RULE ,
32
33
filter ,
33
34
MODIFIER_RULES ,
34
35
MULTIPLE_MODIFIERS_RULES ,
@@ -607,7 +608,8 @@ const contextClause = choice<ContextClause>(
607
608
nanpa . map ( ( nanpa ) => ( { ...nanpa , type : "nanpa" } ) ) ,
608
609
wordUnit ( new Set ( [ "anu" ] ) , '"anu"' ) . map ( ( anu ) => ( { type : "anu" , anu } ) ) ,
609
610
clause ,
610
- ) ;
611
+ )
612
+ . filter ( filter ( CONTEXT_CLAUSE_RULE ) ) ;
611
613
const la = choice (
612
614
comma . with ( specificWord ( "la" ) ) ,
613
615
specificWord ( "la" ) . skip ( comma ) ,
You can’t perform that action at this time.
0 commit comments