Giter VIP home page Giter VIP logo

random-word's Introduction

random-word

Build PyPI version PyPI - Python Version PyPI - Status Codacy Badge Downloads License: MIT

This is a simple python package to generate random english words. If you need help after reading the below, please find me at @vaibhavsingh97 on Twitter.

If you love the package, please ๐ŸŒŸ the repo.

Installation

You should be able to install using easy_install or pip in the usual ways:

$ easy_install random-word
$ pip install random-word

Or just clone this repository and run:

$ python3 setup.py install

Or place the random-word folder that you downloaded somewhere where it can be accessed by your scripts.

Basic Usage

from random_word import RandomWords
r = RandomWords()

# Return a single random word
r.get_random_word()
# Return list of Random words
r.get_random_words()
# Return Word of the day
r.word_of_the_day()

Advance Usage

  1. To generate single random word we can use these optional parameters

    • hasDictionaryDef (string) - Only return words with dictionary definitions (optional)
    • includePartOfSpeech (string) - CSV part-of-speech values to include (optional)
    • excludePartOfSpeech (string) - CSV part-of-speech values to exclude (optional)
    • minCorpusCount (integer) - Minimum corpus frequency for terms (optional)
    • maxCorpusCount (integer) - Maximum corpus frequency for terms (optional)
    • minDictionaryCount (integer) - Minimum dictionary count (optional)
    • maxDictionaryCount (integer) - Maximum dictionary count (optional)
    • minLength (integer) - Minimum word length (optional)
    • maxLength (integer) - Maximum word length (optional)
    r.get_random_word(hasDictionaryDef="true", includePartOfSpeech="noun,verb", minCorpusCount=1, maxCorpusCount=10, minDictionaryCount=1, maxDictionaryCount=10, minLength=5, maxLength=10)
    
    # Output: pediophobia
  2. To generate list of random word we can use these optional parameters

    • hasDictionaryDef (string) - Only return words with dictionary definitions (optional)
    • includePartOfSpeech (string) - CSV part-of-speech values to include (optional)
    • excludePartOfSpeech (string) - CSV part-of-speech values to exclude (optional)
    • minCorpusCount (integer) - Minimum corpus frequency for terms (optional)
    • maxCorpusCount (integer) - Maximum corpus frequency for terms (optional)
    • minDictionaryCount (integer) - Minimum dictionary count (optional)
    • maxDictionaryCount (integer) - Maximum dictionary count (optional)
    • minLength (integer) - Minimum word length (optional)
    • maxLength (integer) - Maximum word length (optional)
    • sortBy (string) - Attribute to sort by alpha or count (optional)
    • sortOrder (string) - Sort direction by asc or desc (optional)
    • limit (integer) - Maximum number of results to return (optional)
    r.get_random_words(hasDictionaryDef="true", includePartOfSpeech="noun,verb", minCorpusCount=1, maxCorpusCount=10, minDictionaryCount=1, maxDictionaryCount=10, minLength=5, maxLength=10, sortBy="alpha", sortOrder="asc", limit=15)
    
    # Output: ['ambivert', 'calcspar', 'deaness', 'entrete', 'gades', 'monkeydom', 'outclimbed', 'outdared', 'pistoleers', 'redbugs', 'snake-line', 'subrules', 'subtrends', 'torenia', 'unhides']
  3. To get word of the day we can use these optional parameters

    • date (string) - Fetches by date in yyyy-MM-dd (optional)
    r.word_of_the_day(date="2018-01-01")
    
    # Output: {"word": "qualtagh", "definations": [{"text": "The first person one encounters, either after leaving one\'s home or (sometimes) outside one\'s home, especially on New Year\'s Day.", "source": "wiktionary", "partOfSpeech": "noun"}, {"text": "A Christmas or New Year\'s ceremony, in the Isle of Man; one who takes part in the ceremony. See the first extract.", "source": "century", "partOfSpeech": "noun"}]}

Development

Assuming that you have Python and pipenv installed, set up your environment and install the required dependencies like this instead of the pip install random-word defined above:

$ git clone https://github.com/vaibhavsingh97/random-word.git
$ cd random-word
$ pipenv install
...
$ pipenv shell

Add API Key in random_word directory defining API Key in config.py. If you don't have an API key than request your API key here

API_KEY = "<API KEY>"

After that, install your package locally

$ pip install -e .

Issues

You can report the bugs at the issue tracker

License

Built with โ™ฅ by Vaibhav Singh(@vaibhavsingh97) under MIT License

You can find a copy of the License at https://vaibhavsingh97.mit-license.org/

random-word's People

Contributors

vaibhavsingh97 avatar dependabot[bot] avatar theblueskies avatar jatin69 avatar jkterry1 avatar nkstonks 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.