mirror of
https://github.com/facebook/duckling.git
synced 2024-09-11 21:27:13 +03:00
Added missing 'TR' time test cases (#661)
Summary: Fixes https://github.com/facebook/duckling/issues/660. Pull Request resolved: https://github.com/facebook/duckling/pull/661 Test Plan: :test Duckling.Time.TR.Tests Reviewed By: stroxler Differential Revision: D32145794 Pulled By: chessai fbshipit-source-id: 4d55043f133b8238e9e8360264a3fbea6af2d022
This commit is contained in:
parent
dd70d80dc1
commit
e1641aeba4
File diff suppressed because it is too large
Load Diff
@ -294,7 +294,9 @@ allExamples = concat
|
|||||||
]
|
]
|
||||||
, examples (datetime (2013, 1, 29, 4, 0, 0) Hour)
|
, examples (datetime (2013, 1, 29, 4, 0, 0) Hour)
|
||||||
[ "14 gün önce"
|
[ "14 gün önce"
|
||||||
, "iki hafta önce"
|
]
|
||||||
|
, examples (datetime (2013, 1, 29, 0, 0, 0) Day)
|
||||||
|
[ "iki hafta önce"
|
||||||
]
|
]
|
||||||
, examples (datetime (2013, 2, 5, 0, 0, 0) Day)
|
, examples (datetime (2013, 2, 5, 0, 0, 0) Day)
|
||||||
[ "bir hafta önce"
|
[ "bir hafta önce"
|
||||||
@ -314,7 +316,9 @@ allExamples = concat
|
|||||||
]
|
]
|
||||||
, examples (datetime (2013, 2, 26, 4, 0, 0) Hour)
|
, examples (datetime (2013, 2, 26, 4, 0, 0) Hour)
|
||||||
[ "14 gün sonra"
|
[ "14 gün sonra"
|
||||||
, "iki hafta sonra"
|
]
|
||||||
|
, examples (datetime (2013, 2, 26, 0, 0, 0) Day)
|
||||||
|
[ "iki hafta sonra"
|
||||||
]
|
]
|
||||||
, examples (datetime (2013, 2, 19, 0, 0, 0) Day)
|
, examples (datetime (2013, 2, 19, 0, 0, 0) Day)
|
||||||
[ "bir hafta sonra"
|
[ "bir hafta sonra"
|
||||||
@ -437,9 +441,11 @@ allExamples = concat
|
|||||||
[ "perşembe 9:30 - 11:00"
|
[ "perşembe 9:30 - 11:00"
|
||||||
]
|
]
|
||||||
, examples (datetimeInterval ((2013, 2, 12, 15, 0, 0), (2013, 2, 12, 17, 0, 0)) Hour)
|
, examples (datetimeInterval ((2013, 2, 12, 15, 0, 0), (2013, 2, 12, 17, 0, 0)) Hour)
|
||||||
[ "saat 15-16"]
|
[ "saat 15-16"
|
||||||
|
]
|
||||||
, examples (datetimeInterval ((2013, 2, 12, 15, 30, 0), (2013, 2, 12, 18, 1, 0)) Minute)
|
, examples (datetimeInterval ((2013, 2, 12, 15, 30, 0), (2013, 2, 12, 18, 1, 0)) Minute)
|
||||||
[ "saat 15:30 - 18"]
|
[ "saat 15:30 - 18"
|
||||||
|
]
|
||||||
, examples (datetimeInterval ((2013, 2, 14, 9, 0, 0), (2013, 2, 14, 12, 0, 0)) Hour)
|
, examples (datetimeInterval ((2013, 2, 14, 9, 0, 0), (2013, 2, 14, 12, 0, 0)) Hour)
|
||||||
[ "perşembe saat 9-11"
|
[ "perşembe saat 9-11"
|
||||||
]
|
]
|
||||||
|
@ -98,19 +98,21 @@ rulePartOfDays :: Rule
|
|||||||
rulePartOfDays = Rule
|
rulePartOfDays = Rule
|
||||||
{ name = "part of days"
|
{ name = "part of days"
|
||||||
, pattern =
|
, pattern =
|
||||||
[ regex "(sabahı?|öğlen?|akşam|gece|öğle\\syemeği)"
|
[ regex "(sabah(ı|a|tan)?|öğlen?|akşam|gece|öğle\\syemeği)"
|
||||||
]
|
]
|
||||||
, prod = \case
|
, prod = \case
|
||||||
(Token RegexMatch (GroupMatch (match:_)):_) -> do
|
(Token RegexMatch (GroupMatch (match:_)):_) -> do
|
||||||
let (start, end) = case Text.toLower match of
|
let (start, end) = case Text.toLower match of
|
||||||
"sabah" -> (hour False 0, hour False 12 )
|
"sabah" -> (hour False 0, hour False 12 )
|
||||||
"sabahı" -> (hour False 0, hour False 12 )
|
"sabahı" -> (hour False 0, hour False 12 )
|
||||||
|
"sabaha" -> (hour False 0, hour False 12 )
|
||||||
|
"sabahtan" -> (hour False 0, hour False 12 )
|
||||||
"akşam" -> (hour False 18, hour False 0 )
|
"akşam" -> (hour False 18, hour False 0 )
|
||||||
"gece" -> (hour False 18, hour False 0 )
|
"gece" -> (hour False 18, hour False 0 )
|
||||||
"öğlen" -> (hour False 12, hour False 14)
|
"öğlen" -> (hour False 12, hour False 14)
|
||||||
"öğle" -> (hour False 12, hour False 14)
|
"öğle" -> (hour False 12, hour False 14)
|
||||||
"öğle yemeği" -> (hour False 12, hour False 14)
|
"öğle yemeği" -> (hour False 12, hour False 14)
|
||||||
_ -> (hour False 12, hour False 19)
|
_ -> (hour False 12, hour False 19)
|
||||||
td <- interval TTime.Open start end
|
td <- interval TTime.Open start end
|
||||||
tt $ partOfDay $ mkLatent td
|
tt $ partOfDay $ mkLatent td
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
@ -233,7 +235,7 @@ ruleDurationFromNow = Rule
|
|||||||
{ name = "<duration> from now"
|
{ name = "<duration> from now"
|
||||||
, pattern =
|
, pattern =
|
||||||
[ regex "(bugünden\\s)?sonra(ki)?"
|
[ regex "(bugünden\\s)?sonra(ki)?"
|
||||||
, dimension Duration
|
, dimension Duration
|
||||||
]
|
]
|
||||||
, prod = \case
|
, prod = \case
|
||||||
(_:Token Duration dd:_) ->
|
(_:Token Duration dd:_) ->
|
||||||
@ -269,19 +271,6 @@ ruleYearLatent2 = Rule
|
|||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
ruleTimeAfterNext :: Rule
|
|
||||||
ruleTimeAfterNext = Rule
|
|
||||||
{ name = "<time> after next"
|
|
||||||
, pattern =
|
|
||||||
[ regex "sonraki|önümüzdeki"
|
|
||||||
, dimension Time
|
|
||||||
]
|
|
||||||
, prod = \case
|
|
||||||
(_:Token Time td:_) ->
|
|
||||||
tt $ predNth 1 True td
|
|
||||||
_ -> Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
ruleNoon :: Rule
|
ruleNoon :: Rule
|
||||||
ruleNoon = Rule
|
ruleNoon = Rule
|
||||||
{ name = "noon"
|
{ name = "noon"
|
||||||
@ -456,8 +445,8 @@ ruleNthTimeAfterTime = Rule
|
|||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
ruleMmdd :: Rule
|
ruleMMDD :: Rule
|
||||||
ruleMmdd = Rule
|
ruleMMDD = Rule
|
||||||
{ name = "mm/dd"
|
{ name = "mm/dd"
|
||||||
, pattern =
|
, pattern =
|
||||||
[ regex "([012]?[1-9]|10|20|30|31)\\.(10|11|12|0?[1-9])\\.?"
|
[ regex "([012]?[1-9]|10|20|30|31)\\.(10|11|12|0?[1-9])\\.?"
|
||||||
@ -470,6 +459,21 @@ ruleMmdd = Rule
|
|||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ruleMMDDYYYY :: Rule
|
||||||
|
ruleMMDDYYYY = Rule
|
||||||
|
{ name = "mm/dd/yyyy"
|
||||||
|
, pattern =
|
||||||
|
[ regex "(1[0-2]|0?[1-9])[-/\\s](3[01]|[12]\\d|0?[1-9])[-/\\s](\\d{2,4})"
|
||||||
|
]
|
||||||
|
, prod = \case
|
||||||
|
(Token RegexMatch (GroupMatch (mm:dd:yy:_)):_) -> do
|
||||||
|
y <- parseInt yy
|
||||||
|
m <- parseInt mm
|
||||||
|
d <- parseInt dd
|
||||||
|
tt $ yearMonthDay y m d
|
||||||
|
_ -> Nothing
|
||||||
|
}
|
||||||
|
|
||||||
ruleTimeofdayLatent :: Rule
|
ruleTimeofdayLatent :: Rule
|
||||||
ruleTimeofdayLatent = Rule
|
ruleTimeofdayLatent = Rule
|
||||||
{ name = "time-of-day (latent)"
|
{ name = "time-of-day (latent)"
|
||||||
@ -669,8 +673,8 @@ ruleOrdinalQuarterYear = Rule
|
|||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
ruleYyyymmdd :: Rule
|
ruleYYYYMMDD :: Rule
|
||||||
ruleYyyymmdd = Rule
|
ruleYYYYMMDD = Rule
|
||||||
{ name = "yyyy-mm-dd"
|
{ name = "yyyy-mm-dd"
|
||||||
, pattern =
|
, pattern =
|
||||||
[ regex "(\\d{2,4})-(0?[1-9]|10|11|12)-([012]?[1-9]|10|20|30|31)"
|
[ regex "(\\d{2,4})-(0?[1-9]|10|11|12)-([012]?[1-9]|10|20|30|31)"
|
||||||
@ -699,19 +703,6 @@ ruleNextNCycle = Rule
|
|||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
ruleMorning :: Rule
|
|
||||||
ruleMorning = Rule
|
|
||||||
{ name = "morning"
|
|
||||||
, pattern =
|
|
||||||
[ regex "sabah(ı|a|tan)?"
|
|
||||||
]
|
|
||||||
, prod = \_ ->
|
|
||||||
let from = hour False 3
|
|
||||||
to = hour False 12
|
|
||||||
in Token Time . mkLatent . partOfDay <$>
|
|
||||||
interval TTime.Open from to
|
|
||||||
}
|
|
||||||
|
|
||||||
ruleThisPartofday :: Rule
|
ruleThisPartofday :: Rule
|
||||||
ruleThisPartofday = Rule
|
ruleThisPartofday = Rule
|
||||||
{ name = "this <part-of-day>"
|
{ name = "this <part-of-day>"
|
||||||
@ -736,6 +727,7 @@ ruleThisCycle = Rule
|
|||||||
tt $ cycleNth grain 0
|
tt $ cycleNth grain 0
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
ruleThisTime :: Rule
|
ruleThisTime :: Rule
|
||||||
ruleThisTime = Rule
|
ruleThisTime = Rule
|
||||||
{ name = "this <time>"
|
{ name = "this <time>"
|
||||||
@ -791,7 +783,7 @@ ruleAfterTimeofday = Rule
|
|||||||
{ name = "after <time-of-day>"
|
{ name = "after <time-of-day>"
|
||||||
, pattern =
|
, pattern =
|
||||||
[ regex "sonraki|önümüzdeki"
|
[ regex "sonraki|önümüzdeki"
|
||||||
, dimension Time
|
, Predicate isATimeOfDay
|
||||||
]
|
]
|
||||||
, prod = \case
|
, prod = \case
|
||||||
(_:Token Time td:_) -> tt $ withDirection TTime.After td
|
(_:Token Time td:_) -> tt $ withDirection TTime.After td
|
||||||
@ -1030,21 +1022,6 @@ rulePartofdayOfTime = Rule
|
|||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
ruleMmddyyyy :: Rule
|
|
||||||
ruleMmddyyyy = Rule
|
|
||||||
{ name = "mm/dd/yyyy"
|
|
||||||
, pattern =
|
|
||||||
[ regex "([012]?[1-9]|10|20|30|31)\\.(0?[1-9]|10|11|12)\\.(\\d{2,4})"
|
|
||||||
]
|
|
||||||
, prod = \case
|
|
||||||
(Token RegexMatch (GroupMatch (m1:m2:m3:_)):_) -> do
|
|
||||||
y <- parseInt m3
|
|
||||||
m <- parseInt m2
|
|
||||||
d <- parseInt m1
|
|
||||||
tt $ yearMonthDay y m d
|
|
||||||
_ -> Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
ruleTimezone :: Rule
|
ruleTimezone :: Rule
|
||||||
ruleTimezone = Rule
|
ruleTimezone = Rule
|
||||||
{ name = "<time> timezone"
|
{ name = "<time> timezone"
|
||||||
@ -1061,7 +1038,7 @@ ruleTimezone = Rule
|
|||||||
|
|
||||||
rules :: [Rule]
|
rules :: [Rule]
|
||||||
rules =
|
rules =
|
||||||
[ruleAbsorptionOfAfterNamedDay
|
[ ruleAbsorptionOfAfterNamedDay
|
||||||
, ruleAfterTimeofday
|
, ruleAfterTimeofday
|
||||||
, ruleAfternoon
|
, ruleAfternoon
|
||||||
, ruleAtTimeofday
|
, ruleAtTimeofday
|
||||||
@ -1097,9 +1074,9 @@ rules =
|
|||||||
, ruleNextTime
|
, ruleNextTime
|
||||||
, ruleLunch
|
, ruleLunch
|
||||||
, ruleMidnighteodendOfDay
|
, ruleMidnighteodendOfDay
|
||||||
, ruleMmdd
|
, ruleMMDD
|
||||||
, ruleMmddyyyy
|
, ruleMMDDYYYY
|
||||||
, ruleMorning
|
, ruleYYYYMMDD
|
||||||
, ruleNamedmonthDayofmonthNonOrdinal
|
, ruleNamedmonthDayofmonthNonOrdinal
|
||||||
, ruleNextCycle
|
, ruleNextCycle
|
||||||
, ruleNextNCycle
|
, ruleNextNCycle
|
||||||
@ -1118,7 +1095,6 @@ rules =
|
|||||||
, ruleThisPartofday
|
, ruleThisPartofday
|
||||||
, ruleThisTime
|
, ruleThisTime
|
||||||
, ruleThisnextDayofweek
|
, ruleThisnextDayofweek
|
||||||
, ruleTimeAfterNext
|
|
||||||
, ruleTimePartofday
|
, ruleTimePartofday
|
||||||
, ruleTimeofdayLatent
|
, ruleTimeofdayLatent
|
||||||
, ruleTimeofdayTimeofdayInterval
|
, ruleTimeofdayTimeofdayInterval
|
||||||
@ -1129,7 +1105,6 @@ rules =
|
|||||||
, ruleYear
|
, ruleYear
|
||||||
, ruleYearLatent
|
, ruleYearLatent
|
||||||
, ruleYearLatent2
|
, ruleYearLatent2
|
||||||
, ruleYyyymmdd
|
|
||||||
, ruleTimezone
|
, ruleTimezone
|
||||||
]
|
]
|
||||||
++ ruleInstants
|
++ ruleInstants
|
||||||
|
@ -1161,6 +1161,7 @@ test-suite duckling-test
|
|||||||
, Duckling.Time.RO.Tests
|
, Duckling.Time.RO.Tests
|
||||||
, Duckling.Time.RU.Tests
|
, Duckling.Time.RU.Tests
|
||||||
, Duckling.Time.SV.Tests
|
, Duckling.Time.SV.Tests
|
||||||
|
, Duckling.Time.TR.Tests
|
||||||
, Duckling.Time.UK.Tests
|
, Duckling.Time.UK.Tests
|
||||||
, Duckling.Time.VI.Tests
|
, Duckling.Time.VI.Tests
|
||||||
, Duckling.Time.ZH.Tests
|
, Duckling.Time.ZH.Tests
|
||||||
|
@ -55,6 +55,7 @@ import qualified Duckling.Time.PT.Corpus as PTTime
|
|||||||
import qualified Duckling.Time.RO.Corpus as ROTime
|
import qualified Duckling.Time.RO.Corpus as ROTime
|
||||||
import qualified Duckling.Time.RU.Corpus as RUTime
|
import qualified Duckling.Time.RU.Corpus as RUTime
|
||||||
import qualified Duckling.Time.SV.Corpus as SVTime
|
import qualified Duckling.Time.SV.Corpus as SVTime
|
||||||
|
import qualified Duckling.Time.TR.Corpus as TRTime
|
||||||
import qualified Duckling.Time.UK.Corpus as UKTime
|
import qualified Duckling.Time.UK.Corpus as UKTime
|
||||||
import qualified Duckling.Time.VI.Corpus as VITime
|
import qualified Duckling.Time.VI.Corpus as VITime
|
||||||
import qualified Duckling.Time.ZH.Corpus as ZHTime
|
import qualified Duckling.Time.ZH.Corpus as ZHTime
|
||||||
@ -221,7 +222,7 @@ getCorpusForLang = \case
|
|||||||
TA -> (testContext, testOptions, [])
|
TA -> (testContext, testOptions, [])
|
||||||
TE -> (testContext, testOptions, [])
|
TE -> (testContext, testOptions, [])
|
||||||
TH -> (testContext, testOptions, [])
|
TH -> (testContext, testOptions, [])
|
||||||
TR -> (testContext, testOptions, [])
|
TR -> TRTime.corpus
|
||||||
UK -> UKTime.corpus
|
UK -> UKTime.corpus
|
||||||
VI -> VITime.corpus
|
VI -> VITime.corpus
|
||||||
ZH -> ZHTime.corpus
|
ZH -> ZHTime.corpus
|
||||||
|
@ -47,6 +47,7 @@ import qualified Duckling.Time.PT.Tests as PT
|
|||||||
import qualified Duckling.Time.RO.Tests as RO
|
import qualified Duckling.Time.RO.Tests as RO
|
||||||
import qualified Duckling.Time.RU.Tests as RU
|
import qualified Duckling.Time.RU.Tests as RU
|
||||||
import qualified Duckling.Time.SV.Tests as SV
|
import qualified Duckling.Time.SV.Tests as SV
|
||||||
|
import qualified Duckling.Time.TR.Tests as TR
|
||||||
import qualified Duckling.Time.UK.Tests as UK
|
import qualified Duckling.Time.UK.Tests as UK
|
||||||
import qualified Duckling.Time.VI.Tests as VI
|
import qualified Duckling.Time.VI.Tests as VI
|
||||||
import qualified Duckling.Time.ZH.Tests as ZH
|
import qualified Duckling.Time.ZH.Tests as ZH
|
||||||
@ -77,6 +78,7 @@ tests = testGroup "Time Tests"
|
|||||||
, RO.tests
|
, RO.tests
|
||||||
, RU.tests
|
, RU.tests
|
||||||
, SV.tests
|
, SV.tests
|
||||||
|
, TR.tests
|
||||||
, UK.tests
|
, UK.tests
|
||||||
, VI.tests
|
, VI.tests
|
||||||
, ZH.tests
|
, ZH.tests
|
||||||
|
Loading…
Reference in New Issue
Block a user