Add optional support for serde
This commit is contained in:
parent
bacf82c8cc
commit
5127aac1ec
|
@ -12,10 +12,12 @@ documentation = "https://docs.rs/instant-segment"
|
|||
[features]
|
||||
__test_data = ["test-cases"]
|
||||
test-cases = []
|
||||
with-serde = ["serde", "ahash/serde", "smartstring/serde"]
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.7.0"
|
||||
smartstring = "0.2.5"
|
||||
serde = { version = "1.0.123", features = ["derive"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
bencher = "0.1.5"
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use std::ops::{Index, Range};
|
||||
use std::str;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use smartstring::alias::String;
|
||||
|
||||
#[cfg(feature = "test-cases")]
|
||||
|
@ -9,6 +11,7 @@ pub mod test_cases;
|
|||
pub mod test_data;
|
||||
|
||||
/// Central data structure used to calculate word probabilities
|
||||
#[cfg_attr(feature = "with-serde", derive(Deserialize, Serialize))]
|
||||
pub struct Segmenter {
|
||||
unigrams: HashMap<String, f64>,
|
||||
bigrams: HashMap<(String, String), f64>,
|
||||
|
|
Loading…
Reference in New Issue