Skip to content

Commit

Permalink
update structure
Browse files Browse the repository at this point in the history
  • Loading branch information
AlongWY committed Apr 5, 2024
1 parent ce08462 commit 17f689c
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion python/extension/src/algorithms.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ltp::{drop_get_entities, eisner, viterbi_decode_postprocessing};
use ltp::utils::{drop_get_entities, eisner, viterbi_decode_postprocessing};
use pyo3::prelude::*;

/// Convert Tags to Entities
Expand Down
2 changes: 1 addition & 1 deletion python/extension/src/hook.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ltp::hook::Hook;
use ltp::utils::hook::Hook;
use pyo3::prelude::*;

#[pyclass(module = "ltp_extension.algorithms", name = "Hook", subclass)]
Expand Down
2 changes: 1 addition & 1 deletion python/extension/src/stnsplit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ltp::{stn_split_with_options, SplitOptions};
use ltp::utils::{stn_split_with_options, SplitOptions};
use pyo3::prelude::*;
use pyo3::types::{PyList, PyString};
use rayon::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion rust/ltp-cffi/src/stnsplit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Callback;
use ltp::stnsplit::{
use ltp::utils::stnsplit::{
stn_split as r_stn_split, stn_split_with_options as r_stn_split_with_options, SplitOptions,
};
use std::slice;
Expand Down
11 changes: 2 additions & 9 deletions rust/ltp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
pub mod eisner;
pub mod entities;
pub mod hook;
pub mod perceptron;
pub mod stnsplit;
pub mod viterbi;
pub mod utils;

pub use perceptron::{
Algorithm, CWSDefinition, NERDefinition, POSDefinition, PaMode, Perceptron, Trainer,
Expand All @@ -18,7 +14,4 @@ pub type POSModel = SerdePOSModel;
#[cfg(feature = "serialization")]
pub type NERModel = SerdeNERModel;

pub use eisner::eisner;
pub use entities::{drop_get_entities, get_entities};
pub use stnsplit::{stn_split, stn_split_with_options, SplitOptions};
pub use viterbi::viterbi_decode_postprocessing;

2 changes: 1 addition & 1 deletion rust/ltp/src/perceptron/definition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::collections::HashSet;
use std::fmt::Debug;
use std::io::Read;

use crate::get_entities;
use crate::utils::get_entities;
use crate::perceptron::Sample;
pub use cws::CWSDefinition;
pub use ner::NERDefinition;
Expand Down
2 changes: 1 addition & 1 deletion rust/ltp/src/perceptron/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl<Feature, ParamStorage, Param> Perceptron<NERDefinition, Feature, ParamStora
}
}

use crate::{get_entities, CWSDefinition, NERDefinition, POSDefinition};
use crate::{utils::get_entities, CWSDefinition, NERDefinition, POSDefinition};

impl<Feature, ParamStorage, Param> Perceptron<CWSDefinition, Feature, ParamStorage, Param>
where
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions rust/ltp/src/hook.rs → rust/ltp/src/utils/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ mod tests {
}

#[test]
fn test_dag() {
fn test_dag() -> Result<()> {
let mut dag = Dag::with_size_hint(5);
let mut ans: Vec<Vec<usize>> = vec![Vec::new(); 5];
for i in 0..=3 {
Expand All @@ -394,8 +394,10 @@ mod tests {
assert_eq!(dag.size_hint_for_iterator, 4);

for i in 0..=3 {
let edges: Vec<usize> = dag.iter_edges(i).collect();
let edges: Vec<usize> = dag.iter_edges(i)?.collect();
assert_eq!(ans[i], edges);
}

Ok(())
}
}
10 changes: 10 additions & 0 deletions rust/ltp/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pub mod eisner;
pub mod entities;
pub mod hook;
pub mod stnsplit;
pub mod viterbi;

pub use eisner::eisner;
pub use entities::{drop_get_entities, get_entities};
pub use stnsplit::{stn_split, stn_split_with_options, SplitOptions};
pub use viterbi::viterbi_decode_postprocessing;
File renamed without changes.
File renamed without changes.

0 comments on commit 17f689c

Please sign in to comment.