mirror of
https://github.com/facebook/duckling.git
synced 2024-09-11 21:27:13 +03:00
forward factor parse tree for exploit in T85548324
Summary: due to exploit in T85548324, factoring the input to get a smaller parse tree (the existing one parses tail recursively, whereas this one uses ruleIntersect which is still bad, but slightly better). Differential Revision: D26657170 fbshipit-source-id: fe3a738073b4d30ae401521bb692f4a4bba48d96
This commit is contained in:
parent
37b671389c
commit
f68ebf808a
@ -2258,6 +2258,21 @@ ruleCycleTheLastOrdinalOfTime = Rule
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleCycleTheOfTimeGrain :: Rule
|
||||
ruleCycleTheOfTimeGrain = Rule
|
||||
{ name = "the <cycle> of the <time grain>"
|
||||
, pattern =
|
||||
[ regex "the"
|
||||
, dimension TimeGrain
|
||||
, regex "of( the)?"
|
||||
, dimension TimeGrain
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(_:Token TimeGrain grain:_:Token TimeGrain time:_) ->
|
||||
tt $ cycleNthAfter True grain 0 $ cycleNth time 0
|
||||
_ -> Nothing
|
||||
}
|
||||
|
||||
ruleCycleTheOfTime :: Rule
|
||||
ruleCycleTheOfTime = Rule
|
||||
{ name = "the <cycle> of <time>"
|
||||
@ -2753,6 +2768,7 @@ rules =
|
||||
, ruleCycleLastOrdinalOfTime
|
||||
, ruleCycleTheOrdinalOfTime
|
||||
, ruleCycleTheLastOrdinalOfTime
|
||||
, ruleCycleTheOfTimeGrain
|
||||
, ruleCycleTheOfTime
|
||||
, ruleCycleOrdinalAfterTime
|
||||
, ruleCycleTheOrdinalAfterTime
|
||||
|
Loading…
Reference in New Issue
Block a user