Skip to content

Commit

Permalink
Merge pull request #82 from bact/add-pyo3-signature
Browse files Browse the repository at this point in the history
[nlpo3-python]: Add pyo3 signature to functions
  • Loading branch information
bact authored Nov 11, 2024
2 parents 2028d36 + e002a32 commit 5d5221e
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 4 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "nlpo3"
version = "1.4.0"
edition = "2018"
license = "Apache-2.0"
license-file = "LICENSE"
authors = ["Thanathip Suntorntip Gorlph"]
description = "Thai natural language processing library, with Python and Node bindings"
homepage = "https://github.com/PyThaiNLP/nlpo3/"
Expand Down
1 change: 0 additions & 1 deletion nlpo3-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "nlpo3-cli"
version = "0.2.1-dev"
edition = "2018"
license = "Apache-2.0"
license-file = "LICENSE"
authors = ["Vee Satayamas <[email protected]>"]
description = "Command line interface for nlpO3, a Thai natural language processing library"
documentation = "https://github.com/PyThaiNLP/nlpo3/tree/main/nlpo3-cli/README.md"
Expand Down
1 change: 0 additions & 1 deletion nlpo3-nodejs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "nlpo3-nodejs"
version = "1.0.0"
edition = "2018"
license = "Apache-2.0"
license-file = "LICENSE"
authors = ["Thanathip Suntorntip Gorlph"]
description = "Node binding for nlpO3 Thai language processing library"
documentation = "https://github.com/PyThaiNLP/nlpo3/tree/main/nlpo3-nodejs/README.md"
Expand Down
1 change: 0 additions & 1 deletion nlpo3-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "nlpo3-python"
version = "1.3.1-dev"
edition = "2018"
license = "Apache-2.0"
license-file = "LICENSE"
authors = ["Thanathip Suntorntip Gorlph"]
description = "Python binding for nlpO3 Thai language processing library"
exclude = ["notebooks"]
Expand Down
2 changes: 2 additions & 0 deletions nlpo3-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ lazy_static! {
/// returns list of valid utf-8 bytes list
/// signature: (text: str, dict_name: str, safe: boolean = false, parallel: boolean = false) -> List[List[u8]]
#[pyfunction]
#[pyo3(signature = (text, dict_name, safe=false, parallel=false))]
fn segment(text: &PyString, dict_name: &str, safe: bool, parallel: bool) -> PyResult<Vec<String>> {
if let Some(loaded_dict) = DICT_COLLECTION.lock().unwrap().get(dict_name) {
let result = loaded_dict.segment_to_string(text.to_str()?, safe, parallel);
Expand All @@ -48,6 +49,7 @@ fn segment(text: &PyString, dict_name: &str, safe: bool, parallel: bool) -> PyRe
/// returns a tuple of string of loading result and a boolean
/// signature: (file_path: str, dict_name: str) -> (str, boolean)
#[pyfunction]
#[pyo3(signature = (file_path, dict_name))]
fn load_dict(file_path: &str, dict_name: &str) -> PyResult<(String, bool)> {
let mut dict_col_lock = DICT_COLLECTION.lock().unwrap();
if dict_col_lock.get(dict_name).is_some() {
Expand Down

0 comments on commit 5d5221e

Please sign in to comment.