Giter Site home page Giter Site logo

hhy5277 / zdict Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zdict/zdict

0.0 1.0 0.0 521 KB

The last online dictionary framework you need. (?)

Home Page: https://pypi.org/project/zdict/

License: GNU General Public License v3.0

Dockerfile 0.19% Makefile 0.64% Shell 0.28% Python 98.89%

zdict's Introduction

zdict

issues

travis circleci coveralls

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


Note: This project is working in progress.

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.



Installation

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

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

  • Normal Mode

zdict hello

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

  • Interactive Mode

zdict

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

Moe Dictionary 萌典

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

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

Urban Dictionary

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

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

SpanishDict

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

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

Jisho Japanese Dictionary

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

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

Yandex Translate

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

Oxford Dictionary

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

Wiktionary

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

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

Development & Contributing

Testing

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. Don't need to install it again.

We use py.test:

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

or:

$ py.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.

Debugging

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

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

or:

$ py.test --pdb

Bug Report

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.

Related Projects

  • zdict.vim
    • A vim plugin integrates with zdict.
  • zdict.sh
    • A collection of shell completion scripts for zdict.

Stargazers over time

stargazers

zdict's People

Contributors

cwshu avatar fkztw avatar gitter-badger avatar iblislin avatar offpics avatar pi314 avatar pyup-bot avatar tzing avatar wdv4758h avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.