Expand description
词库格式契约:拼音表的命名规则,以及 msime-pinyin.db、msime-wubi.db、msime-others.db 的文件内版本(metadata 表)。dict-builder 和运行时必须对它们取得一致,所以只在这里定义一次。完整规格见 docs/data-formats.md §4、§9、§12。
Constants§
- FORMAT_
VERSION - 词库格式版本:发布清单的
format_version与engine_compatibility.dictionary_format,也是 dict-builder 写进三个主库metadata表的format_version。引擎读得懂这个版本及以下的文件。 - LEGACY_
FORMAT_ VERSION - 没有
metadata表的文件按这个版本读:文件内版本出现之前发布的词库(dict-v2.0.39及更早)都是这样,必须照常能用。 - MAXIMUM_
NUMBERED_ SYLLABLES - Tables are numbered by syllable count up to this; longer keys go to the overflow bucket.
- METADATA_
FORMAT_ VERSION metadata里存放格式版本的那一行,与语言词库同名。- METADATA_
SCHEMA - 三个主库的
metadata表,形状与语言词库(language_dictionary::SCHEMA)的同名表相同:name是键,value是十进制文本。 - OVERFLOW_
BUCKET - SHIPPED_
INITIALS - First letters that have tables.
i,uandvstart no syllable, so they have none. - TABLE_
PREFIX
Functions§
- build_
table_ name - The table for a segmented key: by segment count and the first letter of the first segment.
- check_
format_ version - 读
connection所在文件的格式版本并检查引擎读不读得懂;file是写进错误信息的文件名(只给名字,不带路径)。没有metadata表时是LEGACY_FORMAT_VERSION。有表却读不出format_version(没有这一行,或表的列不对)、值不是非负整数、或比FORMAT_VERSION新时报DICTIONARY_FORMAT_UNSUPPORTED(EngineError::Failed),调用方不能把这样的文件当作已知格式去读:新版本的表可能换了列或换了语义,照旧读只会悄悄出错。连sqlite_master都读不出(不是数据库、被锁住),或读metadata时遇到被锁、读写出错、文件损坏这类与格式无关的错误时,原样返回EngineError::Sqlite,由调用方按它原来对读不了的文件的处理来办。 - quanpin_
table tbl_<n>_<initial>, ortbl_others_<initial>past seven syllables.Nonefor no syllables or an initial outsidea..=z. A shipped-set miss (i,u,v) still gets a name; the table simply does not exist, and readers treat that as no rows.