@@ -26,7 +26,12 @@ function fixNounPhrase(noun: English.NounPhrase): English.NounPhrase {
2626 case "compound" :
2727 return {
2828 ...noun ,
29- nouns : noun . nouns . map ( fixNounPhrase ) ,
29+ nouns : noun . nouns . flatMap ( ( item ) =>
30+ item . type === "compound" && item . conjunction === noun . conjunction
31+ ? item . nouns
32+ : [ item ]
33+ )
34+ . map ( fixNounPhrase ) ,
3035 } ;
3136 }
3237}
@@ -120,7 +125,14 @@ function fixAdjectivePhrase(
120125 case "compound" :
121126 return {
122127 ...adjective ,
123- adjectives : adjective . adjectives . map ( fixAdjectivePhrase ) ,
128+ adjectives : adjective . adjectives
129+ . flatMap ( ( item ) =>
130+ item . type === "compound" &&
131+ item . conjunction === adjective . conjunction
132+ ? item . adjectives
133+ : [ item ]
134+ )
135+ . map ( fixAdjectivePhrase ) ,
124136 } ;
125137 }
126138}
@@ -169,15 +181,42 @@ function fixMultipleAdverbs(adverbs: ReadonlyArray<English.Adverb>) {
169181 return adverbs ;
170182 }
171183}
184+ function filterGerundNoun ( noun : English . NounPhrase ) : void {
185+ switch ( noun . type ) {
186+ case "simple" :
187+ if ( noun . gerund ) {
188+ throw new FilteredError ( "continuous tense" ) ;
189+ }
190+ break ;
191+ case "compound" :
192+ noun . nouns . forEach ( filterGerundNoun ) ;
193+ break ;
194+ }
195+ }
196+ function filterGerundLikeAdjective ( adjective : English . AdjectivePhrase ) : void {
197+ switch ( adjective . type ) {
198+ case "simple" :
199+ if ( adjective . gerundLike ) {
200+ throw new FilteredError ( "continuous tense" ) ;
201+ }
202+ break ;
203+ case "compound" :
204+ adjective . adjectives . forEach ( filterGerundLikeAdjective ) ;
205+ break ;
206+ }
207+ }
172208function fixComplement ( complement : English . Complement ) : English . Complement {
173209 switch ( complement . type ) {
174- case "noun" :
175- return { type : "noun" , noun : fixNounPhrase ( complement . noun ) } ;
176- case "adjective" :
177- return {
178- type : "adjective" ,
179- adjective : fixAdjectivePhrase ( complement . adjective ) ,
180- } ;
210+ case "noun" : {
211+ const noun = fixNounPhrase ( complement . noun ) ;
212+ filterGerundNoun ( noun ) ;
213+ return { type : "noun" , noun } ;
214+ }
215+ case "adjective" : {
216+ const adjective = fixAdjectivePhrase ( complement . adjective ) ;
217+ filterGerundLikeAdjective ( adjective ) ;
218+ return { type : "adjective" , adjective } ;
219+ }
181220 }
182221}
183222function fixAdverbVerb ( adverbVerb : English . AdverbVerb ) : English . AdverbVerb {
@@ -189,7 +228,13 @@ function fixAdverbVerb(adverbVerb: English.AdverbVerb): English.AdverbVerb {
189228function fixMultipleVerb (
190229 verb : ReadonlyArray < English . AdverbVerb > ,
191230) : ReadonlyArray < English . AdverbVerb > {
192- return verb . map ( fixAdverbVerb ) ;
231+ const newVerb = verb . map ( fixAdverbVerb ) ;
232+ for ( const verb of newVerb . slice ( 1 ) ) {
233+ if ( verb . verb . type === "modal" ) {
234+ throw new FilteredError ( "modal verb after another verb" ) ;
235+ }
236+ }
237+ return newVerb ;
193238}
194239function fixVerbPhrase ( verb : English . VerbPhrase ) : English . VerbPhrase {
195240 switch ( verb . type ) {
0 commit comments