Skip to content

Commit

Permalink
去掉"上午下午六点的说法" (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
du00cs authored Sep 14, 2023
1 parent b57e890 commit dd03adc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public enum Hint {
* 早/晚上位于规则右部
*/
PartOfDayAtLast,
/**
* 上午下午组合
*/
PartOfDay,
/**
* 节假日
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ object FuzzyDayIntervals {
for {
hAdjustP <- updatePredicateByFuzzyInterval(part, p)
(is12H, hAdjust) <- hAdjustP.hour
} yield timeOfDay(hAdjust, is12H = false, td).copy(timePred = hAdjustP, hint = Hint.NoHint)
} yield timeOfDay(hAdjust, is12H = false, td).copy(timePred = hAdjustP, hint = Hint.PartOfDay)
case (
TimeIntervalsPredicate(t, p1: TimeDatePredicate, p2: TimeDatePredicate, beforeEndOfInterval),
IntervalOfDay
Expand All @@ -149,7 +149,7 @@ object FuzzyDayIntervals {
pattern = List(
// 避免[2017年三月2号早上][10点半] 与 [2017年三月2号][早上10点半] 同时出现,只保留后者
and(isAPartOfDay, not(isHint(PartOfDayAtLast))).predicate,
and(or(isNotLatent, isLatent0oClockOfDay), or(isATimeOfDay, isIntervalOfDay)).predicate
and(or(isNotLatent, isLatent0oClockOfDay), or(isATimeOfDay, isIntervalOfDay), not(isHint(Hint.PartOfDay))).predicate
),
prod = {
case (options: Options, Token(Time, td0: TimeData) :: Token(Time, td: TimeData) :: _) =>
Expand All @@ -163,7 +163,7 @@ object FuzzyDayIntervals {
// 避免[2017年三月2号早上][10点半] 与 [2017年三月2号][早上10点半] 同时出现,只保留后者
and(isAPartOfDay, not(isHint(PartOfDayAtLast)), isNotLatent).predicate,
"".regex,
and(or(isNotLatent, isLatent0oClockOfDay), or(isATimeOfDay, isIntervalOfDay)).predicate
and(or(isNotLatent, isLatent0oClockOfDay), or(isATimeOfDay, isIntervalOfDay), not(isHint(Hint.PartOfDay))).predicate
),
prod = {
case (options, Token(Time, td0: TimeData) :: _ :: Token(Time, td: TimeData) :: _) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class TimeTest extends UnitSpec {
}

it("不支持日到月等") {
val cases = Table("query", "八号到十二月", "八点到五分", "春天一点", "这十分钟后", "十后", "后三十分钟后")
val cases = Table("query", "八号到十二月", "八点到五分", "春天一点", "这十分钟后", "十后", "后三十分钟后", "早上晚上八点")
forAll(cases) { query =>
parse(query, context = testContext, options = options) should have size 0
}
Expand Down

0 comments on commit dd03adc

Please sign in to comment.