Skip to content

Commit

Permalink
[.NET] Minor refinements from addressing issues #2936, #2921 (#2962)
Browse files Browse the repository at this point in the history
Co-authored-by: aitelint <[email protected]>
  • Loading branch information
aitelint and aitelint authored May 25, 2022
1 parent a1d01af commit 9d2c805
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,7 @@ private DateTimeResolutionResult MergeTwoTimePoints(string text, DateObject refe
pastEnd = DateObject.MinValue.SafeCreateFromValue(
pastBegin.Year, pastBegin.Month, pastBegin.Day, pastEnd.Hour, pastEnd.Minute, pastEnd.Second);

rightTimex = pr1.TimexStr.Equals(Constants.TimexNow, StringComparison.Ordinal) ? DateTimeFormatUtil.LuisDateShortTime(futureEnd) :
pr1.TimexStr.Split(Constants.TimeTimexPrefix[0])[0] + pr2.TimexStr;
rightTimex = TimexUtility.CombineDateTimeTimex(pr2.TimexStr, pr1.TimexStr, futureEnd);
}
else if (endHasDate)
{
Expand All @@ -1145,8 +1144,7 @@ private DateTimeResolutionResult MergeTwoTimePoints(string text, DateObject refe
pastBegin = DateObject.MinValue.SafeCreateFromValue(
pastEnd.Year, pastEnd.Month, pastEnd.Day, pastBegin.Hour, pastBegin.Minute, pastBegin.Second);

leftTimex = pr2.TimexStr.Equals(Constants.TimexNow, StringComparison.Ordinal) ? DateTimeFormatUtil.LuisDateShortTime(pastBegin) :
pr2.TimexStr.Split(Constants.TimeTimexPrefix[0])[0] + pr1.TimexStr;
leftTimex = TimexUtility.CombineDateTimeTimex(pr1.TimexStr, pr2.TimexStr, pastBegin);
}

ret.Timex = TimexUtility.GenerateDateTimePeriodTimex(leftTimex, rightTimex, futureEnd - futureBegin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ public static string GenerateWeekTimex(int weekNum)
return $"W{weekNum.ToString("D2", CultureInfo.InvariantCulture)}";
}

public static string CombineDateTimeTimex(string timeTimex1, string dateTimeTimex2, DateObject dateTime1)
{
return dateTimeTimex2.Equals(Constants.TimexNow, StringComparison.Ordinal) ? DateTimeFormatUtil.LuisDateShortTime(dateTime1) :
dateTimeTimex2.Split(Constants.TimeTimexPrefix[0])[0] + timeTimex1;
}

public static string GenerateDateTimePeriodTimex(string beginTimex, string endTimex, string durationTimex)
{
return $"({beginTimex},{endTimex},{durationTimex})";
Expand Down
136 changes: 136 additions & 0 deletions Specs/NumberWithUnit/Japanese/CurrencyModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -1037,5 +1037,141 @@
"End": 23
}
]
},
{
"Input": "これは 7万円です",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "7万円",
"TypeName": "currency",
"Resolution": {
"isoCurrency": "JPY",
"value": "70000",
"unit": "Japanese yen"
},
"Start": 4,
"End": 6
}
]
},
{
"Input": "これは7万円です",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "7万円",
"TypeName": "currency",
"Resolution": {
"isoCurrency": "JPY",
"value": "70000",
"unit": "Japanese yen"
},
"Start": 3,
"End": 5
}
]
},
{
"Input": "これは 7万円です",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "7万円",
"TypeName": "currency",
"Resolution": {
"isoCurrency": "JPY",
"value": "70000",
"unit": "Japanese yen"
},
"Start": 8,
"End": 10
}
]
},
{
"Input": "これは 7 万 円 です",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "7 万 円",
"TypeName": "currency",
"Resolution": {
"isoCurrency": "JPY",
"value": "70000",
"unit": "Japanese yen"
},
"Start": 4,
"End": 10
}
]
},
{
"Input": "これは 700円です",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "700円",
"TypeName": "currency",
"Resolution": {
"isoCurrency": "JPY",
"value": "700",
"unit": "Japanese yen"
},
"Start": 4,
"End": 7
}
]
},
{
"Input": "これは 七万円です",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "七万円",
"TypeName": "currency",
"Resolution": {
"isoCurrency": "JPY",
"value": "70000",
"unit": "Japanese yen"
},
"Start": 4,
"End": 6
}
]
},
{
"Input": "これは 7百円です",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "7百円",
"TypeName": "currency",
"Resolution": {
"isoCurrency": "JPY",
"value": "700",
"unit": "Japanese yen"
},
"Start": 4,
"End": 6
}
]
},
{
"Input": "これは 7千円です",
"NotSupported": "javascript, python, java",
"Results": [
{
"Text": "7千円",
"TypeName": "currency",
"Resolution": {
"isoCurrency": "JPY",
"value": "7000",
"unit": "Japanese yen"
},
"Start": 4,
"End": 6
}
]
}
]

0 comments on commit 9d2c805

Please sign in to comment.