Skip to main content

sudachi/dic/word_info/
raw.rs

1/*
2 * Copyright (c) 2026 Works Applications Co., Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17use crate::dic::lexicon::strings::StringPointer;
18
19/// Parsed raw binary representation of a word info entry.
20///
21/// word id/ref fields are typed as u32 to avoid type conversion.
22/// crate::dic::word_info::{WordInfoData, WordInfoRefData} will handle those types.
23#[derive(Clone, Debug, Default)]
24pub struct WordInfoRawData {
25    pub pos_id: i16,
26
27    pub headword_strptr: StringPointer,
28    pub reading_form_strptr: StringPointer,
29    pub normalized_form: u32,
30    pub dictionary_form: u32,
31
32    /// bytes length of the index form in utf-8.
33    pub index_form_length: i16,
34    pub c_unit_split_length: i8,
35    pub b_unit_split_length: i8,
36    pub a_unit_split_length: i8,
37    pub word_structure_length: i8,
38    pub synonym_group_ids_length: i8,
39    pub user_data_flag: i8,
40
41    pub c_unit_split: Vec<u32>,
42    pub b_unit_split: Vec<u32>,
43    pub a_unit_split: Vec<u32>,
44    pub word_structure: Vec<u32>,
45    pub synonym_group_ids: Vec<i32>,
46    pub user_data: String,
47}
48
49#[derive(Clone, Debug, Default)]
50pub struct WordInfoFixedData {
51    pub pos_id: i16,
52    pub headword_strptr: StringPointer,
53    pub reading_form_strptr: StringPointer,
54    pub normalized_form: u32,
55    pub dictionary_form: u32,
56    pub index_form_length: i16,
57    pub c_unit_split_length: i8,
58    pub b_unit_split_length: i8,
59    pub a_unit_split_length: i8,
60    pub word_structure_length: i8,
61    pub synonym_group_ids_length: i8,
62    pub user_data_flag: i8,
63}
64
65pub(crate) struct WordInfoVariableData<'a> {
66    pub c_unit_split: &'a [u32],
67    pub b_unit_split: &'a [u32],
68    pub a_unit_split: &'a [u32],
69    pub word_structure: &'a [u32],
70    pub synonym_group_ids: &'a [i32],
71    pub user_data: &'a str,
72}