TextSense API is a lightweight, stateless (no database) API built with Java and Spring Boot to enable real-time text analysis. This service focuses on providing on-demand processing with high performance and simplicity.
- Text Statistics: Calculates word count, character count, sentence count, and estimated reading time.
- Sentiment Analysis: Analyzes the overall sentiment of the provided text, returning a sentiment label (e.g., POSITIVE, NEGATIVE) and a score.
- Java: Version 21
- Spring Boot: Version 3
- Apache Maven: Build tool
- Stanford CoreNLP: For sentiment analysis logic
Analyzes a block of text and returns comprehensive statistics and sentiment analysis.
{
"text": "This new framework is absolutely brilliant. I am overjoyed with how easy it is to use, and the performance is simply stunning."
}{
"statistics": {
"characterCount": 160,
"wordCount": 29,
"sentenceCount": 3,
"readingTimeSeconds": 8
},
"sentiment": {
"score": 3,
"label": "POSITIVE"
}
}- Score: Integer from
0to4, where0representsVERY_NEGATIVEand4representsVERY_POSITIVE.
- JDK: Version 21 (or 17+)
- Apache Maven
- Clone the repository:
git clone <URL_TO_YOUR_REPO>
- Navigate to the project directory:
cd textsense-api - Run the project:
mvn spring-boot:run
- Access the API:
http://localhost:8080
You can test the API using curl as shown below:
curl -X POST http://localhost:8080/analyze \
-H "Content-Type: application/json" \
-d '{
"text": "This is a great test, but the second part was awful."
}'Sample Response:
{
"statistics": {
"characterCount": 55,
"wordCount": 12,
"sentenceCount": 2,
"readingTimeSeconds": 3
},
"sentiment": {
"score": 2,
"label": "NEUTRAL"
}
}Enjoy leveraging the TextSense API for all your real-time text analysis needs!