From 81ede267b11b9d2532cacc21af58c819159fad8c Mon Sep 17 00:00:00 2001 From: mh-northlander Date: Fri, 7 Jun 2024 11:26:24 +0900 Subject: [PATCH] reorder use statements --- python/src/build.rs | 11 +++++++---- python/src/dictionary.rs | 9 +++++---- python/src/errors.rs | 4 +++- python/src/pretokenizer.rs | 16 +++++++++------- python/src/projection.rs | 12 ++++++++---- python/src/tokenizer.rs | 1 - 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/python/src/build.rs b/python/src/build.rs index 9cff1d71..baf98b2a 100644 --- a/python/src/build.rs +++ b/python/src/build.rs @@ -14,18 +14,21 @@ * limitations under the License. */ -use crate::dictionary::get_default_resource_dir; -use crate::errors; -use pyo3::prelude::*; -use pyo3::types::{PyBytes, PyList, PyString, PyTuple, PyType}; use std::fs::{File, OpenOptions}; use std::io::BufWriter; use std::path::Path; + +use pyo3::prelude::*; +use pyo3::types::{PyBytes, PyList, PyString, PyTuple, PyType}; + use sudachi::analysis::stateless_tokenizer::DictionaryAccess; use sudachi::config::Config; use sudachi::dic::build::{DataSource, DictBuilder}; use sudachi::dic::dictionary::JapaneseDictionary; +use crate::dictionary::get_default_resource_dir; +use crate::errors; + pub fn register_functions(m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(build_system_dic, m)?)?; m.add_function(wrap_pyfunction!(build_user_dic, m)?)?; diff --git a/python/src/dictionary.rs b/python/src/dictionary.rs index 93918c2c..4bf18532 100644 --- a/python/src/dictionary.rs +++ b/python/src/dictionary.rs @@ -14,18 +14,18 @@ * limitations under the License. */ -use pyo3::prelude::*; -use pyo3::types::{PySet, PyString, PyTuple}; use std::convert::TryFrom; use std::fmt::Write; use std::ops::Deref; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::Arc; -use sudachi::analysis::Mode; -use crate::errors::{wrap, wrap_ctx, SudachiError as SudachiErr}; +use pyo3::prelude::*; +use pyo3::types::{PySet, PyString, PyTuple}; + use sudachi::analysis::stateless_tokenizer::DictionaryAccess; +use sudachi::analysis::Mode; use sudachi::config::{Config, ConfigBuilder, SurfaceProjection}; use sudachi::dic::dictionary::JapaneseDictionary; use sudachi::dic::grammar::Grammar; @@ -35,6 +35,7 @@ use sudachi::plugin::input_text::InputTextPlugin; use sudachi::plugin::oov::OovProviderPlugin; use sudachi::plugin::path_rewrite::PathRewritePlugin; +use crate::errors::{wrap, wrap_ctx, SudachiError as SudachiErr}; use crate::morpheme::{PyMorphemeListWrapper, PyProjector}; use crate::pos_matcher::PyPosMatcher; use crate::pretokenizer::PyPretokenizer; diff --git a/python/src/errors.rs b/python/src/errors.rs index 04827fd4..27bc0c7f 100644 --- a/python/src/errors.rs +++ b/python/src/errors.rs @@ -14,9 +14,11 @@ * limitations under the License. */ -use pyo3::{import_exception, PyResult}; use std::fmt::{Debug, Display}; +use pyo3::prelude::*; +use pyo3::{import_exception, PyResult}; + // Sudachi exception class is defined in Python import_exception!(sudachipy.errors, SudachiError); diff --git a/python/src/pretokenizer.rs b/python/src/pretokenizer.rs index d959285f..6e373289 100644 --- a/python/src/pretokenizer.rs +++ b/python/src/pretokenizer.rs @@ -14,21 +14,23 @@ * limitations under the License. */ -use crate::dictionary::PyDicData; -use crate::errors::wrap; -use crate::morpheme::{PyMorphemeList, PyMorphemeListWrapper, PyProjector}; +use std::cell::RefCell; +use std::sync::Arc; + use pyo3::intern; use pyo3::prelude::*; use pyo3::sync::GILOnceCell; use pyo3::types::{PyList, PySlice, PyTuple, PyType}; -use std::cell::RefCell; -use std::sync::Arc; +use thread_local::ThreadLocal; -use crate::projection::MorphemeProjection; use sudachi::analysis::stateful_tokenizer::StatefulTokenizer; use sudachi::dic::subset::InfoSubset; use sudachi::prelude::Mode; -use thread_local::ThreadLocal; + +use crate::dictionary::PyDicData; +use crate::errors::wrap; +use crate::morpheme::{PyMorphemeList, PyMorphemeListWrapper, PyProjector}; +use crate::projection::MorphemeProjection; /// This struct perform actual tokenization /// There should be at most one instance per thread of execution diff --git a/python/src/projection.rs b/python/src/projection.rs index 2c2cc2be..a7d61c33 100644 --- a/python/src/projection.rs +++ b/python/src/projection.rs @@ -14,18 +14,22 @@ * limitations under the License. */ -use crate::dictionary::PyDicData; -use crate::morpheme::PyProjector; -use pyo3::types::PyString; -use pyo3::{PyResult, Python}; use std::convert::TryFrom; use std::ops::Deref; use std::sync::Arc; + +use pyo3::prelude::*; +use pyo3::types::PyString; +use pyo3::{PyResult, Python}; + use sudachi::analysis::stateless_tokenizer::DictionaryAccess; use sudachi::config::SurfaceProjection; use sudachi::pos::PosMatcher; use sudachi::prelude::Morpheme; +use crate::dictionary::PyDicData; +use crate::morpheme::PyProjector; + pub(crate) trait MorphemeProjection { fn project<'py>(&self, m: &Morpheme>, py: Python<'py>) -> &'py PyString; } diff --git a/python/src/tokenizer.rs b/python/src/tokenizer.rs index 1a8446e0..4e94a040 100644 --- a/python/src/tokenizer.rs +++ b/python/src/tokenizer.rs @@ -21,7 +21,6 @@ use std::sync::Arc; use pyo3::prelude::*; use sudachi::analysis::stateful_tokenizer::StatefulTokenizer; - use sudachi::dic::subset::InfoSubset; use sudachi::prelude::*;