Skip to content

Commit

Permalink
add deprecated directive and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mh-northlander committed Jul 8, 2024
1 parent 5d8620e commit d1c3165
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
9 changes: 9 additions & 0 deletions python/py_src/sudachipy/sudachipy.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class SplitMode:
Unit to split text.
A == short mode
B == middle mode
C == long mode
"""

Expand Down Expand Up @@ -205,6 +207,9 @@ class Morpheme:
def get_word_info(self) -> WordInfo:
"""
Returns the word info.
..deprecated:: v0.6.0
Users should not touch the raw WordInfo.
"""
...

Expand Down Expand Up @@ -293,6 +298,7 @@ class Morpheme:
class MorphemeList:
"""
A list of morphemes.
An object can not be instantiated manually.
Use Tokenizer.tokenize("") to create an empty morpheme list.
"""
Expand All @@ -303,6 +309,9 @@ class MorphemeList:
def empty(cls, dict: Dictionary) -> MorphemeList:
"""
Returns an empty morpheme list with dictionary.
.. deprecated::
Use Tokenizer.tokenize("") if you need.
"""
...

Expand Down
4 changes: 2 additions & 2 deletions python/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn create_file(p: &Path) -> std::io::Result<File> {
/// :param output: Path to output built dictionray.
/// :param description: A description text to embed in the dictionary.
/// :return: A build report, list of (part, size, time).
///
///
/// :type matrix: pathlib.Path | str | bytes
/// :type lex: list[pathlib.Path | str | bytes]
/// :type output: pathlib.Path | str
Expand Down Expand Up @@ -106,7 +106,7 @@ fn build_system_dic<'p>(
/// :param output: Path to output built dictionray.
/// :param description: A description text to embed in the dictionary.
/// :return: A build report, list of (part, size, time).
///
///
/// :type system: pathlib.Path | str
/// :type lex: list[pathlib.Path | str | bytes]
/// :type output: pathlib.Path | str
Expand Down
4 changes: 2 additions & 2 deletions python/src/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl PyDicData {
/// :param config_path: path to the configuration JSON file, config json as a string, or a [sudachipy.Config] object.
/// :param config: alias to config_path, only one of them can be specified at the same time.
/// :param resource_dir: path to the resource directory folder.
/// :param dict: type of pre-packaged dictionary, referring to sudachidict_<dict_type> packages on PyPI: https://pypi.org/search/?q=sudachidict.
/// :param dict: type of pre-packaged dictionary, referring to sudachidict_<dict> packages on PyPI: https://pypi.org/search/?q=sudachidict.
/// Also, can be an _absolute_ path to a compiled dictionary file.
/// :param dict_type: deprecated alias to dict.
///
Expand All @@ -114,7 +114,7 @@ impl PyDictionary {
/// :param config_path: path to the configuration JSON file, config json as a string, or a [sudachipy.Config] object.
/// :param config: alias to config_path, only one of them can be specified at the same time.
/// :param resource_dir: path to the resource directory folder.
/// :param dict: type of pre-packaged dictionary, referring to sudachidict_<dict_type> packages on PyPI: https://pypi.org/search/?q=sudachidict.
/// :param dict: type of pre-packaged dictionary, referring to sudachidict_<dict> packages on PyPI: https://pypi.org/search/?q=sudachidict.
/// Also, can be an _absolute_ path to a compiled dictionary file.
/// :param dict_type: deprecated alias to dict.
///
Expand Down
6 changes: 6 additions & 0 deletions python/src/morpheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ impl PyMorphemeListWrapper {
#[pymethods]
impl PyMorphemeListWrapper {
/// Returns an empty morpheme list with dictionary.
///
/// .. deprecated:: 0.6.0
/// Use Tokenizer.tokenize("") if you need.
#[classmethod]
#[pyo3(text_signature = "(dict: Dictionary) -> MorphemeList")]
fn empty(_cls: &PyType, py: Python, dict: &PyDictionary) -> PyResult<Self> {
Expand Down Expand Up @@ -439,6 +442,9 @@ impl PyMorpheme {
}

/// Returns the word info.
///
/// ..deprecated:: v0.6.0
/// Users should not touch the raw WordInfo.
#[pyo3(text_signature = "(self, /) -> WordInfo")]
fn get_word_info(&self, py: Python) -> PyResult<PyWordInfo> {
let cat = PyModule::import(py, "builtins")?.getattr("DeprecationWarning")?;
Expand Down
2 changes: 2 additions & 0 deletions python/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ use crate::morpheme::{PyMorphemeListWrapper, PyProjector};
/// Unit to split text.
///
/// A == short mode
///
/// B == middle mode
///
/// C == long mode
///
/// :param mode: string representation of the split mode. One of [A,B,C] in captital or lower case.
Expand Down

0 comments on commit d1c3165

Please sign in to comment.