diff --git a/Duckling/Numeral/RU/Corpus.hs b/Duckling/Numeral/RU/Corpus.hs index c567536d..ebe69656 100644 --- a/Duckling/Numeral/RU/Corpus.hs +++ b/Duckling/Numeral/RU/Corpus.hs @@ -41,6 +41,7 @@ allExamples = concat [ "3" , "три" , "03" + , "трех" ] , examples (NumeralValue 4) [ "4" diff --git a/Duckling/Numeral/RU/Rules.hs b/Duckling/Numeral/RU/Rules.hs index 26943a04..d196f835 100644 --- a/Duckling/Numeral/RU/Rules.hs +++ b/Duckling/Numeral/RU/Rules.hs @@ -232,6 +232,27 @@ threeToNineteenMap = HashMap.fromList , ( "девятнадцать", 19) ] +threeToNineteenMapGenitive :: HashMap Text Integer +threeToNineteenMapGenitive = HashMap.fromList + [ ( "трех", 3) + , ( "четырех", 4) + , ( "пяти", 5) + , ( "шести", 6) + , ( "семи", 7) + , ( "восьми", 8) + , ( "девяти", 9) + , ( "десяти", 10) + , ( "одиннадцати", 11) + , ( "двенадцати", 12) + , ( "тринадцати", 13) + , ( "четырнадцати", 14) + , ( "пятнадцати", 15) + , ( "шестнадцати", 16) + , ( "семнадцати", 17) + , ( "восемнадцати", 18) + , ( "девятнадцати", 19) + ] + ruleInteger4 :: Rule ruleInteger4 = Rule { name = "integer (3..19)" @@ -244,6 +265,18 @@ ruleInteger4 = Rule _ -> Nothing } +ruleInteger4Genitive :: Rule +ruleInteger4Genitive = Rule + { name = "integer (3..19)" + , pattern = + [ regex "(трех|четырнадцати|четырех|пятнадцати|пяти|шестнадцати|шести|семнадцати|семи|восемнадцати|восьми|девятнадцати|девяти|десяти|одиннадцати|двенадцати|тринадцати)" + ] + , prod = \tokens -> case tokens of + (Token RegexMatch (GroupMatch (match:_)):_) -> + HashMap.lookup (Text.toLower match) threeToNineteenMapGenitive >>= integer + _ -> Nothing + } + ruleInteger2 :: Rule ruleInteger2 = Rule { name = "integer 1" @@ -287,6 +320,7 @@ rules = , ruleInteger2 , ruleInteger3 , ruleInteger4 + , ruleInteger4Genitive , ruleInteger5 , ruleInteger6 , ruleInteger7 diff --git a/Duckling/Ordinal/RU/Rules.hs b/Duckling/Ordinal/RU/Rules.hs index ac429dbb..3a4f846d 100644 --- a/Duckling/Ordinal/RU/Rules.hs +++ b/Duckling/Ordinal/RU/Rules.hs @@ -37,7 +37,7 @@ ordinalsFirstthMap = HashMap.fromList , ( "восьм", 8 ) , ( "девят", 9 ) , ( "десят", 10 ) - , ( "одинадцат", 11 ) + , ( "одиннадцат", 11 ) , ( "двенадцат", 12 ) , ( "тринадцат", 13 ) , ( "четырнадцат", 14 ) @@ -65,7 +65,7 @@ ruleOrdinalsFirstth :: Rule ruleOrdinalsFirstth = Rule { name = "ordinals (first..19th)" , pattern = - [ regex "(перв|втор|трет|четверт|пят|шест|седьм|восьм|девят|десят|одинадцат|двенадцат|тринадцат|четырнадцат|пятнадцат|шестнадцат|семнадцат|восемнадцат|девятнадцат|двадцат)(ье(го|й)?|ого|ый|ой|ий|ая|ое|ья)" + [ regex "(перв|втор|трет|четверт|пят|шест|седьм|восьм|девят|десят|одиннадцат|двенадцат|тринадцат|четырнадцат|пятнадцат|шестнадцат|семнадцат|восемнадцат|девятнадцат|двадцат)(ье(го|й)?|ого|ый|ой|ий|ая|ое|ья)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (match:_)):_) ->