Skip to content

TextSense API is a stateless service built with Java and Spring Boot. It provides on-demand text processing, offering instant analysis of statistics, sentiment (using Stanford CoreNLP), and keywords without requiring a database

Notifications You must be signed in to change notification settings

Luca5Eckert/textsense-api-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TextSense API

Java Spring Boot

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.


Features

  • 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.

Tech Stack

  • Java: Version 21
  • Spring Boot: Version 3
  • Apache Maven: Build tool
  • Stanford CoreNLP: For sentiment analysis logic

API Contract

Endpoint: POST /analyze

Description:

Analyzes a block of text and returns comprehensive statistics and sentiment analysis.

Example Request Body

{
  "text": "This new framework is absolutely brilliant. I am overjoyed with how easy it is to use, and the performance is simply stunning."
}

Example Response Body

{
  "statistics": {
    "characterCount": 160,
    "wordCount": 29,
    "sentenceCount": 3,
    "readingTimeSeconds": 8
  },
  "sentiment": {
    "score": 3,
    "label": "POSITIVE"
  }
}
  • Score: Integer from 0 to 4, where 0 represents VERY_NEGATIVE and 4 represents VERY_POSITIVE.

How to Run Locally

Prerequisites

  • JDK: Version 21 (or 17+)
  • Apache Maven

Steps

  1. Clone the repository:
    git clone <URL_TO_YOUR_REPO>
  2. Navigate to the project directory:
    cd textsense-api
  3. Run the project:
    mvn spring-boot:run
  4. Access the API:
    http://localhost:8080
    

Usage Example

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!

About

TextSense API is a stateless service built with Java and Spring Boot. It provides on-demand text processing, offering instant analysis of statistics, sentiment (using Stanford CoreNLP), and keywords without requiring a database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages