Skip to content

Commit

Permalink
ES time improvements (#634)
Browse files Browse the repository at this point in the history
Summary:
New rules for ES time expressions like "3 Marzo", "Marzo 3.

Pull Request resolved: #634

Reviewed By: girifb

Differential Revision: D30110631

Pulled By: chessai

fbshipit-source-id: e6add868535522d243ccf1dab2443e6cd3f7f8b2
  • Loading branch information
fil090302 authored and facebook-github-bot committed Aug 5, 2021
1 parent a649922 commit fc7950a
Show file tree
Hide file tree
Showing 10 changed files with 874 additions and 689 deletions.
191 changes: 106 additions & 85 deletions Duckling/Ranking/Classifiers/ES_AR.hs

Large diffs are not rendered by default.

191 changes: 106 additions & 85 deletions Duckling/Ranking/Classifiers/ES_CL.hs

Large diffs are not rendered by default.

191 changes: 106 additions & 85 deletions Duckling/Ranking/Classifiers/ES_CO.hs

Large diffs are not rendered by default.

191 changes: 106 additions & 85 deletions Duckling/Ranking/Classifiers/ES_ES.hs

Large diffs are not rendered by default.

191 changes: 106 additions & 85 deletions Duckling/Ranking/Classifiers/ES_MX.hs

Large diffs are not rendered by default.

191 changes: 106 additions & 85 deletions Duckling/Ranking/Classifiers/ES_PE.hs

Large diffs are not rendered by default.

191 changes: 106 additions & 85 deletions Duckling/Ranking/Classifiers/ES_VE.hs

Large diffs are not rendered by default.

191 changes: 106 additions & 85 deletions Duckling/Ranking/Classifiers/ES_XX.hs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Duckling/Time/ES/Corpus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,15 @@ allExamples = concat
, examples (datetime (2013, 3, 3, 0, 0, 0) Day)
[ "el 3 de marzo"
, "3 de marzo"
, "3 marzo"
, "marzo 3"
, "el 3-3"
]
, examples (datetime (2013, 4, 5, 0, 0, 0) Day)
[ "el 5 de abril"
, "5 de abril"
, "5 abril"
, "abril 5"
]
, examples (datetime (2013, 3, 1, 0, 0, 0) Day)
[ "el 1 de marzo"
Expand Down
31 changes: 22 additions & 9 deletions Duckling/Time/ES/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,19 +1038,31 @@ ruleTimeofdayAmpm = Rule
_ -> Nothing
}

ruleDayofmonthDeNamedmonth :: Rule
ruleDayofmonthDeNamedmonth = Rule
{ name = "<day-of-month> de <named-month>"
ruleDOMOfMonth :: Rule
ruleDOMOfMonth = Rule
{ name = "<day-of-month> (ordinal or number) de <named-month>"
, pattern =
[ Predicate isDOMInteger
[ Predicate isDOMValue
, regex "de"
, Predicate isAMonth
]
, prod = \tokens -> case tokens of
, prod = \case
(token:_:Token Time td:_) -> Token Time <$> intersectDOM td token
_ -> Nothing
}

ruleDOMMonth :: Rule
ruleDOMMonth = Rule
{ name = "<day-of-month> (ordinal or number) <named-month>"
, pattern =
[ Predicate isDOMValue
, Predicate isAMonth
]
, prod = \case
(token:Token Time td:_) -> Token Time <$> intersectDOM td token
_ -> Nothing
}

ruleEntreDdEtDdMonthinterval :: Rule
ruleEntreDdEtDdMonthinterval = Rule
{ name = "entre dd et dd <month>(interval)"
Expand Down Expand Up @@ -1078,8 +1090,8 @@ ruleEntreDdEtDdMonthinterval = Rule
_ -> Nothing
}

ruleNamedmonthDayofmonth :: Rule
ruleNamedmonthDayofmonth = Rule
ruleMonthDOM :: Rule
ruleMonthDOM = Rule
{ name = "<named-month> <day-of-month>"
, pattern =
[ Predicate isAMonth
Expand Down Expand Up @@ -1566,7 +1578,6 @@ rules =
, ruleCeTime
, ruleDatetimeDatetimeInterval
, ruleDayOfMonthSt
, ruleDayofmonthDeNamedmonth
, ruleDayofweekDayofmonth
, ruleDdddMonthinterval
, ruleDdmm
Expand All @@ -1578,6 +1589,8 @@ rules =
, ruleDimTimeDeLaManana
, ruleDimTimeDeLaTarde
, ruleDimTimeDeLaTarde2
, ruleDOMOfMonth
, ruleDOMMonth
, ruleElCycleAntesTime
, ruleElCycleProximoqueViene
, ruleElCycleProximoqueVieneTime
Expand All @@ -1602,11 +1615,11 @@ rules =
, ruleLaCyclePasado
, ruleLaPasadoCycle
, ruleMidnight
, ruleMonthDOM
, ruleMorning
, ruleNCycleProximoqueViene
, ruleNPasadosCycle
, ruleNProximasCycle
, ruleNamedmonthDayofmonth
, ruleNamedmonthnameddayNext
, ruleNamedmonthnameddayPast
, ruleNavidad
Expand Down

0 comments on commit fc7950a

Please sign in to comment.