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
104 changes: 36 additions & 68 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.24"
text2num = "2.6.2"
pyo3 = "0.28"
text2num = "2.6.3"
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,19 @@ is in pure python and uses a less capable algorithm and has now been retired.

## Installation

We provide pre-compiled wheels for Linux, MacOS and Windows and for python 3.8 up to and including 3.13.
We provide pre-compiled wheels for Linux, MacOS and Windows:

| | py 3.8 | py 3.9 | py 3.10 | py 3.11 | py 3.12 | py 3.13 |
| ------------- | -------|------- | --------|---------|---------|---------|
| Linux aarch64 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Linux armv7l | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Linux ppc64le | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Linux s390x | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Linux x86_64 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Linux i686 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| win32 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| win amd64 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| macos 11 | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |

So all you need to do is this:

Expand Down
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
Loading