Skip to main content

lindera_dictionary/loader/
unknown_dictionary.rs

1use std::path::Path;
2
3use crate::LinderaResult;
4use crate::dictionary::unknown_dictionary::UnknownDictionary;
5use crate::util::read_file;
6
7/// Loader for unknown dictionary data from disk files.
8pub struct UnknownDictionaryLoader {}
9
10impl UnknownDictionaryLoader {
11    /// Load unknown dictionary from a file in the specified directory.
12    ///
13    /// # Arguments
14    ///
15    /// * `input_dir` - Path to the directory containing unk.bin.
16    ///
17    /// # Returns
18    ///
19    /// An `UnknownDictionary` loaded from the file.
20    pub fn load(input_dir: &Path) -> LinderaResult<UnknownDictionary> {
21        let raw_data = read_file(input_dir.join("unk.bin").as_path())?;
22
23        let mut aligned_data = rkyv::util::AlignedVec::<16>::new();
24        aligned_data.extend_from_slice(&raw_data);
25
26        UnknownDictionary::load(&aligned_data)
27    }
28}