Skip to main content

This is a simple python package to generate random english words

Project description

random-word

Build Status 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 :star2: 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/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Random Word-1.0.7.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

Random_Word-1.0.7-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file Random Word-1.0.7.tar.gz.

File metadata

  • Download URL: Random Word-1.0.7.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0

File hashes

Hashes for Random Word-1.0.7.tar.gz
Algorithm Hash digest
SHA256 6656a809abafb394ea5067c3e3d2faf8aa6ef61d5cb42987f0baf5e8d4d54141
MD5 3ab721af3db890ec80bd1cea3cc8de83
BLAKE2b-256 11f40137f2e1c2b2f8a65e758b21c626167760bf8461f14bedbb31407b3c2449

See more details on using hashes here.

File details

Details for the file Random_Word-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: Random_Word-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0

File hashes

Hashes for Random_Word-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a568980218a6520a2f5ef7d4a79a12579989cda7244f48b1d915ebc19a396047
MD5 815615291317bd4557206ee0a43df541
BLAKE2b-256 2d7c3b227773ea52b9f743624d78ef883d75bf08be5404881bcd1ba7e65d1caf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page