Skip to content

Commit 8fa46fa

Browse files
MichaelMWWMichael Wang (Centific Technologies Inc)
andauthored
Fix french time duration issue (#3189)
Co-authored-by: Michael Wang (Centific Technologies Inc) <[email protected]>
1 parent 90e968e commit 8fa46fa

File tree

5 files changed

+175
-5
lines changed

5 files changed

+175
-5
lines changed

.NET/Microsoft.Recognizers.Definitions.Common/French/DateTimeDefinitions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public static class DateTimeDefinitions
250250
public const string WeekWithWeekDayRangeRegex = @"^\b$";
251251
public const string GeneralEndingRegex = @"^\b$";
252252
public const string MiddlePauseRegex = @"^\b$";
253-
public const string DurationConnectorRegex = @"^\b$";
253+
public const string DurationConnectorRegex = @"^\s*(?<connector>\s+|et|,)\s*$";
254254
public const string PrefixArticleRegex = @"^[\.]";
255255
public const string OrRegex = @"^\b$";
256256
public const string YearPlusNumberRegex = @"^\b$";
@@ -748,7 +748,7 @@ public static class DateTimeDefinitions
748748
};
749749
public static readonly Dictionary<string, string> AmbiguityTimeFiltersDict = new Dictionary<string, string>
750750
{
751-
{ @"heures?$", @"\b(pour|durée\s+de|pendant)\s+(\S+\s+){1,2}heures?\b" }
751+
{ @"\bheures?\b", @"\b(pour|durée\s+de|pendant|dure|durera)\s+(\S+\s+){1,2}heures?.*$" }
752752
};
753753
public static readonly IList<string> MorningTermList = new List<string>
754754
{

Patterns/French/French-DateTime.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,7 @@ MiddlePauseRegex: !simpleRegex
579579
# TODO: modify below regex according to the counterpart in English
580580
def: ^\b$
581581
DurationConnectorRegex: !simpleRegex
582-
# TODO: modify below regex according to the counterpart in English
583-
def: ^\b$
582+
def: ^\s*(?<connector>\s+|et|,)\s*$
584583
PrefixArticleRegex: !simpleRegex
585584
# TODO: modify below regex according to the counterpart in English
586585
def: ^[\.]
@@ -1112,7 +1111,7 @@ AmbiguityFiltersDict: !dictionary
11121111
AmbiguityTimeFiltersDict: !dictionary
11131112
types: [ string, string ]
11141113
entries:
1115-
'heures?$': '\b(pour|durée\s+de|pendant)\s+(\S+\s+){1,2}heures?\b'
1114+
'\bheures?\b': '\b(pour|durée\s+de|pendant|dure|durera)\s+(\S+\s+){1,2}heures?.*$'
11161115
# For TimeOfDay resolution
11171116
MorningTermList: !list
11181117
types: [ string ]

Specs/DateTime/French/DateTimeModel.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,6 +2734,78 @@
27342734
}
27352735
]
27362736
},
2737+
{
2738+
"Input": "dure 2 heures",
2739+
"Context": {
2740+
"ReferenceDateTime": "2016-11-07T00:00:00"
2741+
},
2742+
"NotSupported": "java, javascript, python",
2743+
"Results": [
2744+
{
2745+
"Text": "2 heures",
2746+
"TypeName": "datetimeV2.duration",
2747+
"Resolution": {
2748+
"values": [
2749+
{
2750+
"timex": "PT2H",
2751+
"type": "duration",
2752+
"value": "7200"
2753+
}
2754+
]
2755+
},
2756+
"Start": 5,
2757+
"End": 12
2758+
}
2759+
]
2760+
},
2761+
{
2762+
"Input": "durera 2 heures 50 minutes",
2763+
"Context": {
2764+
"ReferenceDateTime": "2016-11-07T00:00:00"
2765+
},
2766+
"NotSupported": "java, javascript, python",
2767+
"Results": [
2768+
{
2769+
"Text": "2 heures 50 minutes",
2770+
"TypeName": "datetimeV2.duration",
2771+
"Resolution": {
2772+
"values": [
2773+
{
2774+
"timex": "PT2H50M",
2775+
"type": "duration",
2776+
"value": "10200"
2777+
}
2778+
]
2779+
},
2780+
"Start": 7,
2781+
"End": 25
2782+
}
2783+
]
2784+
},
2785+
{
2786+
"Input": "durera douze heures et vingt minutes",
2787+
"Context": {
2788+
"ReferenceDateTime": "2016-11-07T00:00:00"
2789+
},
2790+
"NotSupported": "java, javascript, python",
2791+
"Results": [
2792+
{
2793+
"Text": "douze heures et vingt minutes",
2794+
"TypeName": "datetimeV2.duration",
2795+
"Resolution": {
2796+
"values": [
2797+
{
2798+
"timex": "PT12H20M",
2799+
"type": "duration",
2800+
"value": "44400"
2801+
}
2802+
]
2803+
},
2804+
"Start": 7,
2805+
"End": 35
2806+
}
2807+
]
2808+
},
27372809
{
27382810
"Input": "Je vais partir pour la ville à 3 heures",
27392811
"Context": {

Specs/DateTime/French/DurationExtractor.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,42 @@
428428
}
429429
]
430430
},
431+
{
432+
"Input": "dure 2 heures",
433+
"NotSupported": "javascript, python, java",
434+
"Results": [
435+
{
436+
"Text": "2 heures",
437+
"Type": "duration",
438+
"Start": 5,
439+
"Length": 8
440+
}
441+
]
442+
},
443+
{
444+
"Input": "durera 2 heures 50 minutes",
445+
"NotSupported": "javascript, python, java",
446+
"Results": [
447+
{
448+
"Text": "2 heures 50 minutes",
449+
"Type": "duration",
450+
"Start": 7,
451+
"Length": 19
452+
}
453+
]
454+
},
455+
{
456+
"Input": "durera douze heures et vingt minutes",
457+
"NotSupported": "javascript, python, java",
458+
"Results": [
459+
{
460+
"Text": "douze heures et vingt minutes",
461+
"Type": "duration",
462+
"Start": 7,
463+
"Length": 29
464+
}
465+
]
466+
},
431467
{
432468
"Input": "Je partirai pour quelqués minutes",
433469
"Results": [

Specs/DateTime/French/DurationParser.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,69 @@
579579
}
580580
]
581581
},
582+
{
583+
"Input": "dure 2 heures",
584+
"NotSupported": "javascript, python, java",
585+
"Results": [
586+
{
587+
"Text": "2 heures",
588+
"Type": "duration",
589+
"Value": {
590+
"Timex": "PT2H",
591+
"FutureResolution": {
592+
"duration": "7200"
593+
},
594+
"PastResolution": {
595+
"duration": "7200"
596+
}
597+
},
598+
"Start": 5,
599+
"Length": 8
600+
}
601+
]
602+
},
603+
{
604+
"Input": "durera 2 heures 50 minutes",
605+
"NotSupported": "javascript, python, java",
606+
"Results": [
607+
{
608+
"Text": "2 heures 50 minutes",
609+
"Type": "duration",
610+
"Value": {
611+
"Timex": "PT2H50M",
612+
"FutureResolution": {
613+
"duration": "10200"
614+
},
615+
"PastResolution": {
616+
"duration": "10200"
617+
}
618+
},
619+
"Start": 7,
620+
"Length": 19
621+
}
622+
]
623+
},
624+
{
625+
"Input": "durera douze heures et vingt minutes",
626+
"NotSupported": "javascript, python, java",
627+
"Results": [
628+
{
629+
"Text": "douze heures et vingt minutes",
630+
"Type": "duration",
631+
"Value": {
632+
"Timex": "PT12H20M",
633+
"FutureResolution": {
634+
"duration": "44400"
635+
},
636+
"PastResolution": {
637+
"duration": "44400"
638+
}
639+
},
640+
"Start": 7,
641+
"Length": 29
642+
}
643+
]
644+
},
582645
{
583646
"Input": "Je pars pour 3 heures",
584647
"NotSupported": "dotnet, javascript, python, java",

0 commit comments

Comments
 (0)