Skip to content

Commit

Permalink
Merge pull request #29 from allo-media/master
Browse files Browse the repository at this point in the history
Release 2.1.4
  • Loading branch information
rtxm authored Aug 29, 2023
2 parents 2201628 + 2bd2aaa commit 8b7989b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "text2num"
version = "2.1.3"
version = "2.1.4"
authors = ["Allo-Media <contact@allo-media.fr>"]
edition = "2021"
license = "MIT"
Expand Down
2 changes: 2 additions & 0 deletions src/lang/en/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ mod tests {
assert_text2digits!("thirty-five thousands", "35000");
assert_text2digits!("thousand nine hundred twenty", "1920");
assert_text2digits!("thousand and nine hundred twenty", "1920");
assert_text2digits!("one billion twenty-five millions", "1025000000");
}

#[test]
Expand Down Expand Up @@ -327,6 +328,7 @@ mod tests {
"1st, 2nd, 3rd, 4th, 5th, 6th, 7th, 8th, 9th, 10th."
);
assert_replace_numbers!("Twenty seconds", "20 seconds");
assert_replace_numbers!("five hundred first", "501st");
}

#[test]
Expand Down
13 changes: 10 additions & 3 deletions src/lang/fr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ impl LangInterpretor for French {
let lemma = lemmatize(num_func);
let status = match lemmatize(lemma) {
"zéro" => b.put(b"0"),
"un" | "unième" | "premier" | "première" if !blocked.contains(Excludable::UN) => {
b.put(b"1")
}
"un" | "unième" if !blocked.contains(Excludable::UN) => b.put(b"1"),
"premier" | "première" if b.is_empty() => b.put(b"1"),
"deux" | "deuxième" if !blocked.contains(Excludable::DEUX) => b.put(b"2"),
"trois" | "troisième" if !blocked.contains(Excludable::TROIS) => b.put(b"3"),
"quatre" | "quatrième" if !blocked.contains(Excludable::QUATRE) => b.put(b"4"),
Expand Down Expand Up @@ -279,6 +278,7 @@ mod tests {
assert_text2digits!("quinze", "15");

assert_text2digits!("soixante quinze mille", "75000");
assert_text2digits!("un milliard vingt-cinq millions", "1025000000");
}

#[test]
Expand Down Expand Up @@ -395,6 +395,9 @@ mod tests {
);
assert_replace_numbers!("première seconde", "première seconde");
assert_replace_numbers!("premier second", "premier second");
assert_replace_numbers!("cinq cent unième", "501ème");
assert_replace_numbers!("cinq cent premiers", "500 premiers");
assert_replace_numbers!("cinq cent premier", "500 premier");
}

#[test]
Expand Down Expand Up @@ -436,6 +439,10 @@ mod tests {
);
assert_replace_numbers!("Un douzième essai", "Un 12ème essai");
assert_replace_numbers!("Premier, deuxième, troisième", "1er, 2ème, 3ème");
assert_replace_numbers!("un peu d'eau", "un peu d'eau");
assert_replace_numbers!("un peu moins", "un peu moins");
assert_replace_numbers!("un peu plus", "un peu plus");

assert_replace_all_numbers!("le logement neuf", "le logement neuf");
assert_replace_all_numbers!("le logement neuf deux sept", "le logement 9 2 7");
}
Expand Down
1 change: 1 addition & 0 deletions src/lang/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub trait LangInterpretor {
/// and "*uh*" is not significant, so this method would return `true` for them.
/// In the opposite, in the sentence "*two pigs and three chickens*", "*pigs*" and "*chickens*" are important words
/// that separate unrelated numbers. So the method would return `false` for them.
/// This function is used to find isolate numbers.
fn is_linking(&self, word: &str) -> bool;
/// In some languages, numbers can be homonyms to other words
fn is_ambiguous(&self, number: &str) -> bool;
Expand Down

0 comments on commit 8b7989b

Please sign in to comment.