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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: betterud-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 5390c60380cead031d834dcf5497a6bb580fe073a2771dc62edbfeca141d1ac5
MD5 a5d67aea2b33108fb67a4aa6329a7d74
BLAKE2b-256 a08bee8682256c3f203a1b758429f45d086421084971a0f0344b4a7c3fd92bf8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: betterud-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64c935a108b8e2b4599386b4d2802c382a6929338ec5a2f86f95e982ff2671ea
MD5 8a6343be5a18a4eae3a4dd21e09d2bd9
BLAKE2b-256 1831b690b855dc3d3dd7b998618f153e0aeb43db4b0d47ae580f8d89dcb1d549

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