Skip to content
/ zdict Public
forked from zdict/zdict

The last online dictionary framework you need. (?)

License

Notifications You must be signed in to change notification settings

apua/zdict

 
 

Repository files navigation

zdict

license version python version month download

stars forks contributors pull requests issues

github_actions circleci coveralls

docker automated build docker build status

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

pyup.io badge

[ ~ Dependencies scanned by PyUp.io ~ ]


zdict is a CLI dictionary framework mainly focus on any kind of online dictionary. This project originally forked from https://github.com/chenpc/ydict, which is a CLI tool for the Yahoo! online dictionary. After heavily refactoring the original project including:

  1. Change from Python 2 to Python 3
  2. Focus on being a flexible framework for any kind online dicitionaries, not only just a CLI tool for querying Yahoo! online dictionary.
  3. Based on an open source project skeleton.

So, we decided to create a new project.



from PyPI :

pip install zdict

from GitHub :

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

from 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

How to run the zdict docker image

# 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.
  • Normal Mode

zdict hello

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

  • Interactive Mode

zdict

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

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

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

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

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

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

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

http://i.imgur.com/63n3qmH.png

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

https://user-images.githubusercontent.com/2716047/29741879-ca1a3826-8a3a-11e7-9701-4a7e9a15971a.png

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

To use this source, you should first apply an API key and place it under ~/.zdict/oxford.key in the format:

app_id, app_key

https://i.imgur.com/5OzIFU3.png

https://i.imgur.com/UO5nQjU.png

https://user-images.githubusercontent.com/1645228/55309799-656acd00-5491-11e9-9d79-4ae578c83f8b.jpg

https://user-images.githubusercontent.com/1645228/55309820-7582ac80-5491-11e9-998d-51ebfb183375.jpg

https://user-images.githubusercontent.com/1645228/86770837-e6951480-c083-11ea-95f2-51b1e6f7e04f.jpg

https://user-images.githubusercontent.com/1645228/86770828-e432ba80-c083-11ea-813a-e357f213826a.jpg

During development, you can install our project as editable. If you use virtualenv, you may want to create a new enviroment for zdict:

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

Once you installed it with the command above, just execute zdict after modification. No need to install it again.

Install the packages for testing:

$ pip install -r requirements-test.txt

or:

$ make install-test-deps

Use the command below to execute the tests:

$ py.test

or:

$ make test

After runing testing, we will get a coverage report in html. We can browse around it:

$ cd htmlcov
$ python -m http.server

Also, there is some configs for py.test in setup.cfg. Change it if you need.

py.test can prompt pdb shell when your test case failed:

$ py.test --pdb

or:

$ make test-with-pdb

Feel free to send a bug report to https://github.com/zdict/zdict/issues. Please attach the error message and describe how to reproduce the bug. PR is also welcome.

Please use the -d/--disable-db-cache option to query before sending the bug report. Sometimes we modify the data schema in database for a dictionary, but the default dictionary query of zdict uses the cache in the database which may be stored within an old schema. This might cause an error while showing the result. Just use the -d/--disable-db-cache to update the cache in database.

  • zdict.vim
    • A vim plugin integrates with zdict.
  • zdict.sh
    • A collection of shell completion scripts for zdict.
  • zdict_jupyter
    • Use zdict in Jupyter Notebook.

About

The last online dictionary framework you need. (?)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.4%
  • Other 0.6%