Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Russian language support is extended for months and suffixes #722

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Duckling/Time/RU/Corpus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,15 @@ allExamples = concat
]
, examples (datetime (2013, 3, 0, 0, 0, 0) Month)
[ "март"
, "в марте"
]
, examples (datetime (2014, 10, 0, 0, 0, 0) Month)
[ "Октябрь 2014"
[ "Октябрь 2014",
"В октябре 2014"
]
, examples (datetime (2014, 11, 0, 0, 0, 0) Month)
[ "Ноябрь 2014"
[ "Ноябрь 2014",
"В ноябре 2014"
]
, examples (datetime (1974, 10, 31, 0, 0, 0) Day)
[ "31.10.1974"
Expand Down Expand Up @@ -506,6 +509,10 @@ allExamples = concat
, examples (datetime (2013, 10, 10, 0, 0, 0) Day)
[ "10.10.2013"
]
examples (datetime (2013, 10, 1, 0, 0, 0) Day)
[ "10.2013"
, "10/2013"
],
, examples (datetime (2013, 2, 12, 10, 10, 0) Minute)
[ "в 10:10"
]
Expand Down
51 changes: 40 additions & 11 deletions Duckling/Time/RU/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ ruleDaysOfWeek = mkRuleDaysOfWeek

ruleMonths :: [Rule]
ruleMonths = mkRuleMonths
[ ( "Январь" , "январ(ь|я)|янв\\.?" )
, ( "Февраль" , "феврал(ь|я)|фев\\.?" )
, ( "Март" , "март(а)?|мар\\.?" )
, ( "Апрель" , "апрел(ь|я)|апр\\.?" )
, ( "Май" , "ма(й|я)" )
, ( "Июнь" , "июн(ь|я)|июн\\.?" )
, ( "Июль" , "июл(ь|я)|июл\\.?" )
, ( "Август" , "август(а)?|авг\\.?" )
, ( "Сентябрь" , "сентябр(ь|я)|сен\\.?" )
, ( "Октябрь" , "октябр(ь|я)|окт\\.?" )
, ( "Ноябрь" , "ноябр(ь|я)?|ноя\\.?" )
[ ( "Январь" , "январ(ь|я)|янв\\.?" )
, ( "Февраль" , "феврал(ь|я|e)|фев\\.?" )
, ( "Март" , "март(а)?|мар\\.?" )
, ( "Апрель" , "апрел(ь|я)|апр\\.?" )
, ( "Май" , "ма(й|я)" )
, ( "Июнь" , "июн(ь|я)|июн\\.?" )
, ( "Июль" , "июл(ь|я)|июл\\.?" )
, ( "Август" , "август(а)?|авг\\.?" )
, ( "Сентябрь" , "сентябр(ь|я)|сен\\.?" )
, ( "Октябрь" , "октябр(ь|я)|окт\\.?" )
, ( "Ноябрь" , "ноябр(ь|я)?|ноя\\.?" )
, ( "Декабрь" , "декабр(ь|я)|дек\\.?" )
]

Expand Down Expand Up @@ -708,6 +708,20 @@ ruleYyyymmdd = Rule
_ -> Nothing
}

ruleMMYYYY :: Rule
ruleMMYYYY = Rule
{ name = "mm/yyyy"
, pattern =
[ regex "(0?[1-9]|1[0-2])[/-](\\d{4})"
]
, prod = \case
(Token RegexMatch (GroupMatch (mm:yy:_)):_) -> do
y <- parseInt yy
m <- parseInt mm
tt $ yearMonth y m
_ -> Nothing
}

ruleIntersectByOfFromS :: Rule
ruleIntersectByOfFromS = Rule
{ name = "intersect by 'of', 'from', 's"
Expand Down Expand Up @@ -1031,6 +1045,20 @@ ruleMmddyyyy = Rule
_ -> Nothing
}

ruleMmyyyy :: Rule
ruleMmyyyy = Rule
{ name = "mm/yyyy"
, pattern =
[ regex "([012]?[1-9]|10|20|30|31)\\.(\\d{2,4})"
]
, prod = \case
(Token RegexMatch (GroupMatch (m1:m2:m3:_)):_) -> do
y <- parseInt m3
m <- parseInt m2
tt $ yearMonth y m
_ -> Nothing
}

ruleTimeofdayOclock :: Rule
ruleTimeofdayOclock = Rule
{ name = "<time-of-day> o'clock"
Expand Down Expand Up @@ -1148,6 +1176,7 @@ rules =
, ruleYearLatent
, ruleYearLatent2
, ruleYyyymmdd
, ruleMMYYYY
, ruleTimezone
]
++ ruleInstants
Expand Down