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
65 changes: 13 additions & 52 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "py-text2num"
version = "3.0.0"
edition = "2021"
version = "3.0.1"
edition = "2024"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "_text2num"
crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.27"
text2num = "2.6.2"
pyo3 = "0.28"
text2num = "2.6.3"
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
use pyo3::types::PyList;
use text2num::{
get_interpreter_for, replace_numbers_in_text, text2digits, word_to_digit::find_numbers_iter,
Occurence, Token,
Occurence, Token, get_interpreter_for, replace_numbers_in_text, text2digits,
word_to_digit::find_numbers_iter,
};

/// Return the text of ``text`` with all the ``lang`` spelled numbers converted to digits.
Expand Down Expand Up @@ -66,7 +66,7 @@ impl<'a> Token for TokenAdaptor<'a> {
}

fn text_lowercase(&self) -> &str {
&self.text_cache_lowercase.as_str()
self.text_cache_lowercase.as_str()
}

fn nt_separated(&self, previous: &Self) -> bool {
Expand All @@ -78,7 +78,11 @@ impl<'a> Token for TokenAdaptor<'a> {
}

fn not_a_number_part(&self) -> bool {
self.model.call_method0("not_a_number_part").unwrap().extract().unwrap()
self.model
.call_method0("not_a_number_part")
.unwrap()
.extract()
.unwrap()
}
}

Expand Down
3 changes: 3 additions & 0 deletions tests/test_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def test_alpha2digit(self):
"25 vaches, 12 poulets et 125 kg de pommes de terre."
)

def test_alpha2digit_all(self):
self.assertEqual(text_to_num.alpha2digit("1 2 un 8", "fr", threshold=0.0), "1 2 1 8")


class TestBindingExtensions(TestCase):

Expand Down