Giter VIP home page Giter VIP logo

zdict's Introduction

zdict

license version python version month download

stars forks contributors pull requests issues

github_actions circleci coveralls

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.


Table of Contents


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 --platform=linux/amd64 zdict/zdict         # latest commit
docker run -it --rm --platform=linux/amd64 zdict/zdict:release # latest release
docker run -it --rm --platform=linux/amd64 zdict/zdict:v0.10.0 # use zdict v0.10.0
docker run -it --rm --platform=linux/amd64 zdict/zdict:$tag    # with specific tag

# Run normal mode
docker run -it --rm --platform=linux/amd64 zdict/zdict apple bird         # latest commit
docker run -it --rm --platform=linux/amd64 zdict/zdict:release apple bird # latest release
docker run -it --rm --platform=linux/amd64 zdict/zdict:v0.10.0 apple bird # use zdict v0.10.0
docker run -it --rm --platform=linux/amd64 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 --platform=linux/amd64 zdict/zdict:v0.10.0 -dt moe    # use moe dict in interactive mode
docker run -it --rm --platform=linux/amd64 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,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.

Screenshots

  • Normal Mode

zdict hello

image

  • Interactive Mode

zdict

image

image

image

image

image

image

image

image

image

image

image

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

image

image

image

image

image

image

Development & Contributing

Testing

During development, you can install our project as editable. If you use virtualenv, you may want to create a new environment 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.

Debugging

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

$ py.test --pdb

or:

$ make test-with-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.

  • 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.

zdict's People

Contributors

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zdict's Issues

regular expression for searching

Some dictionaries have ability to use advance searching, e.g. regex. I think we can support these features (we can just return some message for dictionaries not support these kind of features).


For example, I can use regex in moedict :
moedict-re-01
Then, zdict can return that list of result.


For KanTan :

kantan

TypeError: Can't convert 'Tag' object to str implicitly

$ zdict pan
Traceback (most recent call last):
File "/Users/m157q/.virtualenvs/zdict/bin/zdict", line 6, in
exec(compile(open(file).read(), file, 'exec'))
File "/Users/m157q/GitHub/zdict/scripts/zdict", line 5, in
main()
File "/Users/m157q/GitHub/zdict/zdict/zdict.py", line 293, in main
ydict.lookup(w)
File "/Users/m157q/GitHub/zdict/zdict/dictionaries.py", line 52, in lookup
record = self.query(word)
File "/Users/m157q/GitHub/zdict/zdict/plugins/yahoo_dict.py", line 132, in query
sentence += word
TypeError: Can't convert 'Tag' object to str implicitly

Add template.py into dictionaries/

  • template.py
    • Make contributors add new dictionary more conveniently.
    • Add docstring about what should be filled in the template.py
    • Add usage of color.print in show function for contributors easily choosing the colors of the output.
  • README
    • The guide about how to contribute a new dictionary for zdict.

Testing for UrbanDict

Working list:

In class UrbanDict:

  • provider
  • show: run only without testing the output format
  • _get_url
  • query

[utils.py] Code Refactoring for color print

Color

I think we can use Python 3.4's Enum module for color which will be more clear.

for example :

from enum import IntEnum

class COLOR(IntEnum):
    ORG     = 0
    BLACK   = 30
    RED     = 31
    GREEN   = 32
    YELLOW  = 33
    BLUE    = 34
    MAGENTA = 35
    INDIGO  = 36
    WHITE   = 37

usage :

>>> COLOR.RED
<COLOR.RED: 31>
>>> COLOR(31)
<COLOR.RED: 31>
>>> COLOR['RED']
<COLOR.RED: 31>
>>> COLOR['RED'].value
31
>>> '{}'.format(COLOR['RED'])
'31'
>>> for i in COLOR: print(repr(i))
<COLOR.ORG: 0>
<COLOR.BLACK: 30>
<COLOR.RED: 31>
<COLOR.GREEN: 32>
<COLOR.YELLOW: 33>
<COLOR.BLUE: 34>
<COLOR.MAGENTA: 35>
<COLOR.INDIGO: 36>
<COLOR.WHITE: 37>

The implementation of Enum in CPython is a little bit slower than pure Python dictionary now, but I think that's not our concern (and it may change in the future or other implementation).

BTW, the example of Enum in the documentation is color :p

The `readline` module on Mac OS X has strange behavior

  • Mac OS X 10.10 with Python3.4
    • import readline causes some escape sequence being output to terminal, although that is not visible
  • Mac OS X 10.10 with Python3.5
    • Ctrl-D not working correctly.
    • After enter-and-leave zdict shell (or any readline based shell, even Python shell), my zsh cannot be exited with Ctrl-D, but if I run zdict -h, problem disappeared.

gnureadline module works fine.

I want to check the platform, if sys.platform == 'darwin', install gnureadline instead.

yahoo dict crashes when querying "運作"

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/bin/zdict", line 4, in <module>
    zdict.main()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zdict/zdict.py", line 207, in main
    execute_zdict()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zdict/zdict.py", line 191, in execute_zdict
    normal_mode()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zdict/zdict.py", line 152, in normal_mode
    zdict.lookup(word, args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zdict/dictionary.py", line 119, in lookup
    record = self.query(word, args.query_timeout, args.verbose)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/zdict/dictionaries/yahoo.py", line 106, in query
    content['pronounce'].append(m.group(1, 2))
AttributeError: 'NoneType' object has no attribute 'group'

Jisho dictionary support

I just find a nice dictionary for Japanese <--> English called Jisho (dictionary in japanese).

Website : http://jisho.org/
API : http://jisho.org/api/v1/search/words?keyword={word}

I can't find the API's spec detail, though.
API related topic : http://jisho.org/forum/54fefc1f6e73340b1f160000-is-there-any-kind-of-search-api

example for じしょ :

jisho-01

http://jisho.org/api/v1/search/words?keyword=じしょ :

{
  "meta": {
    "status": 200
  },
  "data": [
    {
      "is_common": true,
      "tags": [
        "wanikani16"
      ],
      "japanese": [
        {
          "word": "\u8fad\u66f8",
          "reading": "\u3058\u3057\u3087"
        }
      ],
      "senses": [
        {
          "english_definitions": [
            "dictionary",
            "lexicon"
          ],
          "parts_of_speech": [
            "Noun"
          ],
          "links": [

          ],
          "tags": [

          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        },
        {
          "english_definitions": [
            "letter of resignation"
          ],
          "parts_of_speech": [

          ],
          "links": [

          ],
          "tags": [
            "Archaism"
          ],
          "restrictions": [

          ],
          "see_also": [
            "\u8fad\u8868"
          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        }
      ],
      "attribution": {
        "jmdict": true,
        "jmnedict": false,
        "dbpedia": false
      }
    },
    {
      "is_common": false,
      "tags": [

      ],
      "japanese": [
        {
          "word": "\u5730\u6240",
          "reading": "\u3058\u3057\u3087"
        },
        {
          "word": "\u5730\u6240",
          "reading": "\u3061\u3057\u3087"
        }
      ],
      "senses": [
        {
          "english_definitions": [
            "estate",
            "plot of land"
          ],
          "parts_of_speech": [
            "Noun"
          ],
          "links": [

          ],
          "tags": [

          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        }
      ],
      "attribution": {
        "jmdict": true,
        "jmnedict": false,
        "dbpedia": false
      }
    },
    {
      "is_common": false,
      "tags": [

      ],
      "japanese": [
        {
          "word": "\u5b57\u66f8",
          "reading": "\u3058\u3057\u3087"
        }
      ],
      "senses": [
        {
          "english_definitions": [
            "(character) dictionary"
          ],
          "parts_of_speech": [
            "Noun"
          ],
          "links": [

          ],
          "tags": [

          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        },
        {
          "english_definitions": [
            "Chinese dictionary"
          ],
          "parts_of_speech": [
            "Wikipedia definition"
          ],
          "links": [
            {
              "text": "Read \u300cChinese dictionary\u300d on English Wikipedia",
              "url": "http:\/\/en.wikipedia.org\/wiki\/Chinese_dictionary?oldid=490865690"
            },
            {
              "text": "Read \u300c\u5b57\u66f8\u300d on Japanese Wikipedia",
              "url": "http:\/\/ja.wikipedia.org\/wiki\/\u5b57\u66f8?oldid=42671286"
            }
          ],
          "tags": [

          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ],
          "sentences": [

          ]
        }
      ],
      "attribution": {
        "jmdict": true,
        "jmnedict": false,
        "dbpedia": "http:\/\/dbpedia.org\/resource\/Chinese_dictionary"
      }
    },
    {
      "is_common": false,
      "tags": [

      ],
      "japanese": [
        {
          "word": "\u74bd\u66f8",
          "reading": "\u3058\u3057\u3087"
        }
      ],
      "senses": [
        {
          "english_definitions": [
            "document with the emperor's seal"
          ],
          "parts_of_speech": [
            "Noun"
          ],
          "links": [

          ],
          "tags": [

          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        }
      ],
      "attribution": {
        "jmdict": true,
        "jmnedict": false,
        "dbpedia": false
      }
    },
    {
      "is_common": false,
      "tags": [

      ],
      "japanese": [
        {
          "word": "\u81ea\u66f8",
          "reading": "\u3058\u3057\u3087"
        }
      ],
      "senses": [
        {
          "english_definitions": [
            "one's own writing"
          ],
          "parts_of_speech": [
            "Noun",
            "Suru verb"
          ],
          "links": [

          ],
          "tags": [

          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        }
      ],
      "attribution": {
        "jmdict": true,
        "jmnedict": false,
        "dbpedia": false
      }
    },
    {
      "is_common": false,
      "tags": [

      ],
      "japanese": [
        {
          "word": "\u81ea\u7f72",
          "reading": "\u3058\u3057\u3087"
        }
      ],
      "senses": [
        {
          "english_definitions": [
            "autograph",
            "signature"
          ],
          "parts_of_speech": [
            "Noun",
            "Suru verb"
          ],
          "links": [

          ],
          "tags": [

          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        }
      ],
      "attribution": {
        "jmdict": true,
        "jmnedict": false,
        "dbpedia": false
      }
    },
    {
      "is_common": true,
      "tags": [
        "wanikani23"
      ],
      "japanese": [
        {
          "word": "\u8fad\u8077",
          "reading": "\u3058\u3057\u3087\u304f"
        }
      ],
      "senses": [
        {
          "english_definitions": [
            "resignation"
          ],
          "parts_of_speech": [
            "Noun",
            "Suru verb"
          ],
          "links": [

          ],
          "tags": [

          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        }
      ],
      "attribution": {
        "jmdict": true,
        "jmnedict": false,
        "dbpedia": false
      }
    },
    {
      "is_common": true,
      "tags": [

      ],
      "japanese": [
        {
          "word": "\u81ea\u7a31",
          "reading": "\u3058\u3057\u3087\u3046"
        }
      ],
      "senses": [
        {
          "english_definitions": [
            "self-alleged",
            "self-proclaimed",
            "calling oneself",
            "self-styled",
            "would-be"
          ],
          "parts_of_speech": [
            "Noun",
            "Suru verb",
            "No-adjective"
          ],
          "links": [

          ],
          "tags": [

          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        },
        {
          "english_definitions": [
            "first person"
          ],
          "parts_of_speech": [
            "Noun"
          ],
          "links": [

          ],
          "tags": [
            "Law, etc. term"
          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        }
      ],
      "attribution": {
        "jmdict": true,
        "jmnedict": false,
        "dbpedia": false
      }
    },
    {
      "is_common": true,
      "tags": [

      ],
      "japanese": [
        {
          "word": "\u4e8b\u8c61",
          "reading": "\u3058\u3057\u3087\u3046"
        }
      ],
      "senses": [
        {
          "english_definitions": [
            "event",
            "phenomenon",
            "matter"
          ],
          "parts_of_speech": [
            "Noun"
          ],
          "links": [

          ],
          "tags": [

          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        }
      ],
      "attribution": {
        "jmdict": true,
        "jmnedict": false,
        "dbpedia": false
      }
    },
    {
      "is_common": false,
      "tags": [

      ],
      "japanese": [
        {
          "word": "\u8fad\u66f8\u5f62",
          "reading": "\u3058\u3057\u3087\u3051\u3044"
        }
      ],
      "senses": [
        {
          "english_definitions": [
            "dictionary form"
          ],
          "parts_of_speech": [
            "Noun"
          ],
          "links": [

          ],
          "tags": [
            "linguistics terminology"
          ],
          "restrictions": [

          ],
          "see_also": [

          ],
          "antonyms": [

          ],
          "source": [

          ],
          "info": [

          ]
        }
      ],
      "attribution": {
        "jmdict": true,
        "jmnedict": false,
        "dbpedia": false
      }
    }
  ]
}

Documentation for dictionaries' API or HTML parsing

Urban

API http://api.urbandictionary.com/v0/define?term={word}


test :

{
  "tags": [
    "testes",
    "balls",
    "testicles",
    "nuts",
    "scrotum",
    "school",
    "tests",
    "exam",
    "penis",
    "testing"
  ],
  "result_type": "exact",
  "list": [
    {
      "defid": 708924,
      "word": "test",
      "author": "tester",
      "permalink": "http:\/\/test.urbanup.com\/708924",
      "definition": "A process for testing things",
      "example": "This is a test message",
      "thumbs_up": 376,
      "thumbs_down": 221,
      "current_vote": ""
    },
    {
      "defid": 2957653,
      "word": "test",
      "author": "sm1g",
      "permalink": "http:\/\/test.urbanup.com\/2957653",
      "definition": "To check if something coresponds the promised result or what effect does it have at all.",
      "example": "By typing in the word \"test\" you prolly tried to search if there was a definition for this word.",
      "thumbs_up": 188,
      "thumbs_down": 88,
      "current_vote": ""
    },
    {
      "defid": 2573364,
      "word": "test",
      "author": "test is best",
      "permalink": "http:\/\/test.urbanup.com\/2573364",
      "definition": "slang for testosterone..steroid hormones.",
      "example": "This cycle I'm stacking test with fina for some serious gains.\r\n",
      "thumbs_up": 133,
      "thumbs_down": 49,
      "current_vote": ""
    },
    {
      "defid": 1662552,
      "word": "test",
      "author": "Eddiehashiv",
      "permalink": "http:\/\/test.urbanup.com\/1662552",
      "definition": "A means of evaluating another person's character through a series of unannounced, inconspicuous examinations. Developed by Eddie, it serves to define which people are desirable company and which should not be associated with. As a general rule, a test-passer is a good person while a test-failer is a bad person.\r\n\r\nPassing the test results in the joyous proclamation that \"You pass the test!\"\r\n\r\nFailure of a test is announced simply by saying \"You failed the test.\" This phrase is often used to show general disdain for a person's existence.\r\n",
      "example": "\"You didn't make eye contact while saying 'thank you.' You failed the test.\"\r\n\r\n\"You forgot to hold the door open for me... failed the test.\"\r\n\r\n\"You passed the test - you offered me a piece of sausage from your pizza.\"",
      "thumbs_up": 120,
      "thumbs_down": 52,
      "current_vote": ""
    },
    {
      "defid": 1876232,
      "word": "test",
      "author": "monn-unit",
      "permalink": "http:\/\/test.urbanup.com\/1876232",
      "definition": "1. the main cause of explosions.\r\n2. any thing dreaded that your \"teachers\" say is \"good\" for you. soon after, you explode for no reason.\r\n3. what scientists do to make stuff explode.\r\n4. when a sheet of paper explodes into flames.",
      "example": "1. test sodium and water.\r\n2. SAT is a test.\r\n3. Monkeys.\r\n4. you brought your lighter to test.",
      "thumbs_up": 93,
      "thumbs_down": 31,
      "current_vote": ""
    },
    {
      "defid": 1246559,
      "word": "test",
      "author": "bLINK 182 yALL",
      "permalink": "http:\/\/test.urbanup.com\/1246559",
      "definition": "1. A process of finding out whether something works or not.\r\n2. An oral or written exam to find out one's ability in one or more subjects.",
      "example": "1. Lets test out that abandoned car!\r\n2. NOOO!! We have a test in math class today! I'm going to fail1!",
      "thumbs_up": 63,
      "thumbs_down": 33,
      "current_vote": ""
    },
    {
      "defid": 2081307,
      "word": "TEST",
      "author": "VICKI KARMA",
      "permalink": "http:\/\/test.urbanup.com\/2081307",
      "definition": "Everything that is put in front of you during any given day. ",
      "example": "How was your day?\r\nTesting!...but i did well at not passing every test!...Hope i get a better run tomorrow. ",
      "thumbs_up": 39,
      "thumbs_down": 15,
      "current_vote": ""
    },
    {
      "defid": 1693816,
      "word": "TEST",
      "author": "Joey Suska",
      "permalink": "http:\/\/test.urbanup.com\/1693816",
      "definition": "1. One of the greatest pro-wrestlers to ever grace us with his presence. Has a good habbit of getting annoying WWE Diva's OFF of our TV screens, usually by charging at them and booting them in the face.\r\n\r\n2. A real mans man! Even more so than William Regal.\r\n\r\n3. Soon to be returning to WWE rings and will be murdering mid-carders left and right with big boots.",
      "example": "J.R.: Bah Gawd, that sunuvabitch TEST just kicked that poor girls teeth down her throat!\r\n\r\nKing: Those poor puppies!",
      "thumbs_up": 70,
      "thumbs_down": 52,
      "current_vote": ""
    },
    {
      "defid": 1157334,
      "word": "Test!",
      "author": "fano",
      "permalink": "http:\/\/test.urbanup.com\/1157334",
      "definition": "Derogative term. \r\nDerived from the way a Greek may call someone an Arhidi (a testicle). \r\n\r\nPlace of origin: N Melbourne (Aust)",
      "example": "You're such a test!\r\n\r\nHey there goes that test again.\r\n\r\nTEST!",
      "thumbs_up": 15,
      "thumbs_down": 3,
      "current_vote": ""
    },
    {
      "defid": 2485641,
      "word": "Test",
      "author": "energizerman38",
      "permalink": "http:\/\/test.urbanup.com\/2485641",
      "definition": "What you take in school to determine if you pass or fail in life.",
      "example": "I failed my test, therfore I must fail at life.",
      "thumbs_up": 16,
      "thumbs_down": 6,
      "current_vote": ""
    }
  ],
  "sounds": [
    "http:\/\/media.urbandictionary.com\/sound\/test-8076.mp3"
  ]
}

zdict vim plugin

[plan] Press, say <leader>b, on a word, and vim shows a vertical split to show the result, just like The-NERD-Tree

[Bug] zdict hangs when user connected to network but no routing

I encountered this when I connected to my wireless AP but the uplink was unplugged by me accidently.
At first, zdict hanged, even after the network got worked (After I plugged the uplink into the wireless AP)
zdict just got exceptions below and quit.
20151020_00 54 08
I guess this problem may also happend to users who are using a bad network connection.
ex: The users who are using the NCTU network (?)
Need to solve this.

An option for choosing the available dictionaries

  • Use Yahoo dictionary as default.
  • Add an option for users choosing one of the available dictionaries.
  • If users not giving an argument for this option, the program should list out all available dictionaries.
  • There should be an argument "all" within this option for showing all results from every available dictionaries of the words queried by users.
  • The available dictionaries list should not be modified manually, instead, it should be parsed from the directory which stores all of the available dictionary classes (zdict/dictionaries/). (ref 1ef84c3)

IndexError: list index out of range

$ zdict deinstall
Traceback (most recent call last):
File "/Users/m157q/.virtualenvs/zdict/bin/zdict", line 6, in
exec(compile(open(file).read(), file, 'exec'))
File "/Users/m157q/GitHub/zdict/scripts/zdict", line 5, in
main()
File "/Users/m157q/GitHub/zdict/zdict/zdict.py", line 293, in main
ydict.lookup(w)
File "/Users/m157q/GitHub/zdict/zdict/dictionaries.py", line 52, in lookup
record = self.query(word)
File "/Users/m157q/GitHub/zdict/zdict/plugins/yahoo_dict.py", line 87, in query
('DJ', pronu_value[1][2:]),
IndexError: list index out of range

Add `-s` option for saving the whole result into a file after exiting interactive mode.

  • -s / --save
  • Save in plaintext (without VT100 color code).
  • Save at ~/.zdict/last_history
  • Overwrite if ~/.zdict/last_history had already existed.
  • Don't save not found word(s).

Concern

What if user searched lots of words and run out of memory for storing the results before saving to the file?
Maybe need a test for the maxium lines can be saved?
or just append the result into the saving file after each query?
Maybe the last would be better.

Migrate test utils to `py.test`

Let's try out py.test

Also, i want to add some test relative working list:

  • coverage,py
  • coveralls
  • coveralls badge
  • add test_suite and tests_require option in setup.py
  • doc about test: using python setup.py test
  • travis ci command: using python setup.py test

generate Phone App

Our zdict is a framework, so it can handle mutiple dictionaries. Furthermore, I think we can provide an easy way to generate an app for our dictionaries. So, people can reuse the query stuff and have a simple useful app for their phone :) (maybe another repo ?)

(in the future)

dictionaries registration mechanism

As a framework, we may have lots of dictionaries to choose. So, we need a mechanism to register the new dictionaries and expose to command line argument.

Add `-l` option for choosing language

example: zdict -l Chinese for querying all the Chinese related dictionaries.

Maybe need to add an language attribute into each dictionary under dictionaries/
and we can find a way to retrieve the attribute for all dictionaries for using and showing at the -h

Design of class `Shell`

Currently, we have a class MetaInteractivePrompt which hadle interative shell and a function normal_mode handle simple query from command line.

But accutally, we may need more elegant abstraction like this:

class Shell:
    def interactive_mode(...):
        # query dictionaries
        ...
    def normal_mode(...):
        # query dictionaries
        ...

And just let zdict.py invoke the instance of Shell.

I think Shell will have following interface and behavior:

  • Operations
    • interactive_mode: it will do the dictionaries query
    • normal_mode: dictionaries query
    • _is_cmd(s: str): Impelment about #29
    • hook(category: Enum, udf: function): Just an idea about something like,
      post_query -- After query, user defined function (udf) invoke a espeach. But this hook system should be well-intergrated with config zdictrc( or ~/.zdict/...). Maybe this is another big topic....
  • Properties
    • cmds: the supported commands. A set of class Command (see below)
    • cmds_completer: support tab complete for cmds.
  • Behavior
    • Init dict completer

class Command:

  • Properties
    • name
    • args
    • completer: optional. For completing the args. Maybe we will need to Implement class CmdCompletor for large aomunt of reusing.
  • Operations
    • exec(args: iterable)

Please comment!
I will keep updating this blueprints.

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.