Note
API that's used to analyze blog content given a link to the blog or text content using BERT model from HuggingFace (Max limit is 512 token i.e. 2500 characters)
This API checks the sentiment (like positive or negative) of a webpage or some text you provide.
A virtual environment keeps your project’s dependencies separate from other Python projects on your system.
-
Open your terminal or command prompt.
-
Run the following command to create a virtual environment:
python -m venv venv
This will create a folder named
venv
in your project directory.
Once the virtual environment is created, you need to activate it.
-
On Windows:
venv\Scripts\activate
-
On macOS/Linux:
source venv/bin/activate
You’ll know it’s activated if you see (venv)
at the beginning of your terminal prompt.
With the virtual environment activated, install the necessary packages.
-
Run the following command to install the packages:
pip install -r requirements.txt
This will install the requirement packages and libraries.
pip install torch
You can send requests to the following endpoints:
What it Does: Checks the sentiment of a webpage by its URL.
How to Use: Add the link
to the URL as a query parameter.
Request Example:
GET /l?link=https://example.com
Response Example:
{
"sentiment": "positive"
}
What it Does: Checks the sentiment of some text you provide.
How to Use: Add the content
to the URL as a query parameter.
Request Example:
GET /c?content=This+is+awesome!
Response Example:
{
"sentiment": "positive"
}
- If you forget to include
link
orcontent
, you’ll get an error saying the request is invalid.