File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,14 @@ import * as English from "./ast.ts";
4
4
import { encodeDeterminer } from "./determiner.ts" ;
5
5
import { FilteredError } from "./error.ts" ;
6
6
7
+ function rankNoun ( noun : English . NounPhrase ) : number {
8
+ switch ( noun . type ) {
9
+ case "simple" :
10
+ return [ "third" , "second" , "first" ] . indexOf ( noun . perspective ) ;
11
+ case "compound" :
12
+ return rankNoun ( noun . nouns [ 0 ] ) ;
13
+ }
14
+ }
7
15
function fixNounPhrase ( noun : English . NounPhrase ) : English . NounPhrase {
8
16
switch ( noun . type ) {
9
17
case "simple" :
@@ -15,7 +23,12 @@ function fixNounPhrase(noun: English.NounPhrase): English.NounPhrase {
15
23
prepositions : noun . prepositions . map ( fixPreposition ) ,
16
24
} ;
17
25
case "compound" :
18
- return { ...noun , nouns : noun . nouns . map ( fixNounPhrase ) } ;
26
+ return {
27
+ ...noun ,
28
+ nouns : noun . nouns
29
+ . map ( fixNounPhrase )
30
+ . sort ( ( a , b ) => rankNoun ( a ) - rankNoun ( b ) ) ,
31
+ } ;
19
32
}
20
33
}
21
34
function filterKind (
You can’t perform that action at this time.
0 commit comments