Skip to content

Proof of concept sentiment analysis using python interop

License

Notifications You must be signed in to change notification settings

biotz/POC-sentiment-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sentiment Analysis Service

This project provides a sentiment analysis service using Clojure and Python. The service exposes a REST API to analyze the sentiment of text data.

Prerequisites

Clojure: Ensure you have Clojure installed.

Python: Ensure you have Python and pip installed, since you are going to need pysentimiento.

If you install conda, make sure to set the LD_LIBRARY_PATH as follows:
export LD_LIBRARY_PATH="$(python3-config --prefix)/lib"

It is convenient to use a tool to manage the environment on a per-project basis, like direnv. If you go down that route, you will find the .envrc file in the base folder of the project managing the environmental variables for you.

Dependencies: The project uses the following libraries:

• ring

• reitit

• muuntaja

• libpython-clj2

• pysentimiento

Setup

  1. Clone the repository:
git clone <repository-url>
cd <repository-directory>
  1. Set up the environment:

Install Python dependencies:

pip install pysentimiento

Or create a conda environment and install pysentimiento.

Running the Service

  1. Build the uberjar:
clj -T:build uber
  1. Run the server:
java -jar target/sentiment-analysis-1.2.10-standalone.jar
  1. Server will run on port 3000:

API Endpoints
Health Check
• Endpoint: /health

• Method: GET

• Response:

{
"status": 200
}

Sentiment Analysis • Endpoint: /sentiment

• Method: POST

• Request parameters: data="Your text goes here"

• Response:

{
"sentimiento": "Positivo/Negativo/Neutro",
"probabilidades": {
"Positivo": "xx.x%",
"Negativo": "xx.x%",
"Neutro": "xx.x%"
}
}

• Example : curl -XPOST 'http://localhost:3000/sentiment' -d 'data=Un Golf no se compra se alcanza' response : {"sentimiento":"Positivo","probabilidades":{"Negativo":"7.2%","Positivo":"58.3%","Neutro":"34.4%"}} Code Overview
• Namespace: sentiment-analysis.core

• Dependencies: Required libraries are imported at the beginning.a

• Python Initialization: Python environment is initialized using libpython-clj2.

• Sentiment Analyzer: Created using pysentimiento.

• Routes: Defined for health check and sentiment analysis.

• Server: Configured to run on port 3000.

License
This project is licensed under the MIT License.

About

Proof of concept sentiment analysis using python interop

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published