{"id":15013592,"url":"https://github.com/finalion/wordquery","last_synced_at":"2025-04-07T13:09:28.814Z","repository":{"id":70669394,"uuid":"74213880","full_name":"finalion/WordQuery","owner":"finalion","description":"word fast-querying addon for anki","archived":false,"fork":false,"pushed_at":"2020-03-18T16:23:21.000Z","size":34165,"stargazers_count":292,"open_issues_count":45,"forks_count":59,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-07T13:09:23.497Z","etag":null,"topics":["anki","mdx","stardict"],"latest_commit_sha":null,"homepage":"https://ankiweb.net/shared/info/775418273","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/finalion.png","metadata":{"files":{"readme":"README-CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-11-19T14:36:20.000Z","updated_at":"2025-03-14T12:32:01.000Z","dependencies_parsed_at":"2023-02-22T18:30:20.360Z","dependency_job_id":null,"html_url":"https://github.com/finalion/WordQuery","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/finalion%2FWordQuery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/finalion%2FWordQuery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/finalion%2FWordQuery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/finalion%2FWordQuery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/finalion","download_url":"https://codeload.github.com/finalion/WordQuery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657281,"owners_count":20974345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anki","mdx","stardict"],"created_at":"2024-09-24T19:44:30.671Z","updated_at":"2025-04-07T13:09:28.790Z","avatar_url":"https://github.com/finalion.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WordQuery 插件(anki)\n\n## 主要功能\n\n1. 快速零散制卡 \n\n   在添加卡片和编辑卡片界面，插件辅助完成单词释义的查询和自动填充。 \n\n2. 批量制卡 \n\n   在浏览器界面选择多个单词，插件辅助完成选中单词释义的批量查询和自动填充。 \n\n3. 本地词典支持\n\n   支持**mdx格式**词典和**stardict格式**词典。\n\n4. 网络词典支持  \n\n   支持网络词典的查询，目前内置有道、百词斩等插件。\n   \n   所有词典以插件形式实现，用户可自行定义、修改和删除。插件定义和实现方式可参考[该节](#词典服务插件定义)。\n\n\n\n## 使用方法\n\n### 安装\n\n1. [https://github.com/finalion/WordQuery](https://github.com/finalion/WordQuery)下载并放到anki插件文件夹\n\n2. 安装代码775418273\n\n### 词典文件夹设置\n\n1. “工具”菜单--\u003e\"WordQuery\"，弹出设置界面；\n\n2. 点击“词典文件夹”按钮，在弹出的对话框中通过“+”或“-”增加或删除文件夹，支持递归查找。\n\n    ![](screenshots/add_dict_folders.png)\n\n3. 其他设置    \n\n   - 使用文件名作为词典名：不选中则使用词典中的特定标题字段作为词典名\n   \n   - 导出媒体文件：选中则导出词典解释中包含的**音频**\n\n\n### 笔记类型选择\n\n在设置界面中，点击“选择笔记类型”按钮，选择要设定的笔记类型；   \n\n![](screenshots/note_type.png)\n\n\n### 查询单词字段设置\n\n单选框选中要查询的单词字段.\n\n\n### 待填充词典字段与笔记区域的映射\n\n为每个笔记区域映射待查询的词典以及词典字段：   \n\n![](screenshots/dicts.png)\n\n词典下拉框选项中包括三部分，各部分之间有分割线：\n\n- 第一部分：“不是词典字段”\n\n- 第二部分：设定文件夹中包含的可支持的本地词典\n\n- 第三部分：网络词典\n\n\n### 查询并填充释义\n    \n插件可在多种编辑模式下快速查询并添加单词释义。   \n\n1. “添加笔记”界面和“编辑笔记”界面\n\n    - 点击“Query”按钮查询并填充全部字段的释义；\n\n    - 右键菜单“Query All Fields”查询并填充全部字段的释义；\n\n    - 右键菜单“Query Current Field”查询并填充当前字段的释义；\n\n    - 右键菜单“Options”查看修改笔记区域和词典字段的映射；\n\n2. 浏览器\n\n    - 选择多个卡片，工具栏菜单“WoryQuery”选择“查询选中单词”，查询并填充所有选中单词全部字段的释义；\n\n    ![](screenshots/editor.png)\n\n    ![](screenshots/browser.png)\n\n所有操作均支持快捷键，默认为\"Ctrl+Q\"，可[修改](#快捷键自定义)。\n\n\n## 其他Tips\n\n### 快捷键自定义\n\n“工具”菜单--\u003e“插件”--\u003e\"wordquery\"--\u003e编辑，找到并修改快捷键设置:\n\n```python\n# shortcut\nshortcut = 'Ctrl+Q'\n```\n\n\n## 词典服务插件定义\n\n### 实现类\n\n继承WebService，使用```@register(label)``` 装饰。参数```label```作为词典标签，出现在词典下拉列表中。例如\n```python\n@register(u'有道词典')\nclass Youdao(WebService):\n    \"\"\"service implementation\"\"\"\n```\n如果不注册```label```，则默认使用**类名称**作为标签。\n\n### 词典字段导出函数定义\n\n词典字段导出函数返回查询词典相应字段的释义，使用```@export(fld_name, order)``` 装饰。\n\n- 参数```fld_name```为词典字段名称，出现在词典字段下拉列表中\n\n- 参数```order```为词典字段在下拉列表中的顺序，小号在上，大号在下，但号码无需连续。\n\n例如，\n```python\n@export(u'美式音标', 1)\ndef fld_phonetic_us(self):\n    return self._get_field('phonitic_us')\n\n@export(u'英式音标', 2)\ndef fld_phonetic_uk(self):\n    return self._get_field('phonitic_uk')\n```\n\n### 字段修饰（可选）\n\n使用```@with_style(**kwargs)```修饰导出词典字段函数，支持参数包括，\n\n- ```cssfile```\n\n    词典（字段）使用的css文件，需放置在```service```模块的```static```文件夹下。\n\n- ```css```\n\n    词典（字段）使用的css字符串。\n\n- ```jsfile```\n\n    词典（字段）使用的js文件，需放置在```service```模块的```static```文件夹下。\n\n- ```js```\n\n    词典（字段）使用的js字符串。\n\n- ```need_wrap_css```\n\n    为了避免不同字典css样式命名重复可能带来的样式混乱，设置该参数为```True```，插件可通过添加全局```div```对样式表和词典释义结果进行包装。需要定义添加的全局```div```的类名```wrap_class```。\n\n    包装之后的css文件为```*orig_name*_wrap.css```。\n\n    *目前包装方法比较粗糙，待持续验证和改进。*\n\n- ```wrap_class```\n\n    全局```div```类名，```need_wrap_css```为```True```时有效。\n\n例如，\n```python\n@with_styles(cssfile='_youdao.css', need_wrap_css=True, wrap_class='youdao')\ndef _get_singledict(self, single_dict, lang='eng'):\n    url = \"http://m.youdao.com/singledict?q=%s\u0026dict=%s\u0026le=%s\u0026more=false\" % (\n        self.word, single_dict, lang)\n    try:\n        return urllib2.urlopen(url, timeout=5).read()\n    except:\n        return ''\n```\n\n### Cache使用\n\n为了避免对网络词典服务的重复查询，可在必要时对中间结果进行缓存。方法包括，\n\n- ```cache_this(result)```\n\n    缓存当前结果。\n\n- ```cached(key)```\n    \n    检查```key```是否被缓存。\n\n- ```cache_result(key)```\n        \n    返回缓存结果。\n\n具体可参考[有道词典 youdao.py](wquery/service/youdao.py)实现方式。    \n\n\n## 插件所使用的外部库\n\n- [mdict-query](https://github.com/mmjang/mdict-query)\n- [pystardict](https://github.com/lig/pystardict)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffinalion%2Fwordquery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffinalion%2Fwordquery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffinalion%2Fwordquery/lists"}