lindera_dictionary/loader/
connection_cost_matrix.rs1use std::path::Path;
2
3use crate::LinderaResult;
4use crate::dictionary::connection_cost_matrix::ConnectionCostMatrix;
5#[cfg(feature = "mmap")]
6use crate::util::mmap_file;
7use crate::util::read_file;
8
9pub struct ConnectionCostMatrixLoader {}
11
12impl ConnectionCostMatrixLoader {
13 pub fn load(input_dir: &Path) -> LinderaResult<ConnectionCostMatrix> {
23 let data = read_file(input_dir.join("matrix.mtx").as_path())?;
24
25 Ok(ConnectionCostMatrix::load(data))
26 }
27
28 #[cfg(feature = "mmap")]
38 pub fn load_mmap(input_dir: &Path) -> LinderaResult<ConnectionCostMatrix> {
39 let data = mmap_file(input_dir.join("matrix.mtx").as_path())?;
40
41 Ok(ConnectionCostMatrix::load(data))
42 }
43}