日期:2025/04/02 05:34来源:未知 人气:53
数图2.10.0版新增#检索表工具。该工具本质上是个离线词典,具备分类检索表折叠交互功能。
一、数图检索表的特点
小编曾在2008年前后制作过一款名为《中国高等植物物种检索词典》的MDict词库。为实现检索表分支条目的折叠和跳转功能,该词库将检索表重构成很多词条,其折叠效果只是一种模拟,实质是词条间跳转。而数图检索表词典直接支持词条内检索表的折叠交互,使用体验有了提升。
数图检索表工具在检索表的展示上还有个小创新,即在折叠时,展示从一级分支到末端分支各分支的兄弟分支 。这使得在看到当前分支判断路径的同时,还可以看到被否定的分支判断(图3灰色、小字所示),且支持切换分支。这非常有利于提高工作效率。
图1 词条搜索
图2 词条展示
图3 词条中检索表的交互效果
二、使用方法
1. 获取词库
数图APP安装包不包含任何词库,用户需自行导入词库。小编制作了《中国植物志数图检索表词库》,词库数据与上文提到的MDict词库相同,即以中国植物志为主体,增加了拉丁学名解释等数据。图1中展示的内容即来自词库。该词库仅供学习使用,词库所用数据的版权归原作者所有。
上述词库文件名为“中国植物志_数图检索表词库_20230303_先解压看说明.zip”。获取下载地址,请私信。
2. 导入词库
将下载得到的zip文件解压,将解压得到的dmkt文件发送给微信,然后在微信内点击该文件消息,选择“其它应用打开”,选择“数图”(或数图本、或数图田调等别名)。此时将启动数图,并开始导入。词库包含词条43000多条,导入需持续1分钟或更长,需耐心等待,直至提示导入成功。
3. 使用检索表
检索表工具的入口在首页“工具”卡片中的底部,“其它”栏内(见图2左)。检索表通过页面顶部的搜索框搜索词条。搜索模式为模糊搜索。
就《中国植物志数图检索表词库》而言,词条名为分类群的“中文名 + 拉丁名”,因而可使用中文名或拉丁名搜索。
图4 数图检索表工具入口
图5 数图检索表工具界面
图6 数图检索表词条搜索结果
三、制作词库
1. 词库文件格式
数图检索表词库为单纯的XML格式,并以“dmkt”为文件后缀名。文件的格式示例见下文。
<?xml version='1.0' encoding='utf-8'?>
需说明的是,每个“KeyTable”标签对应一个词条,其属性“uuid”用于识别词条,需保证唯一,否则导入后会被覆盖。KeyTable标签的“title”属性为检索表模糊搜索的目标。“Branches”标签部分为类群的检索表,数图检索表对其特殊处理,使得具备交互功能,但此部分并非必须。
2. 制作工具
小编使用Python制作词库。由于所用脚本还比较粗陋,本文暂且仅展示核心代码。如需要帮助请联系小编。
branch_queue = [item for item in branches] while len(branch_queue) > 0: father = branch_queue.pop(0) father_id = father["id"] if father_id is None: continue key_table_sql = f"SELECT branch,leaf_taxon_id, branch_id FROM rtrees WHERE root_taxon_id = {id} AND father_branch_id = '{father_id}' ORDER BY sn DESC" cursor.execute(key_table_sql) key_table_rows = cursor.fetchall() if len(key_table_rows) == 0: continue for row in key_table_rows: son = {"description": row[0], "branches": []} if row[1] is not None and row[1] != "": target = get_entry_title(cursor, row[1]) if target: son["target"] = target if row[2] is not None and row[2] != "": son["id"] = row[2] branch_queue.insert(0, son) father["branches"].insert(0, son) entry = {"uuid": uuid, "title": title, "familyChain": family_chain, "keyTableDescriptions": descriptions, "branches": branches } entryEle = Element("KeyTable", uuid=uuid, title=title) familyChainEle = Element("FamilyChain") for node in family_chain: nodeEle = Element("FamilyChainText") nodeEle.text = node familyChainEle.append(nodeEle) entryEle.append(familyChainEle) descriptionsEle = Element("KeyTableDescriptions") entryEle.append(descriptionsEle) for descr in descriptions: descrEle = Element("KeyTableDescription", tag=descr['tag']) descrEle.text = descr['description'] descriptionsEle.append(descrEle) if len(branches) > 0: branchesEle = Element("Branches") entryEle.append(branchesEle) branchStake = [b for b in branches] fatherBranchStake = [branchesEle for i in range(0, len(branches))]
branchEle = Element("Branch") branchDescr = Element("BranchDescription") branchDescr.text = b['description'] branchEle.append(branchDescr) fatherBranchEle.append(branchEle) if b.get('target') is not None: branchTarget = Element("BranchTarget") branchTarget.text = b['target'] branchEle.append(branchTarget) if b.get('branches') is not None and len(b['branches']) > 0: b["branches"].reverse() branchesEle = Element("Branches") branchEle.append(branchesEle) for son in b["branches"]: branchStake.insert(0, son) fatherBranchStake.insert(0, branchesEle) root.append(entryEle)
四、附记
图检索表以具有交互登录的检索表为特点,但并不要求词条必须由检索表部分,它就是一个特殊的词典工具。
目前数图检索表尚不支持图片、音频等媒体数据。