Skip to content

Commit

Permalink
增加 次日 = 明天
Browse files Browse the repository at this point in the history
  • Loading branch information
du00cs committed Jul 12, 2024
1 parent 788ae5b commit 9d31df3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -575,23 +575,13 @@ trait Rules extends DimRules {
}
)

val tomorrow = Rule(
name = "次日|第二天",
pattern = List("次日|第二天".regex),
prod = tokens {
case Token(RegexMatch, GroupMatch(s :: _)) :: _ =>
tt(cycleNthThis(1, Day, Day, Year))
}
)

def openInterval(td: TimeData, direction: IntervalDirection): Option[Token] = {
val pred = SequencePredicate(List(td, TimeData(TimeOpenIntervalPredicate(direction), timeGrain = Grain.NoGrain)))
tt(TimeData(pred, timeGrain = td.timeGrain, hint = Hint.Sequence))
}

val composite = List(
ruleRecentTime,
tomorrow,
ruleNthTimeOfTime,
ruleNthTimeOfTime2,
ruleIntersect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.xiaomi.duckling.dimension.matcher.{GroupMatch, RegexMatch}
import com.xiaomi.duckling.dimension.matcher.Prods.{regexMatch, singleRegexMatch}
import com.xiaomi.duckling.dimension.numeral.Predicates.{getIntValue, isIntegerBetween}
import com.xiaomi.duckling.dimension.numeral.seq.{DigitSequence, DigitSequenceData}
import com.xiaomi.duckling.dimension.time.Prods.intersectDOM
import com.xiaomi.duckling.dimension.time.Prods.{intersectDOM, tt}
import com.xiaomi.duckling.dimension.time.duration.{isADecade, Duration, DurationData}
import com.xiaomi.duckling.dimension.time.enums.Grain._
import com.xiaomi.duckling.dimension.time.enums.Hint.{NoHint, RecentNominal, YearMonth}
Expand Down Expand Up @@ -229,6 +229,15 @@ trait Rules extends DimRules {
}
)

val tomorrow = Rule(
name = "次日",
pattern = List("次日".regex),
prod = tokens {
case Token(RegexMatch, GroupMatch(s :: _)) :: _ =>
tt(cycleNthThis(1, Day, Day, Year))
}
)

val ruleDecade = Rule(
name = "date: tens of decade",
pattern = List(isADecade.predicate, "年代".regex),
Expand Down

0 comments on commit 9d31df3

Please sign in to comment.