Skip to content

Commit 69ce841

Browse files
serefayarfacebook-github-bot
authored andcommitted
Comma as decimal mark for Numeral TR
Summary: Closes facebook#28 Differential Revision: D5120967 Pulled By: patapizza fbshipit-source-id: 41a5e4b
1 parent 6de7c21 commit 69ce841

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

Duckling/Distance/TR/Corpus.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ allExamples = concat
3131
, "3km"
3232
]
3333
, examples (DistanceValue Kilometre 3.0)
34-
[ "3.0 km"
34+
[ "3,0 km"
3535
]
3636
, examples (DistanceValue Mile 8)
3737
[ "8 Mil"

Duckling/Numeral/TR/Corpus.hs

+27-23
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,20 @@ allExamples = concat
6868
, "on sekiz"
6969
]
7070
, examples (NumeralValue 1.1)
71-
[ "1.1"
72-
, "1.10"
73-
, "01.10"
71+
[ "1,1"
72+
, "1,10"
73+
, "01,10"
7474
, "bir virgül bir"
7575
, "bir nokta bir"
7676
]
7777
, examples (NumeralValue 0.77)
78-
[ "0.77"
79-
, ".77"
78+
[ "0,77"
79+
, ",77"
80+
, "sıfır virgül yetmişyedi"
81+
, "sıfır virgül yetmiş yedi"
8082
]
8183
, examples (NumeralValue 100000)
82-
[ "100,000"
84+
[ "100.000"
8385
, "100000"
8486
, "100K"
8587
, "100k"
@@ -89,24 +91,24 @@ allExamples = concat
8991
[ "3M"
9092
, "3000K"
9193
, "3000000"
92-
, "3,000,000"
94+
, "3.000.000"
9395
]
9496
, examples (NumeralValue 1200000)
95-
[ "1,200,000"
97+
[ "1.200.000"
9698
, "1200000"
97-
, "1.2M"
99+
, "1,2M"
98100
, "1200K"
99-
, ".0012G"
101+
, ",0012G"
100102
, "1200B"
101103
]
102104
, examples (NumeralValue (-1200000))
103-
[ "- 1,200,000"
105+
[ "- 1.200.000"
104106
, "-1200000"
105-
, "eksi 1,200,000"
107+
, "eksi 1.200.000"
106108
, "negatif 1200000"
107-
, "-1.2M"
109+
, "-1,2M"
108110
, "-1200K"
109-
, "-.0012G"
111+
, "-,0012G"
110112
, "-1200B"
111113
]
112114
, examples (NumeralValue 5000)
@@ -149,32 +151,34 @@ allExamples = concat
149151
[ "beş buçuk"
150152
, "beşbuçuk"
151153
, "5 buçuk"
152-
, "5.5"
154+
, "5,5"
153155
]
154156
, examples (NumeralValue 3500000)
155-
[ "3.5 milyon"
157+
[ "3,5 milyon"
156158
, "3500000"
157159
, "üç buçuk milyon"
158160
, "üçbuçuk milyon"
159-
, "3.5M"
161+
, "3,5M"
160162
]
161163
, examples (NumeralValue 0.5)
162164
[ "yarım"
163-
, "0.5"
165+
, "0,5"
164166
]
165167
, examples (NumeralValue 2500)
166-
[ "2.5 bin"
168+
[ "2,5 bin"
167169
, "2500"
168-
, "iki buçuk bin"
169-
, "ikibuçuk bin"
170+
, "iki bin beş yüz"
171+
, "ikibin beşyüz"
170172
]
171173
, examples (NumeralValue 2200000)
172-
[ "2.2 milyon"
174+
[ "2,2 milyon"
173175
, "iki nokta iki milyon"
176+
, "iki virgül iki milyon"
174177
]
175178
, examples (NumeralValue 72.5)
176179
[ "yetmişikibuçuk"
177180
, "yetmişiki buçuk"
178-
, "72.5"
181+
, "yetmiş iki buçuk"
182+
, "72,5"
179183
]
180184
]

Duckling/Numeral/TR/Rules.hs

+10-7
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,14 @@ ruleDecimalWithThousandsSeparator :: Rule
110110
ruleDecimalWithThousandsSeparator = Rule
111111
{ name = "decimal with thousands separator"
112112
, pattern =
113-
[ regex "(\\d+(,\\d\\d\\d)+\\.\\d+)"
113+
[ regex "(\\d+(\\.\\d\\d\\d)+,\\d+)"
114114
]
115115
, prod = \tokens -> case tokens of
116116
(Token RegexMatch (GroupMatch (match:_)):_) ->
117-
parseDouble (Text.replace (Text.singleton ',') Text.empty match) >>= double
117+
let dot = Text.singleton '.'
118+
comma = Text.singleton ','
119+
fmt = Text.replace comma dot $ Text.replace dot Text.empty match
120+
in parseDouble fmt >>= double
118121
_ -> Nothing
119122
}
120123

@@ -138,11 +141,11 @@ ruleDecimalNumeral :: Rule
138141
ruleDecimalNumeral = Rule
139142
{ name = "decimal number"
140143
, pattern =
141-
[ regex "(\\d*\\.\\d+)"
144+
[ regex "(\\d*,\\d+)"
142145
]
143146
, prod = \tokens -> case tokens of
144147
(Token RegexMatch (GroupMatch (match:_)):_) ->
145-
parseDecimal True match
148+
parseDecimal False match
146149
_ -> Nothing
147150
}
148151

@@ -689,13 +692,13 @@ ruleNumeralDotNumeral = Rule
689692

690693
ruleIntegerWithThousandsSeparator :: Rule
691694
ruleIntegerWithThousandsSeparator = Rule
692-
{ name = "integer with thousands separator ,"
695+
{ name = "integer with thousands separator ."
693696
, pattern =
694-
[ regex "(\\d{1,3}(,\\d\\d\\d){1,5})"
697+
[ regex "(\\d{1,3}(\\.\\d\\d\\d){1,5})"
695698
]
696699
, prod = \tokens -> case tokens of
697700
(Token RegexMatch (GroupMatch (match:_)):_) ->
698-
parseDouble (Text.replace (Text.singleton ',') Text.empty match) >>= double
701+
parseDouble (Text.replace (Text.singleton '.') Text.empty match) >>= double
699702
_ -> Nothing
700703
}
701704

0 commit comments

Comments
 (0)