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
Metadata
Release files for hashtag-utils 0.5.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hashtag_utils-0.5.6.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hashtag_utils-0.5.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 kB
Release files / hashtag_utils-0.5.6.tar.gz
| Download URL | hashtag_utils-0.5.6.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0cb9ca41fd972f3eda11f8574bc553277845bb04cf6dc6246dd74146c5b52a24
|
|
BLAKE2b-256 checksum How to use checksums |
4ef6dbfe4903d84380d83adefc2245c64db7db67d0b8ed89ed16615d25e6c87d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Release files / hashtag_utils-0.5.6-py3-none-any.whl
| Download URL | hashtag_utils-0.5.6-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb93d7a9f2c0f585dd3d5808d20392c7402a4788b692fe5c60bd9988e1429c01
|
|
BLAKE2b-256 checksum How to use checksums |
ed4162d9c8630b2008e311ce55323cd12260bef4a65865a17b04a22887861abd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|