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

Misc. fixes for Spanish. #177

Merged
merged 1 commit into from
Jun 5, 2019
Merged
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
11 changes: 6 additions & 5 deletions grammar/es/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn rules_percentage(b: &mut RuleSetBuilder<Dimension>) -> RustlingResult<()>
b.rule_2("<number> per cent",
number_check!(),
// FIXME
b.reg(r#"(?:%|p\.c\.|por ?cien(?:tos?))?"#)?,
b.reg(r#"(?:%|p\.c\.|por ?cien(?:tos?)?)"#)?,
|number, _| Ok(PercentageValue(number.value().value()))
);
Ok(())
Expand Down Expand Up @@ -1321,13 +1321,13 @@ pub fn rules_time(b: &mut RuleSetBuilder<Dimension>) -> RustlingResult<()> {
|_, duration| Ok(duration.value().clone().prefixed())
);
b.rule_2("exactly <duration>",
b.reg(r#"(?:precis|exact)amente|justo"#)?,
b.reg(r#"(?:precis|exact)amente|(?:exact|just)o"#)?,
duration_check!(),
|_, duration| Ok(duration.value().clone().prefixed().precision(Precision::Exact))
);
b.rule_2("<duration> exactly",
duration_check!(),
b.reg(r#"(?:precis|exact)amente|justo"#)?,
b.reg(r#"(?:precis|exact)amente|(?:exact|just)o"#)?,
|duration, _| Ok(duration.value().clone().prefixed().precision(Precision::Exact))
);
b.rule_2("approx <duration>",
Expand Down Expand Up @@ -1607,8 +1607,9 @@ pub fn rules_numbers(b: &mut RuleSetBuilder<Dimension>) -> RustlingResult<()> {
..IntegerValue::default()
})
});
// Warning! Es uses long scale, i.e. 1 billion = 1000 million
b.rule_2("number millions",
integer_check_by_range!(1, 999),
integer_check_by_range!(1, 999999),
b.reg(r#"mill[oóò]n(?:es)?"#)?,
|a, _| {
Ok(IntegerValue {
Expand Down Expand Up @@ -1800,7 +1801,7 @@ pub fn rules_numbers(b: &mut RuleSetBuilder<Dimension>) -> RustlingResult<()> {
}
);
b.rule_1_terminal("ordinals 11-19",
b.reg(r#"d[eé]cimo? ?(primer|segund|tercer|cuart|quint|sext|s[eéè]ptim|octav|noven)(?:[oa]s?)?"#)?,
b.reg(r#"d[eé]cimo?s? ?(primer|segund|tercer|cuart|quint|sext|s[eéè]ptim|octav|noven)(?:[oa]s?)?"#)?,
|text_match| {
let value = match text_match.group(1).as_ref() {
"primer" => 11,
Expand Down