mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-09 17:39:35 +00:00
improve search.db
This commit is contained in:
1 parent
189853cc23
commit
7b75d6302e
16 files changed
+641
-429
No files matched your search
@@ -1,6 +1,7 @@
|
||||
use std::{fs::File, path::Path};
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
use vibrato_rkyv::CacheStrategy;
|
||||
|
||||
use crate::CJDicError;
|
||||
|
||||
@@ -20,16 +21,17 @@ pub struct TokenizeSegment {
|
||||
pub details: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Tokenizer {
|
||||
ja_tokenizer: vibrato::Tokenizer,
|
||||
ja_tokenizer: vibrato_rkyv::Tokenizer,
|
||||
}
|
||||
|
||||
impl Tokenizer {
|
||||
pub fn new(vibrato_dict: impl AsRef<Path>) -> Result<Self, CJDicError> {
|
||||
let reader = zstd::Decoder::new(File::open(vibrato_dict)?)?;
|
||||
let dictionary = vibrato::Dictionary::read(reader)?;
|
||||
let dictionary =
|
||||
vibrato_rkyv::Dictionary::from_zstd(vibrato_dict, CacheStrategy::GlobalCache)?;
|
||||
Ok(Self {
|
||||
ja_tokenizer: vibrato::Tokenizer::new(dictionary),
|
||||
ja_tokenizer: vibrato_rkyv::Tokenizer::new(dictionary),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user