Skip to content
Merged
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 @@ -63,6 +63,12 @@ object Predicates {
case _ => false
}

val isNonNegative: Predicate = {
case Token(Numeral, NumeralData(v, _, _, _, _, precision)) => precision == 0 && isInteger(v) && v >= 0
case Token(UnitNumber, NumeralData(v, _, _, _, _, precision)) => precision == 0 && isInteger(v) && v >= 0
case _ => false
}

val isInteger: Predicate = {
case Token(_, NumeralData(v, _, _, _, _, precision)) => precision == 0 && isInteger(v)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ trait Rules extends DimRules {
val n = math.floor(v).toInt
// 2012年 不召回, 两千年召回
if (seq.nonEmpty && g == Year && 1950 <= n && n <= 2050) None
else Token(Duration, DurationData(n, g, latent = latent, schema = durationSchema(n.toString, g)))
else Token(Duration, DurationData(n, g, latent = if (v == 0) true else latent, schema = durationSchema(n.toString, g)))
case _ => None
}
}
Expand All @@ -64,7 +64,7 @@ trait Rules extends DimRules {
name = "<integer> <unit-of-duration>",
pattern = List(
and(
isNatural,
isNonNegative,
isNumberOrUnitNumber,
not(isDigitLengthGt(1)),
// 一九八七 年 不召回
Expand Down
Loading