Skip to content

Commit

Permalink
Fix french time duration issue (#3189)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Wang (Centific Technologies Inc) <[email protected]>
  • Loading branch information
MichaelMWW and Michael Wang (Centific Technologies Inc) authored Feb 12, 2025
1 parent 90e968e commit 8fa46fa
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public static class DateTimeDefinitions
public const string WeekWithWeekDayRangeRegex = @"^\b$";
public const string GeneralEndingRegex = @"^\b$";
public const string MiddlePauseRegex = @"^\b$";
public const string DurationConnectorRegex = @"^\b$";
public const string DurationConnectorRegex = @"^\s*(?<connector>\s+|et|,)\s*$";
public const string PrefixArticleRegex = @"^[\.]";
public const string OrRegex = @"^\b$";
public const string YearPlusNumberRegex = @"^\b$";
Expand Down Expand Up @@ -748,7 +748,7 @@ public static class DateTimeDefinitions
};
public static readonly Dictionary<string, string> AmbiguityTimeFiltersDict = new Dictionary<string, string>
{
{ @"heures?$", @"\b(pour|durée\s+de|pendant)\s+(\S+\s+){1,2}heures?\b" }
{ @"\bheures?\b", @"\b(pour|durée\s+de|pendant|dure|durera)\s+(\S+\s+){1,2}heures?.*$" }
};
public static readonly IList<string> MorningTermList = new List<string>
{
Expand Down
5 changes: 2 additions & 3 deletions Patterns/French/French-DateTime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,7 @@ MiddlePauseRegex: !simpleRegex
# TODO: modify below regex according to the counterpart in English
def: ^\b$
DurationConnectorRegex: !simpleRegex
# TODO: modify below regex according to the counterpart in English
def: ^\b$
def: ^\s*(?<connector>\s+|et|,)\s*$
PrefixArticleRegex: !simpleRegex
# TODO: modify below regex according to the counterpart in English
def: ^[\.]
Expand Down Expand Up @@ -1112,7 +1111,7 @@ AmbiguityFiltersDict: !dictionary
AmbiguityTimeFiltersDict: !dictionary
types: [ string, string ]
entries:
'heures?$': '\b(pour|durée\s+de|pendant)\s+(\S+\s+){1,2}heures?\b'
'\bheures?\b': '\b(pour|durée\s+de|pendant|dure|durera)\s+(\S+\s+){1,2}heures?.*$'
# For TimeOfDay resolution
MorningTermList: !list
types: [ string ]
Expand Down
72 changes: 72 additions & 0 deletions Specs/DateTime/French/DateTimeModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2734,6 +2734,78 @@
}
]
},
{
"Input": "dure 2 heures",
"Context": {
"ReferenceDateTime": "2016-11-07T00:00:00"
},
"NotSupported": "java, javascript, python",
"Results": [
{
"Text": "2 heures",
"TypeName": "datetimeV2.duration",
"Resolution": {
"values": [
{
"timex": "PT2H",
"type": "duration",
"value": "7200"
}
]
},
"Start": 5,
"End": 12
}
]
},
{
"Input": "durera 2 heures 50 minutes",
"Context": {
"ReferenceDateTime": "2016-11-07T00:00:00"
},
"NotSupported": "java, javascript, python",
"Results": [
{
"Text": "2 heures 50 minutes",
"TypeName": "datetimeV2.duration",
"Resolution": {
"values": [
{
"timex": "PT2H50M",
"type": "duration",
"value": "10200"
}
]
},
"Start": 7,
"End": 25
}
]
},
{
"Input": "durera douze heures et vingt minutes",
"Context": {
"ReferenceDateTime": "2016-11-07T00:00:00"
},
"NotSupported": "java, javascript, python",
"Results": [
{
"Text": "douze heures et vingt minutes",
"TypeName": "datetimeV2.duration",
"Resolution": {
"values": [
{
"timex": "PT12H20M",
"type": "duration",
"value": "44400"
}
]
},
"Start": 7,
"End": 35
}
]
},
{
"Input": "Je vais partir pour la ville à 3 heures",
"Context": {
Expand Down
36 changes: 36 additions & 0 deletions Specs/DateTime/French/DurationExtractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,42 @@
}
]
},
{
"Input": "dure 2 heures",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "2 heures",
"Type": "duration",
"Start": 5,
"Length": 8
}
]
},
{
"Input": "durera 2 heures 50 minutes",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "2 heures 50 minutes",
"Type": "duration",
"Start": 7,
"Length": 19
}
]
},
{
"Input": "durera douze heures et vingt minutes",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "douze heures et vingt minutes",
"Type": "duration",
"Start": 7,
"Length": 29
}
]
},
{
"Input": "Je partirai pour quelqués minutes",
"Results": [
Expand Down
63 changes: 63 additions & 0 deletions Specs/DateTime/French/DurationParser.json
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,69 @@
}
]
},
{
"Input": "dure 2 heures",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "2 heures",
"Type": "duration",
"Value": {
"Timex": "PT2H",
"FutureResolution": {
"duration": "7200"
},
"PastResolution": {
"duration": "7200"
}
},
"Start": 5,
"Length": 8
}
]
},
{
"Input": "durera 2 heures 50 minutes",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "2 heures 50 minutes",
"Type": "duration",
"Value": {
"Timex": "PT2H50M",
"FutureResolution": {
"duration": "10200"
},
"PastResolution": {
"duration": "10200"
}
},
"Start": 7,
"Length": 19
}
]
},
{
"Input": "durera douze heures et vingt minutes",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "douze heures et vingt minutes",
"Type": "duration",
"Value": {
"Timex": "PT12H20M",
"FutureResolution": {
"duration": "44400"
},
"PastResolution": {
"duration": "44400"
}
},
"Start": 7,
"Length": 29
}
]
},
{
"Input": "Je pars pour 3 heures",
"NotSupported": "dotnet, javascript, python, java",
Expand Down

0 comments on commit 8fa46fa

Please sign in to comment.