Skip to content

Commit c48d08a

Browse files
author
FARHAD SHAKERIN
authored
[FR DateTimeV2] Improving coverage of terms for last in French (microsoft#3073)
1 parent 226562c commit c48d08a

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public static class DateTimeDefinitions
2525
public const bool CheckBothBeforeAfter = false;
2626
public const string TillRegex = @"(?<till>\b(au|et|(jusqu')?a|avant)\b|(jusqu')?à|--|-|—|——)";
2727
public const string RangeConnectorRegex = @"(?<and>\b(de\s+la|au|(jusqu')?a|et(\s*la)?)\b|(jusqu')?à|--|-|—|——)";
28-
public const string RelativeRegex = @"(?<order>prochaine?|de|du|ce(tte)?|l[ae]|derni[eè]re|hier|pr[eé]c[eé]dente|au\s+cours+(de|du\s*))";
29-
public const string StrictRelativeRegex = @"(?<order>prochaine?|derni[eè]re|hier|pr[eé]c[eé]dente|au\s+cours+(de|du\s*))";
28+
public const string RelativeRegex = @"(?<order>prochaine?|de|du|ce(tte)?|l[ae]|derni[eè]re?s?|hier|pr[eé]c[eé]dente|au\s+cours+(de|du\s*))";
29+
public const string StrictRelativeRegex = @"(?<order>prochaine?|derni[eè]re?s?|hier|pr[eé]c[eé]dente|au\s+cours+(de|du\s*))";
3030
public const string NextSuffixRegex = @"(?<order>prochain(es?)?|suivante)\b";
31-
public const string PastSuffixRegex = @"(?<order>derni[eè]r(es?)?|pr[eé]c[eé]dente)\b";
31+
public const string PastSuffixRegex = @"(?<order>derni[eè]re?s?|pr[eé]c[eé]dente)\b";
3232
public const string ThisPrefixRegex = @"(?<order>ce(tte)?|au\s+cours+(du|de))\b";
3333
public const string RangePrefixRegex = @"(du|depuis|des?|entre)";
3434
public const string DayRegex = @"(?<day>(?:3[0-1]|[1-2]\d|0?[1-9])(e(r)?)?)(?=\b|t)";
@@ -53,7 +53,7 @@ public static class DateTimeDefinitions
5353
public static readonly string RelativeMonthRegex = $@"(?<relmonth>({ThisPrefixRegex}\s+mois)|(mois\s+{PastSuffixRegex})|(mois\s+{NextSuffixRegex}))\b";
5454
public const string WrittenMonthRegex = @"(?<month>avril|avr(\.)?|ao[uû]t|d[eé]cembre|d[eé]c(\.)?|f[eé]vrier|f[eé]vr?(\.)?|janvier|janv?(\.)?|juillet|jui?[ln](\.)?|mars?(\.)?|mai|novembre|nov(\.)?|octobre|oct(\.)?|septembre|sept?(\.)?(?!\s+heures))";
5555
public static readonly string MonthSuffixRegex = $@"(?<msuf>(en\s*|le\s*|de\s*|dans\s*)?({RelativeMonthRegex}|{WrittenMonthRegex}))";
56-
public const string DateUnitRegex = @"(?<unit>an|mois|((l')?ann[eé]e|semaine|journ[eé]e|jour)(?<plural>s)?)\b";
56+
public const string DateUnitRegex = @"(?<unit>an|(?<plural>mois)|((l')?ann[eé]e|semaine|journ[eé]e|jour)(?<plural>s)?)\b";
5757
public static readonly string SimpleCasesRegex = $@"\b((d[ue])|entre\s+)?({DayRegex})\s*{TillRegex}\s*({DayRegex})\s+{MonthSuffixRegex}((\s+|\s*,\s*){YearRegex})?\b";
5858
public static readonly string MonthFrontSimpleCasesRegex = $@"\b((d[ue]|entre)\s+)?{MonthSuffixRegex}\s+((d[ue]|entre)\s+)?({DayRegex})\s*{TillRegex}\s*({DayRegex})((\s+|\s*,\s*){YearRegex})?\b";
5959
public static readonly string MonthFrontBetweenRegex = $@"\b{MonthSuffixRegex}\s+(entre|d[ue]\s+)({DayRegex})\s*{RangeConnectorRegex}\s*({DayRegex})((\s+|\s*,\s*){YearRegex})?\b";
@@ -83,7 +83,7 @@ public static class DateTimeDefinitions
8383
public static readonly string ThisRegex = $@"\b((cette(\s*semaine)?\s+){WeekDayRegex})|({WeekDayRegex}(\s+cette\s*semaine))\b";
8484
public static readonly string LastDateRegex = $@"\b(({WeekDayRegex}(\s*(de)?\s*la\s*semaine\s+{PastSuffixRegex}))|({WeekDayRegex}(\s+{PastSuffixRegex})))\b";
8585
public static readonly string NextDateRegex = $@"\b(({WeekDayRegex}(\s+{NextSuffixRegex}))|({WeekDayRegex}(\s*(de)?\s*la\s*semaine\s+{NextSuffixRegex})))\b";
86-
public const string SpecialDayRegex = @"\b(avant[\s|-]hier|apr[eè]s(-demain|\s*demain)|(le\s)?jour suivant|(le\s+)?dernier jour|hier|lendemain|demain|(de\s)?la journ[ée]e|aujourd'hui)\b";
86+
public const string SpecialDayRegex = @"\b(avant[\s|-]hier|apr[eè]s(-demain|\s*demain)|(le\s)?jour suivant|(le\s+)?derni[eè]re?s? jour|hier|lendemain|demain|(de\s)?la journ[ée]e|aujourd'hui)\b";
8787
public const string SpecialDayWithNumRegex = @"^\b$";
8888
public const string StrictWeekDay = @"\b(?<weekday>dim(anche)?|lun(di)?|mar(di)?|mer(credi)?|jeu(di)?|ven(dredi)?|sam(edi)?)s?\b";
8989
public const string SetWeekDayRegex = @"\b(?<prefix>le\s+)?(?<weekday>matin([ée]e)?|apr[eè]s-midi|soir([ée]e)?|dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi)s\b";
@@ -124,7 +124,7 @@ public static class DateTimeDefinitions
124124
public const string MorningRegex = @"(?<morning>matin([ée]e)?)";
125125
public const string AfternoonRegex = @"(?<afternoon>(d'|l')?apr[eè]s(-|\s*)midi)";
126126
public static readonly string MidmorningRegex = $@"(?<midmorning>milieu\s*d[ue]\s*{MorningRegex})";
127-
public const string MiddayRegex = @"(?<midday>milieu(\s*|-)d[eu]\s*(jour|midi)|apr[eè]s(-|\s*)midi|(?<=\bà\s+)midi)";
127+
public const string MiddayRegex = @"(?<midday>milieu(\s*|-)d[eu]\s*(jour|midi)|apr[eè]s(-|\s*)midi|(?<=à\s+)midi)";
128128
public static readonly string MidafternoonRegex = $@"(?<midafternoon>milieu\s*d'+{AfternoonRegex})";
129129
public static readonly string MidTimeRegex = $@"(?<mid>({MidnightRegex}|{MidmorningRegex}|{MidafternoonRegex}|{MiddayRegex}))";
130130
public static readonly string AtRegex = $@"\b(((?<=\b[àa]\s+)({WrittenTimeRegex}|{HourNumRegex}(\s+heures)?|{BaseDateTime.HourRegex}|{MidTimeRegex}))|{MidTimeRegex})\b";
@@ -179,7 +179,7 @@ public static class DateTimeDefinitions
179179
public static readonly string EachUnitRegex = $@"(?<each>(chaque|toutes les|tous les)(?<other>\s+autres)?\s*{DurationUnitRegex})";
180180
public const string EachPrefixRegex = @"\b(?<each>(chaque|tous les|(toutes les))\s*$)";
181181
public const string SetEachRegex = @"\b(?<each>(chaque|tous les|(toutes les))\s*)";
182-
public const string SetLastRegex = @"(?<last>prochain|dernier|derni[eè]re|pass[ée]s|pr[eé]c[eé]dent|courant|en\s*cours)";
182+
public const string SetLastRegex = @"(?<last>prochain|derni[eè]re?s?|pass[ée]s|pr[eé]c[eé]dent|courant|en\s*cours)";
183183
public const string EachDayRegex = @"\s*(chaque|tous les)\s*(jour|jours)\b";
184184
public static readonly string DurationFollowedUnit = $@"^\s*{SuffixAndRegex}?(\s+|-)?{DurationUnitRegex}";
185185
public static readonly string NumberCombinedWithDurationUnit = $@"\b(?<num>\d+(\.\d*)?)(-)?{DurationUnitRegex}";

Patterns/French/French-DateTime.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ TillRegex: !simpleRegex
77
RangeConnectorRegex : !simpleRegex
88
def: (?<and>\b(de\s+la|au|(jusqu')?a|et(\s*la)?)\b|(jusqu')?à|--|-|—|——)
99
RelativeRegex: !simpleRegex
10-
def: (?<order>prochaine?|de|du|ce(tte)?|l[ae]|derni[eè]re|hier|pr[eé]c[eé]dente|au\s+cours+(de|du\s*))
10+
def: (?<order>prochaine?|de|du|ce(tte)?|l[ae]|derni[eè]re?s?|hier|pr[eé]c[eé]dente|au\s+cours+(de|du\s*))
1111
StrictRelativeRegex: !simpleRegex
12-
def: (?<order>prochaine?|derni[eè]re|hier|pr[eé]c[eé]dente|au\s+cours+(de|du\s*))
12+
def: (?<order>prochaine?|derni[eè]re?s?|hier|pr[eé]c[eé]dente|au\s+cours+(de|du\s*))
1313
NextSuffixRegex: !simpleRegex
1414
def: (?<order>prochain(es?)?|suivante)\b
1515
PastSuffixRegex: !simpleRegex
16-
def: (?<order>derni[eè]r(es?)?|pr[eé]c[eé]dente)\b
16+
def: (?<order>derni[eè]re?s?|pr[eé]c[eé]dente)\b
1717
ThisPrefixRegex: !simpleRegex
1818
def: (?<order>ce(tte)?|au\s+cours+(du|de))\b
1919
RangePrefixRegex: !simpleRegex
@@ -76,7 +76,7 @@ MonthSuffixRegex: !nestedRegex
7676
def: (?<msuf>(en\s*|le\s*|de\s*|dans\s*)?({RelativeMonthRegex}|{WrittenMonthRegex}))
7777
references: [ RelativeMonthRegex, WrittenMonthRegex ]
7878
DateUnitRegex: !simpleRegex
79-
def: (?<unit>an|mois|((l')?ann[eé]e|semaine|journ[eé]e|jour)(?<plural>s)?)\b
79+
def: (?<unit>an|(?<plural>mois)|((l')?ann[eé]e|semaine|journ[eé]e|jour)(?<plural>s)?)\b
8080
SimpleCasesRegex: !nestedRegex
8181
def: \b((d[ue])|entre\s+)?({DayRegex})\s*{TillRegex}\s*({DayRegex})\s+{MonthSuffixRegex}((\s+|\s*,\s*){YearRegex})?\b
8282
references: [ DayRegex, TillRegex, MonthSuffixRegex, YearRegex ]
@@ -159,7 +159,7 @@ NextDateRegex: !nestedRegex
159159
def: \b(({WeekDayRegex}(\s+{NextSuffixRegex}))|({WeekDayRegex}(\s*(de)?\s*la\s*semaine\s+{NextSuffixRegex})))\b
160160
references: [ NextSuffixRegex, WeekDayRegex ]
161161
SpecialDayRegex: !simpleRegex
162-
def: \b(avant[\s|-]hier|apr[eè]s(-demain|\s*demain)|(le\s)?jour suivant|(le\s+)?dernier jour|hier|lendemain|demain|(de\s)?la journ[ée]e|aujourd'hui)\b
162+
def: \b(avant[\s|-]hier|apr[eè]s(-demain|\s*demain)|(le\s)?jour suivant|(le\s+)?derni[eè]re?s? jour|hier|lendemain|demain|(de\s)?la journ[ée]e|aujourd'hui)\b
163163
SpecialDayWithNumRegex: !simpleRegex
164164
# TODO: modify below regex according to the counterpart in English
165165
def: ^\b$
@@ -413,7 +413,7 @@ EachPrefixRegex: !simpleRegex
413413
SetEachRegex: !simpleRegex
414414
def: \b(?<each>(chaque|tous les|(toutes les))\s*)
415415
SetLastRegex: !simpleRegex
416-
def: (?<last>prochain|dernier|derni[eè]re|pass[ée]s|pr[eé]c[eé]dent|courant|en\s*cours)
416+
def: (?<last>prochain|derni[eè]re?s?|pass[ée]s|pr[eé]c[eé]dent|courant|en\s*cours)
417417
EachDayRegex: !simpleRegex
418418
def: \s*(chaque|tous les)\s*(jour|jours)\b
419419
DurationFollowedUnit: !nestedRegex

Specs/DateTime/French/DateTimeModel.json

+25
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,31 @@
2323
}
2424
]
2525
},
26+
{
27+
"Input": "au cours des dix derniers mois",
28+
"Context": {
29+
"ReferenceDateTime": "2023-02-01T00:00:00"
30+
},
31+
"NotSupported": "javascript, java, python",
32+
"Results": [
33+
{
34+
"Text": "dix derniers mois",
35+
"TypeName": "datetimeV2.daterange",
36+
"Resolution": {
37+
"values": [
38+
{
39+
"timex": "(2022-04-01,2023-02-01,P10M)",
40+
"type": "daterange",
41+
"start": "2022-04-01",
42+
"end": "2023-02-01"
43+
}
44+
]
45+
},
46+
"start": 13,
47+
"End": 29
48+
}
49+
]
50+
},
2651
{
2752
"Input": "Je vais sortir cette août",
2853
"Context": {

0 commit comments

Comments
 (0)