你需要的最后一个字典框架。(?)

zdict的Python项目详细描述


licenseversionpython versionmonth download

starsforkscontributorspull requestsissues

traviscirclecicoveralls

Join the chat at https://gitter.im/zdict/zdict


zdict是一个cli字典框架,主要关注任何类型的在线字典。 这个项目最初是由https://github.com/chenpc/ydict派生的,它是yahoo!的一个cli工具。在线词典。 在对原始项目进行了大量重构之后,包括:

  1. 从python 2更改为python 3 <> LI>专注于任何类型的在线词典的灵活框架,而不仅仅是CLI查询雅虎的工具!在线词典。
  2. 基于开源项目框架。

所以,我们决定创建一个新项目。



Installation

来自PyPI

pip install zdict

来自GitHub

pip install git+https://github.com/zdict/zdict.git

来自Docker Hub

# 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

usage: zdict [-h] [-v] [-d] [-t QUERY_TIMEOUT] [-j [JOBS]] [-sp] [-su]
             [-dt itaigi,moe,moe-taiwanese,spanish,oxford,jisho,yahoo,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,wiktionary,urban,yandex,all, --dict itaigi,moe,moe-taiwanese,spanish,oxford,jisho,yahoo,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.

Screenshots

Yahoo Dictionary

  • 正常模式

zdict hello

http://i.imgur.com/iFTysUz.png
  • 交互模式

zdict

http://i.imgur.com/NtbWXKH.png

Oxford Dictionary

http://i.imgur.com/VkPEfKh.png

要使用此源代码,您应该首先apply一个api密钥,并将其放在~/.zdict/oxford.key下,格式为:

app_id, app_key

Development & Contributing

Testing

在开发过程中,您可以将我们的项目安装为editable。 如果使用virtualenv,您可能需要为zdict创建一个新的环境:

$ git clone https://github.com/zdict/zdict.git
$ cd zdict
$ pip install -e .

一旦你用上面的命令安装了它, 修改后执行zdict。 不用再安装了。

我们使用py.test

$ pip install pytest pytest-cov coverage
$ python setup.py test

或:

$ py.test

在运行测试之后,我们将得到一个HTML格式的覆盖率报告。 我们可以浏览它:

$ cd htmlcov
$ python -m http.server

另外,在setup.cfg中有一些py.test的配置。 如果你需要的话就换。

Debugging

py.test可以在测试用例失败时提示pdbshell:

$ python setup.py test -a "--pdb"

或:

$ py.test --pdb

Bug Report

请随时向https://github.com/zdict/zdict/issues发送错误报告。 请附上错误信息并描述如何重现错误。 公关也是受欢迎的。

在发送错误报告之前,请使用-d/--disable-db-cache选项进行查询。 有时我们会为字典修改数据库中的数据模式, 但zdict的默认字典查询使用数据库中的缓存,该缓存可能存储在旧模式中。 这可能会导致显示结果时出错。 只需使用-d/--disable-db-cache更新数据库中的缓存。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaGWT:何时使用Lazydemelement?   Java中跟踪消失线程的多线程处理   java Springboot未能配置数据源:“url”,但我没有使用数据库   java为按钮生成随机位置   math Java:包含二项式系数计算的表达式   java通过AsyncTask传递参数   从路径错误创建java文件   高流量网站的性能播放框架、Java、Apache、PostgreSQL、JPA和Hibernate   java将4D矢量转换为长矢量   arraylist Java循环在没有任何错误的情况下终止   java正在制作一个计算器应用程序,希望在第二个片段中更新历史,但无法完成   java将信息从IntentService发送到Activity   java如何在游戏中插入大量实体!工作   javascript如何在ScriptEngineforJava中从数学中获得准确的结果?