Skip to content

Commit

Permalink
HI Duration correction and synonyms addition (facebook#319)
Browse files Browse the repository at this point in the history
Summary:
Pakhwada (पखवाड़ा) is 15 days not a fortnight, corrected that logic and added new synonyms and rules for other time grains.
Pull Request resolved: facebook#319

Reviewed By: chinmay87

Differential Revision: D13785950

Pulled By: girifb

fbshipit-source-id: 2e38ac2f1486ca8891ca561c0cb87141f5bfc1cd
  • Loading branch information
VPanjeta authored and facebook-github-bot committed Jan 29, 2019
1 parent fc7f2c7 commit c306078
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Duckling/Duration/HI/Corpus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ allExamples = concat
, examples (DurationData 1 Day)
[ "दिवस"
, "एक दिन"
, "बिल्कुल एक दिन"
]
, examples (DurationData 14 Day)
[ "पखवाड़ा"
Expand All @@ -45,5 +46,7 @@ allExamples = concat
[ "एक साल"
, "केवल एक वर्ष"
, "लगभग एक साल"
, "एक बरस"
, "केवल एक साल"
]
]
8 changes: 6 additions & 2 deletions Duckling/Duration/HI/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,23 @@ import qualified Duckling.TimeGrain.Types as TG
avadhiMap :: HashMap Text TG.Grain
avadhiMap = HashMap.fromList
[ ("मिनट" , TG.Minute)
, ("क्षण", TG.Minute)
, ("घंटा" , TG.Hour)
, ("दिवस" , TG.Day)
, ("दिन" , TG.Day)
, ("महीना", TG.Month)
, ("माह", TG.Month)
, ("मास", TG.Month)
, ("वर्ष" , TG.Year)
, ("साल" , TG.Year)
, ("बरस", TG.Year)
]

ruleAadha :: Rule
ruleAadha = Rule
{ name = "half of a duration"
, pattern =
[ regex "आधा ((साल|वर्ष)|(महीना)|(दिन|दिवस)|(घंटा)|(मिनट))"
[ regex "आधा ((साल|वर्ष|बरस)|(महीना|मास|माह)|(दिन|दिवस)|(घंटा)|(मिनट|क्षण))"
]
, prod = \tokens -> case tokens of
(Token RegexMatch (GroupMatch (x:_)):_) -> do
Expand Down Expand Up @@ -85,7 +89,7 @@ ruleDurationEkSaal :: Rule
ruleDurationEkSaal = Rule
{ name = "one year"
, pattern =
[ regex "एक (साल|वर्ष)"
[ regex "एक (साल|वर्ष|बरस)"
]
, prod = \_ -> Just . Token Duration $ duration TG.Year 1
}
Expand Down

0 comments on commit c306078

Please sign in to comment.