Simple LLM-powered hashtag utilities.
Project description
Hashtag Utilities 🏷️
An LLM-powered multi-purpose hashtag utilities library written in Python.
Hashtags are used on almost every content platform today. This makes it a vital tool for creating & analyzing content. This utilities library makes it easy to do things with hashtags. Ideally, this module is intended to be used within a larger system where more specific problems are solved.
Feel free to suggest features, ideas and improvements! If you want to contribute, feel free to fork and send a Pull Request. I'm actively working on this project.
Features
- Hashtag Generator: Generates hashtags for a content piece.
- Hashtag Relevance: Returns the percentage relevance of a hashtag with respect to a content piece.
- Similar Hashtags: Generates hash tages similar to the provided ones.
- Hashtag Distance: Computes how close two hashtags are.
- Hashtag Definitions: Get hashtag definitions.
Usage: HashtagUtils API
Make sure you add your OPENAI_API_KEY to a .env file from the location where you're running the script.
from hashtag_utils import HashtagUtils
hg = HashtagUtils()
text = "A new study shows that eating chocolate can help you lose weight."
hashtags = hg.get_hashtags(text)
# check other methods below
Methods
get_hashtags(text: str, temperature: float = 1.0, num_tags: int = 5) -> List[str]
Generates a list of hashtags based on the given text.
text: The input text to generate hashtags from.temperature: Controls the randomness of the hashtag generation. Lower values make the output more deterministic. Default is 1.0.num_tags: The number of hashtags to generate. Default is 5.
get_similar_hashtags(hashtags: List[str], temperature: float = 1.0, num_tags: int = 5) -> List[str]
Generates a list of hashtags that are similar to the given hashtags.
hashtags: The input hashtags to find similar hashtags for.temperature: Controls the randomness of the hashtag generation. Lower values make the output more deterministic. Default is 1.0.num_tags: The number of hashtags to generate. Default is 5.
get_hashtag_definition(hashtag: str) -> str
Returns the definition of the given hashtag.
hashtag: The hashtag to get the definition for.
get_hashtags_relevance(hashtags: List[str], text: str) -> Dict[str, float]
Returns a dictionary mapping each hashtag to its relevance to the given text.
hashtags: The hashtags to check the relevance of.text: The text to check the relevance against.
get_hashtag_distance(hashtag1: str, hashtag2: str) -> float
Returns the semantic distance between two hashtags.
hashtag1: The first hashtag.hashtag2: The second hashtag.
Run Examples
- Add
OPENAI_API_KEYto the.envfile. - Run examples:
python example.py
Contributors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hashtag_utils-0.5.6.tar.gz.
File metadata
- Download URL: hashtag_utils-0.5.6.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cb9ca41fd972f3eda11f8574bc553277845bb04cf6dc6246dd74146c5b52a24
|
|
| MD5 |
b512ae374c5afc5627af9b43d947d6a7
|
|
| BLAKE2b-256 |
4ef6dbfe4903d84380d83adefc2245c64db7db67d0b8ed89ed16615d25e6c87d
|
File details
Details for the file hashtag_utils-0.5.6-py3-none-any.whl.
File metadata
- Download URL: hashtag_utils-0.5.6-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb93d7a9f2c0f585dd3d5808d20392c7402a4788b692fe5c60bd9988e1429c01
|
|
| MD5 |
692b6b9b4d5d940e6a06d2f6ee5cfe15
|
|
| BLAKE2b-256 |
ed4162d9c8630b2008e311ce55323cd12260bef4a65865a17b04a22887861abd
|