Skip to main content

A better solution to parse definitions from Urban Dictionary for python

Project description

betterUD

A better solution to parse definitions from Urban Dictionary for python

Installation

Install betterUD with pip

  pip install betterud

Note: requests are required to run the library, so ensure you've installed it:

  pip install requests

Usage

The library contains two main classes SearchUD and Word. SearchUD has only one function .start() and is used to search words' definitions through Urban Dictionary's API. Returns a list of Word's objects.

Word has arguments .definition, .permalink, .thumbs_up, .author, .word, .defid, .current_vote, .written_on, .example, .thumbs_down:

import betterud

definitions = SearchUD('word').start()
print(definitions[0].definition)

Output:

A versatile [declaration], originating (more or less) in hip-hop culture.

"Word" has no single meaning, but is used to convey a casual sense of affirmation, [acknowledgement], agreement, or to indicate that something has impressed you favorably.

Its usage among young blacks has been parodied [ad nauseam] among clueless suburban whites.

Also, Word has a function .bracketless(). This function is used to remove brackets from object's definition and return object itself.

import betterud

definitions = SearchUD('word').start()
print(definitions[0].bracketless().definition)

Output:

A versatile declaration, originating (more or less) in hip-hop culture.

"Word" has no single meaning, but is used to convey a casual sense of affirmation, acknowledgement, agreement, or to indicate that something has impressed you favorably.

Its usage among young blacks has been parodied ad nauseam among clueless suburban whites.

If SearchUD didn't get any arguments, it'd return definitions for random words from Urban Dictionary:

import betterud

definitions = SearchUD().start()
print(definitions[0].word)

Output:

Came

If SearchUD didn't find a definition, it'd return an empty array:

import betterud

definitions = SearchUD('iswearitdoesntexiststhere').start()
print(definitions)

Output:

[]

Credits

Special thanks to atbuy, the creator of python_urbandict as I used his library to understand basics

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

betterud-1.0.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

betterud-1.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file betterud-1.0.1.tar.gz.

File metadata

  • Download URL: betterud-1.0.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for betterud-1.0.1.tar.gz
Algorithm Hash digest
SHA256 52ab522256b32d636c54dc6014c0e157f58dcccee4dcf7f09ed328cc77b56f77
MD5 320e0e0e09fe07b91d26ed1251a8ce86
BLAKE2b-256 b2960c622742908546146b5c2800f4241e2f904d4b08079e2e9665d558d33865

See more details on using hashes here.

File details

Details for the file betterud-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: betterud-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for betterud-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca644d98acca064b3022468a1acc32c1143d318ab80caa923fd207c919b1fa9c
MD5 7d01af972e5b9c62412fb3d7b665cdc6
BLAKE2b-256 2b8169f694a2108cc6cbec261a07b2fcf45caa356211ffd12394d0ab3b8dc13b

See more details on using hashes here.

Supported by

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