Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DUCK] 持续时间表达收缩 #220

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
@State(Scope.Benchmark)
public class DateTimeBenchmark {
Context context = new Context(ZonedDateTime.of(LocalDateTime.of(2016, 12, 8, 11, 30, 30), Types.ZoneCN()), Locale.CHINA);
final Types.Options option = new Types.Options(Sets.newHashSet("time", "duration"), false);
final Types.Options option = new Types.Options(Sets.newHashSet("Time", "Duration"), false);
final Random rand = new Random();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ trait Rules extends DimRules {
name = "intersect",
// 左右边均不能是中午/下午,避免与<dim time> <part-of-day>冲突
pattern = List(
and(isDimension(Time), isNotLatent, isNotHint(Hint.Season)).predicate,
and(isDimension(Time), isNotLatent, isNotHint(Hint.Season, Hint.FinalRule)).predicate,
// "一日"单独是latent,但是可以参与组合
and(isDimension(Time), or(and(or(isNotLatent, isLatent0oClockOfDay), not(isAPartOfDay)), isADayOfMonth)).predicate
),
Expand Down Expand Up @@ -345,7 +345,7 @@ trait Rules extends DimRules {
val predicate = SequencePredicate(
List(td, TimeData(TimeOpenIntervalPredicate(intervalDirection), timeGrain = Grain.NoGrain))
)
tt(TimeData(timePred = predicate, timeGrain = td.timeGrain))
tt(TimeData(timePred = predicate, timeGrain = td.timeGrain, hint = Hint.FinalRule))
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ trait Rules extends DimRules {
val grains = List(
("second (grain)", "秒钟?", Second),
("minute (grain)", "分(?!贝)钟?", Minute),
("hour (grain)", "(小时|钟头|钟|点)", Hour),
("hour (grain)", "(小时|钟头|钟)", Hour),
("day (grain)", "(天(?!气(?!温))|日(?![元本]))", Day),
("week (grain)", WeekPattern, Week),
("month (grain)", "月", Month),
("quarter (grain)", "季度", Quarter),
("year (grain)", "年", Year)
)

val latentExpr = Set("分", "钟", "点")
val latentExpr = Set("分", "钟")

override def dimRules: List[Rule] = grains.map {
case (name, regexPattern, grain) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ object predicates {
case Token(Time | Date, td: TimeData) => hints.contains(td.hint)
}

val isNotHint: Hint => Predicate = (hint: Hint) => {
case Token(Time | Date, td: TimeData) => td.hint != hint
def isNotHint(hints: Hint*): Predicate = {
case Token(Time | Date, td: TimeData) => !hints.contains(td.hint)
}

val is24oClockOfDay: Predicate = {
Expand Down
Loading