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:

from betterud import *

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.

from betterud import *

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:

from betterud import *

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

Output:

Came

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

from betterud import *

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.2.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: betterud-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 4c2e26857eac017e81eda67addb12756feb5388f044a2520b6bc5840ad516f5e
MD5 675bdf011455c9db1e461754617550c7
BLAKE2b-256 fd67353bc600df15229aa4417a11b84156c60301d6b67f74f3f08b0bf0a0cc7e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: betterud-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b25935cf548cf7692d41a68d3886523b32d3c8cf144bbc2d90b81a797eabbe54
MD5 1fb746d93d973f76aa901ed02e4ab085
BLAKE2b-256 d9faabd1c02dc011f96a4d6c33063ccc20f871b3cafadb8cd414c7183dbbbb6f

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page