GithubHelp home page GithubHelp logo

rajarshi1 / hashtag_utils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adipat/hashtag_utils

0.0 0.0 0.0 703 KB

Generates hashtags for a content piece. 🏷️

License: MIT License

Shell 0.63% Python 99.37%

hashtag_utils's Introduction

Hashtag Utilities 🏷️

An LLM-powered multi-purpose hashtag utilities library written in Python.

Hashtag Utilities Hero

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_KEY to the .env file.
  • Run examples: python example.py

Contributors

hashtag_utils's People

Contributors

adipat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.