improve search.db

This commit is contained in:
polv committed 2026-03-09 17:00:54 +07:00
1 parent 189853cc23
commit 7b75d6302e
16 files changed
+641 -429

No files matched your search

+7 -5
View File
@@ -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),
})
}