Skip to content

Commit

Permalink
Update rules to allow more variation for MonthDDDD intervals. (#271)
Browse files Browse the repository at this point in the history
Summary:
Fixes [#218](#218)

**Note:** This is still a work in progress. But, I'm new to both Haskell and this repo and I seem to be stuck. Would appreciate feedback on what I've done so far. Thank you!
Pull Request resolved: #271

Reviewed By: chinmay87

Differential Revision: D13087476

Pulled By: patapizza

fbshipit-source-id: 2dee0d023794265bd791ae0bbc0e2e2b89ea1959
  • Loading branch information
MorrisLaw authored and facebook-github-bot committed Nov 17, 2018
1 parent 39a6a4c commit 4bee268
Show file tree
Hide file tree
Showing 15 changed files with 9,599 additions and 8,080 deletions.
1,344 changes: 729 additions & 615 deletions Duckling/Ranking/Classifiers/EN_AU.hs

Large diffs are not rendered by default.

1,344 changes: 729 additions & 615 deletions Duckling/Ranking/Classifiers/EN_BZ.hs

Large diffs are not rendered by default.

1,382 changes: 748 additions & 634 deletions Duckling/Ranking/Classifiers/EN_CA.hs

Large diffs are not rendered by default.

1,380 changes: 746 additions & 634 deletions Duckling/Ranking/Classifiers/EN_GB.hs

Large diffs are not rendered by default.

1,344 changes: 729 additions & 615 deletions Duckling/Ranking/Classifiers/EN_IE.hs

Large diffs are not rendered by default.

1,344 changes: 729 additions & 615 deletions Duckling/Ranking/Classifiers/EN_IN.hs

Large diffs are not rendered by default.

1,344 changes: 729 additions & 615 deletions Duckling/Ranking/Classifiers/EN_JM.hs

Large diffs are not rendered by default.

1,344 changes: 729 additions & 615 deletions Duckling/Ranking/Classifiers/EN_NZ.hs

Large diffs are not rendered by default.

1,344 changes: 729 additions & 615 deletions Duckling/Ranking/Classifiers/EN_PH.hs

Large diffs are not rendered by default.

1,344 changes: 729 additions & 615 deletions Duckling/Ranking/Classifiers/EN_TT.hs

Large diffs are not rendered by default.

1,401 changes: 754 additions & 647 deletions Duckling/Ranking/Classifiers/EN_US.hs

Large diffs are not rendered by default.

1,366 changes: 740 additions & 626 deletions Duckling/Ranking/Classifiers/EN_XX.hs

Large diffs are not rendered by default.

1,344 changes: 729 additions & 615 deletions Duckling/Ranking/Classifiers/EN_ZA.hs

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion Duckling/Time/EN/Corpus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -955,9 +955,29 @@ allExamples = concat
, "July 13 thru 15"
, "July 13 through 15"
, "July 13 - July 15"
, "from July 13-15"
]
, examples (datetimeInterval ((2013, 7, 13, 0, 0, 0), (2013, 7, 16, 0, 0, 0)) Day)
[ "from July 13-15"
, "from 13 to 15 July"
, "from 13th to 15th July"
, "from the 13 to 15 July"
, "from the 13th to 15th July"
, "from the 13th to the 15th July"
, "from the 13 to the 15 July"
]
, examples (datetimeInterval ((2013, 7, 13, 0, 0, 0), (2013, 7, 16, 0, 0, 0)) Day)
[ "from 13 to 15 of July"
, "from 13th to 15 of July"
, "from 13 to 15th of July"
, "from 13th to 15th of July"
, "from 13 to the 15 of July"
, "from 13th to the 15 of July"
, "from 13 to the 15th of July"
, "from 13th to the 15th of July"
, "from the 13 to the 15 of July"
, "from the 13th to the 15 of July"
, "from the 13 to the 15th of July"
, "from the 13th to the 15th of July"
]
, examples (datetimeInterval ((2013, 8, 8, 0, 0, 0), (2013, 8, 13, 0, 0, 0)) Day)
[ "Aug 8 - Aug 12"
Expand Down
32 changes: 29 additions & 3 deletions Duckling/Time/EN/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,19 +1097,44 @@ ruleIntervalFromMonthDDDD = Rule

ruleIntervalFromDDDDMonth :: Rule
ruleIntervalFromDDDDMonth = Rule
{ name = "from <day-of-month> (ordinal or number) to <day-of-month> (ordinal or number) <named-month> (interval)"
{ name = "from the <day-of-month> (ordinal or number) to the <day-of-month> (ordinal or number) <named-month> (interval)"
, pattern =
[ regex "from"
[ regex "from( the)?"
, Predicate isDOMValue
, regex "\\-|to|th?ru|through|(un)?til(l)?"
, regex "\\-|to( the)?|th?ru|through|(un)?til(l)?"
, Predicate isDOMValue
, Predicate isAMonth
]
, prod = \tokens -> case tokens of
(_:
token1:
_:
token2:
Token Time td:
_) -> do
dom1 <- intersectDOM td token1
dom2 <- intersectDOM td token2
Token Time <$> interval TTime.Closed dom1 dom2
_ -> Nothing
}

ruleIntervalFromDDDDOfMonth :: Rule
ruleIntervalFromDDDDOfMonth = Rule
{ name = "from the <day-of-month> (ordinal or number) to the <day-of-month> (ordinal or number) of <named-month> (interval)"
, pattern =
[ regex "from( the)?"
, Predicate isDOMValue
, regex "\\-|to( the)?|th?ru|through|(un)?til(l)?"
, Predicate isDOMValue
, regex "of"
, Predicate isAMonth
]
, prod = \tokens -> case tokens of
(_:
token1:
_:
token2:
_:
Token Time td:
_) -> do
dom1 <- intersectDOM td token1
Expand Down Expand Up @@ -2404,6 +2429,7 @@ rules =
, rulePrecisionTOD
, ruleIntervalFromMonthDDDD
, ruleIntervalFromDDDDMonth
, ruleIntervalFromDDDDOfMonth
, ruleIntervalMonthDDDD
, ruleIntervalDDDDMonth
, ruleIntervalDash
Expand Down

0 comments on commit 4bee268

Please sign in to comment.