{"id":17987885,"url":"https://github.com/lujun9972/vocabulary2anki.py","last_synced_at":"2025-07-14T09:36:21.868Z","repository":{"id":52375375,"uuid":"79625459","full_name":"lujun9972/vocabulary2anki.py","owner":"lujun9972","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-10T14:10:21.000Z","size":44,"stargazers_count":16,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T13:36:51.601Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lujun9972.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-21T05:17:29.000Z","updated_at":"2024-03-10T00:51:48.000Z","dependencies_parsed_at":"2022-08-21T15:50:43.425Z","dependency_job_id":null,"html_url":"https://github.com/lujun9972/vocabulary2anki.py","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lujun9972/vocabulary2anki.py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujun9972%2Fvocabulary2anki.py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujun9972%2Fvocabulary2anki.py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujun9972%2Fvocabulary2anki.py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujun9972%2Fvocabulary2anki.py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lujun9972","download_url":"https://codeload.github.com/lujun9972/vocabulary2anki.py/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujun9972%2Fvocabulary2anki.py/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265269945,"owners_count":23737944,"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":[],"created_at":"2024-10-29T19:09:59.274Z","updated_at":"2025-07-14T09:36:21.803Z","avatar_url":"https://github.com/lujun9972.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+TITLE: README\n#+AUTHOR: lujun9972\n#+TAGS: vocabulary2anki\n#+DATE: [2017-01-21 六 23:10]\n#+LANGUAGE:  zh-CN\n#+OPTIONS:  H:6 num:nil toc:t \\n:nil ::t |:t ^:nil -:nil f:t *:t \u003c:nil\n\n* What is vocabulary2anki?\nvocabulary2anki是一款用python3写的小工具,用来批量查询英文单词的意义,然后以anki可以倒入的方式输出.\n\n它的特点在于可配置性,理论上通过配置 =vocabulary2anki.cfg= 可以从任意的json/xml格式的字典接口中查询意义.\n\n为了防止单个字典接口存在单词量不足的情况,允许你一次配置多个字典接口. (默认配置了有道和百词斩连个接口)\n\n若同一个单词在多个字典接口都能查到意义,则以配置文件中靠后配置的那个为准.\n** Usage\n#+BEGIN_SRC shell :exports both :results org\n./vocabulary2anki.py -h\n#+END_SRC\n\n#+RESULTS:\n#+BEGIN_SRC org\nusage: vocabulary2anki.py [-h] [-o dest_file] [--fmt format]\n                          [source_file [source_file ...]]\n\n查询单词意义,并以anki可以导入的方式输出\n\npositional arguments:\n  source_file   存放单词的源文件,每行一个词,如果不填,则会从标准输入读取单词\n\noptional arguments:\n  -h, --help    show this help message and exit\n  -o dest_file  存放结果的目标文件,如果省略,则会写入到标准输出中\n  --fmt format  指定输出的格式,其中{word},{mean},{accent},{sentence_en},{sentence_cn},{\n                img},{mp3}会被替换,默认值为\"{word}|{mean}|{accent}|{sentence_en}|{sent\n                ence_cn}|{img}|{mp3}\"\n#+END_SRC\n\n** example\n假设我有一个名为 =vocabulary.txt= 的文件,里面包含了一些不认识的单词:\n#+BEGIN_SRC text :tangle \"vocabulary.txt\"\n  vim\n  emacs\n#+END_SRC\n\n我要查询这两个单词的意义,英文例句与中文例句,并用 =|= 作为分隔符写入到 =anki.txt= 中,那么可以执行:\n#+BEGIN_SRC shell\n  ./vocabulary2anki.py --fmt \"{word}|{mean}|{accent}|{sentence_cn}\" -o anki.txt vocabulary.txt\n#+END_SRC\n\n#+RESULTS:\n\n则会发现程序新生成了一个 =anki.txt= 文件,其内容为:\n#+BEGIN_SRC text\n  vim|n.精力，活力|He's such an energetic guy, full of \u003cb\u003evim\u003c/b\u003e, vigor and spunk!|\n  emacs|n. 编辑器，编译与测试；功能强大的编辑环境||\n#+END_SRC\n\n其中 =vim= 在有道和百词斩中都能查到意思,由于百词斩的接口比较靠后,因此使用的是百词斩中的意思,而英文例句和中文例句在有道接口中是没有的,因此使用了百词斩中的内容.\n\n而 =emacs= 只在有道中能查询到释义,在百词斩中查不到,因此这是使用的是来自有道接口中的释义,而中英文例句则为空.\n  \n* How to Config\n下面是一个例子:\n#+BEGIN_SRC conf\n  [youdao]\n  type = xml\n  url = http://dict.youdao.com/fsearch?client=deskdict\u0026keyfrom=chrome.extension\u0026pos=-1\u0026doctype=xml\u0026xmlVersion=3.2\u0026dogVersion=1.0\u0026vendor=unknown\u0026appVer=3.1.17.4208\u0026le=eng\u0026q={}\n  means = .//custom-translation/translation/content\n  accent = .//phonetic-symbol\n  # mp3 = http://dict.youdao.com/dictvoice?audio={}\u0026type=2\n  [baicizhan]\n  type = json\n  url = http://mall.baicizhan.com/ws/search?w={}\n  means = mean_cn\n  mean_sep = ；\\s+\n  accent = accent\n  sentence_en = st\n  sentence_cn = sttr\n  mp3 = http://baicizhan.qiniucdn.com/word_audios/{}.mp3\n  img = img\n#+END_SRC\n\n配置项只能是 =type=, =url=, =means=, =mean_sep=, =accent=, =sentence_en=, =sentence_cn=, =mp3=, =img= 这几个.\n\n*其他的配置项会让程序出错!*\n  \n其中:\n| type        | 表示字典接口的格式,目前只支持json和xml两种格式的接口                                                                      |\n| url         | 表示字典接口的URL,其中的 ={}= 会被替换成待查询的单词                                                                      |\n| means       | 告诉程序,字典接口中那部分内容为释义,若接口为xml则它的值应该为一个xpath;若接口为json,则它的值是一个类似 =a.b.c= 这样的路径 |\n| accent      | 类似means,但是表示读音                                                                                                    |\n| sentence_en | 类似means,但是表示英文例句                                                                                                |\n| sentence_cn | 类似means,但是表示中文例句                                                                                                |\n| mp3         | 类似means,但是表示读音mp3的下载地址,且可以是一个类似url的字符串                                                           |\n| img         | 类似mp3,但是表示图片的下载地址                                                                                            |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flujun9972%2Fvocabulary2anki.py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flujun9972%2Fvocabulary2anki.py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flujun9972%2Fvocabulary2anki.py/lists"}