From a0cd87390982518b87067011f191b04318176be0 Mon Sep 17 00:00:00 2001 From: souvik ghosh Date: Wed, 18 Oct 2023 11:35:57 +0200 Subject: [PATCH 1/2] rebase to original fork --- Duckling/Numeral/DE/Corpus.hs | 5 +++++ Duckling/Numeral/DE/NumParser.hs | 6 +++++- Duckling/Numeral/DE/Rules.hs | 11 ++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Duckling/Numeral/DE/Corpus.hs b/Duckling/Numeral/DE/Corpus.hs index 69b03132a..8b1097363 100644 --- a/Duckling/Numeral/DE/Corpus.hs +++ b/Duckling/Numeral/DE/Corpus.hs @@ -36,6 +36,11 @@ allExamples = concat , "Eine" , "einen" ] + , examples (NumeralValue 2) + [ "2" + , "Zwei" + , "Zwo" + ] , examples (NumeralValue 3) [ "3" , "Drei" diff --git a/Duckling/Numeral/DE/NumParser.hs b/Duckling/Numeral/DE/NumParser.hs index 4e3762d42..8d2729452 100644 --- a/Duckling/Numeral/DE/NumParser.hs +++ b/Duckling/Numeral/DE/NumParser.hs @@ -103,6 +103,10 @@ two = , times10 = [assign 20 "zwanzig"] } +two_alternative :: NumItem +two_alternative = defaultNumItem 2 "zwo" + + three :: NumItem three = (defaultNumItem 3 "drei") @@ -139,7 +143,7 @@ nine :: NumItem nine = defaultNumItem 9 "neun" digitLexicon :: [NumItem] -digitLexicon = [one, two, three, four, five, six, seven, eight, nine] +digitLexicon = [one, two_alternative, two, three, four, five, six, seven, eight, nine] from1to9 :: NumParser from1to9 = foldr ((<|>) . base) empty digitLexicon diff --git a/Duckling/Numeral/DE/Rules.hs b/Duckling/Numeral/DE/Rules.hs index 79553595d..ea937a7b8 100644 --- a/Duckling/Numeral/DE/Rules.hs +++ b/Duckling/Numeral/DE/Rules.hs @@ -76,6 +76,15 @@ ruleDecimalNumeral = Rule _ -> Nothing } +ruleTwo :: Rule +ruleTwo = Rule + { name = "integer 2" + , pattern = + [ regex "(zwei|zwo)" + ] + , prod = \_ -> integer 2 + } + ruleNumeralsUnd :: Rule ruleNumeralsUnd = Rule { name = "numbers und" @@ -218,7 +227,7 @@ ruleIntegerWithThousandsSeparator = Rule ruleAllNumeralWords :: Rule ruleAllNumeralWords = Rule { name = "simple and complex numerals written as one word" - , pattern = [regex "(ein|zwei|drei|vier|fünf|sech|sieb|acht|neun|zehn|elf|zwölf|hundert|tausend)?([^\\s]+)?(eine[m|n|r|s]?|eins?|zwei|drei|vier|fünf|sechs|sieben|acht|neun|zehn|elf|zwölf|[s|ß|z]ig|hundert|tausend)"] + , pattern = [regex "(ein|zwei|zwo|drei|vier|fünf|sech|sieb|acht|neun|zehn|elf|zwölf|hundert|tausend)?([^\\s]+)?(eine[m|n|r|s]?|eins?|zwei|drei|vier|fünf|sechs|sieben|acht|neun|zehn|elf|zwölf|[s|ß|z]ig|hundert|tausend)"] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch matches) : _) -> (parseNumeral $ concat $ Text.unpack . Text.toLower <$> matches) From 29e5eeb369f9bc662794aea01d51f406498442c7 Mon Sep 17 00:00:00 2001 From: SOUVIK GHOSH Date: Mon, 6 Nov 2023 14:42:13 +0100 Subject: [PATCH 2/2] Update Rules.hs --- Duckling/Numeral/DE/Rules.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/Duckling/Numeral/DE/Rules.hs b/Duckling/Numeral/DE/Rules.hs index ea937a7b8..2f064bccb 100644 --- a/Duckling/Numeral/DE/Rules.hs +++ b/Duckling/Numeral/DE/Rules.hs @@ -248,6 +248,7 @@ rules = , ruleNumeralDotNumeral , ruleNumeralsPrefixWithNegativeOrMinus , ruleNumeralsSuffixesKMG + , ruleTwo , ruleNumeralsUnd , rulePowersOfTen , ruleZero