参照:http://code.google.com/p/babiloo/wiki/StarDict_format | ||
stardict词典格式分析 | ||
xxxxx.dict or xxxxx.dict.dz | ||
xxxxx.idx or xxxxx.idx.gz | ||
xxxxx.ifo | ||
xxxxx.syn | optional | |
☆dict文件 | ||
词典最原始的数据文件,文件结构遵从ifo文件中的定 义 。 | ||
数据类型没有定义的时候,遵循以下结构 | ||
word_1_data_1_type; // a single char identifying the data type | 数据类型 一个字符 | |
word_1_data_1_data; // the data | 数据 | |
word_1_data_2_type; | 数据类型 一个字符 | |
word_1_data_2_data; | 数据 | |
...... // the number of data entries for each word is determined by | ||
// word_data_size in .idx file | ||
word_2_data_1_type; | ||
word_2_data_1_data; | ||
...... | ||
☆idx文件 | ||
词条的索引文件,按升序排序。 | ||
word_str; // a utf-8 string terminated by '/0'. | 长度小于256,所收 词 条 单词 | |
word_data_offset; // word data's offset in .dict file | 32bit or 63bit 无符号整数 网络 字 节 序列 | |
word_data_size; // word data's total size in .dict file | 32-bit 无符号整数 网络字节序列 | |
☆ifo文件 | ||
词典定义说明等描述文件。 | ||
version= // required | 现在的官方解析软件只解析2.4.2和3.0.0 | |
拒绝读取替他版本。 | ||
如果是3.0.0版本,会用到idxoffsetbits属性。 | ||
bookname= // required | 词典名称,必须项。 | |
wordcount= // required | 词典收词数,idx中的总词数。注意不包括.syn中的词数 | |
synwordcount= // required if ".syn" file exists. | 同义词词数,多用于日文中的假名等 | |
idxfilesize= // required | 索引文件大小。为压缩前的大小。 | |
idxoffsetbits= // New in 3.0.0 | 设定值为32或64。指定索引文件中 每 个 索引的 长度位数 | |
author= | ||
email= | ||
website= | ||
description= // You can use <br> for new line. | ||
date= | ||
sametypesequence= // very important. | ||
e.g. | ||
sametypesequence=W | .dict数据文件全部由 .wav声音文件 组 成 | |
声音数据文件格式 | 所以,读取时可以直接忽略w 类型和长度 | |
按照idx文件中的数据长度读取即可。 | ||
word_1_data | ||
word_2_data | ||
word_3_data | ||
…… | ||
sametypesequence=tm | word_1_data_1_data + /0 | |
t:音 标格式 | word_1_data_2_data | |
m:纯文本数据格式 | word_2_data_1_data + /0 | |
word_2_data_2_data | ||
☆syn文件 | ||
同义词定义文件。2.4.8以上版本支持 | ||
synonym_word; // a utf-8 string terminated by '/0'. | 长度小于256,同义词词条单词 | |
original_word_index; // original word's index in .idx file. | 32bit,原词在索引文件中的位置 |