您需要的最后一个在线词典框架。(?)
项目描述
[ ~ PyUp.io 扫描的依赖关系 ~ ]
zdict 是一个 CLI 词典框架,主要专注于任何类型的在线词典。该项目最初来自https://github.com/chenpc/ydict,它是 Yahoo! 的 CLI 工具。在线字典。在对原始项目进行大量重构后,包括:
从 Python 2 更改为 Python 3
专注于为任何类型的在线词典提供灵活的框架,而不仅仅是用于查询 Yahoo! 的 CLI 工具。在线字典。
基于开源项目框架。
所以,我们决定创建一个新项目。
<nav class="contents" id="table-of-contents" role="doc-toc">
目录
安装
来自PyPI:
pip install zdict
来自GitHub:
pip install git+https://github.com/zdict/zdict.git
来自Docker 中心:
# Pull the image of latest commit of master branch from Docker Hub
docker pull zdict/zdict
# Pull the image of latest release from Docker Hub
docker pull zdict/zdict:release
# Pull the image of specific release version from Docker Hub
docker pull zdict/zdict:${version}
docker pull zdict/zdict:v0.10.0
如何运行 zdict docker 镜像
# Run interactive mode
docker run -it --rm zdict/zdict # latest commit
docker run -it --rm zdict/zdict:release # latest release
docker run -it --rm zdict/zdict:v0.10.0 # use zdict v0.10.0
docker run -it --rm zdict/zdict:$tag # with specific tag
# Run normal mode
docker run -it --rm zdict/zdict apple bird # latest commit
docker run -it --rm zdict/zdict:release apple bird # latest release
docker run -it --rm zdict/zdict:v0.10.0 apple bird # use zdict v0.10.0
docker run -it --rm zdict/zdict:$tag apple bird # with specific tag
# You can also add the options while using docker run either interactive mode or normal mode
docker run -it --rm zdict/zdict:v0.10.0 -dt moe # use moe dict in interactive mode
docker run -it --rm zdict/zdict:v0.10.0 -dt moe 哈 # use moe dict in normal mode
用法
usage: zdict [-h] [-v] [-d] [-t QUERY_TIMEOUT] [-j [JOBS]] [-sp] [-su]
[-dt itaigi,moe,moe-taiwanese,spanish,oxford,jisho,yahoo,naer,wiktionary,urban,yandex,all]
[-ld] [-V] [-c] [--dump [PATTERN]] [-D]
[word [word ...]]
positional arguments:
word Words for searching its translation
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-d, --disable-db-cache
Temporarily not using the result from db cache. (still
save the result into db)
-t QUERY_TIMEOUT, --query-timeout QUERY_TIMEOUT
Set timeout for every query. default is 5 seconds.
-j [JOBS], --jobs [JOBS]
Allow N jobs at once. Do not pass any argument to use
the number of CPUs in the system.
-sp, --show-provider Show the dictionary provider of the queried word
-su, --show-url Show the url of the queried word
-dt itaigi,moe,moe-taiwanese,spanish,oxford,jisho,yahoo,naer,wiktionary,urban,yandex,all, --dict itaigi,moe,moe-taiwanese,spanish,oxford,jisho,yahoo,naer,wiktionary,urban,yandex,all
Must be seperated by comma and no spaces after each
comma. Choose the dictionary you want. (default:
yahoo) Use 'all' for qureying all dictionaries. If
'all' or more than 1 dictionaries been chosen, --show-
provider will be set to True in order to provide more
understandable output.
-ld, --list-dicts Show currently supported dictionaries.
-V, --verbose Show more information for the queried word. (If the
chosen dictionary have implemented verbose related
functions)
-c, --force-color Force color printing (zdict automatically disable
color printing when output is not a tty, use this
option to force color printing)
--dump [PATTERN] Dump the querying history, can be filtered with regex
-D, --debug Print raw html prettified by BeautifulSoup for
debugging.
截图
雅虎词典
正常模式
你好
交互模式
zdict
萌典 萌典
城市词典
西班牙语词典
地所日语词典
Yandex 翻译
牛津词典
要使用此源,您应该首先应用API 密钥并将其放在~/.zdict/oxford.key下,格式如下:
app_id, app_key
维基词典
iTaigi-爱台语
国家教育研究院 - 双语词汇、学术名词暨辞书资讯网
开发与贡献
测试
在开发过程中,您可以将我们的项目安装为可编辑的。如果您使用virtualenv,您可能需要为zdict创建一个新环境:
$ git clone https://github.com/zdict/zdict.git $ cd zdict $ pip install -e .
使用上面的命令安装后,修改后执行zdict即可。无需再次安装。
安装测试包:
$ pip install -r requirements-test.txt
或者:
$ make install-test-deps
使用以下命令执行测试:
$ py.test
或者:
$ make test
运行测试后,我们会得到一个 html 格式的覆盖率报告。我们可以浏览一下:
$ cd htmlcov $ python -m http.server
此外,在setup.cfg 中有一些 py.test 的配置。如果需要,请更改它。
调试
当您的测试用例失败时,py.test可以提示pdb shell:
$ py.test --pdb
或者:
$ make test-with-pdb
错误报告
随时向https://github.com/zdict/zdict/issues发送错误报告。请附上错误消息并描述如何重现错误。也欢迎 PR。
请在发送错误报告之前使用-d/--disable-db-cache选项进行查询。有时我们为字典修改数据库中的数据模式,但 zdict 的默认字典查询使用数据库中的缓存,该缓存可能存储在旧模式中。这可能会在显示结果时导致错误。只需使用-d/--disable-db-cache来更新数据库中的缓存。