A web app that analyzes the emotional tone of text using natural language processing. Built with Spring Boot and Stanford CoreNLP, it gives you real-time sentiment analysis with detailed scoring and keeps track of your analysis history.
Ever wondered if your text sounds positive, negative, or neutral? This app helps you figure that out. It's useful for:
- Analyzing customer feedback
- Checking social media posts
- Reviewing your own writing
- Understanding how your messages might be perceived
The app breaks down text sentence by sentence and gives you scores for positive, negative, and neutral tones, plus an overall sentiment with confidence level.
- Real-time Analysis: Get results instantly as you type
- Detailed Scoring: See individual scores for positive, negative, and neutral
- Confidence Metrics: Know how certain the analysis is
- History Tracking: Keep track of all your analyses with timestamps
- Local Storage: Your data stays on your device
- Clean Interface: Works great on desktop and mobile
- REST API: Easy to integrate with other apps
- Java 17: Modern Java with good performance
- Spring Boot 3.2.0: Fast development framework
- Stanford CoreNLP: Industry-standard NLP library
- Maven: Build and dependency management
- Vanilla JavaScript: Modern ES6+ features, no framework bloat
- Tailwind CSS: Utility-first CSS for quick development
- HTML5: Clean, semantic markup
- Java 17 or higher
- Maven 3.6 or higher
- A modern web browser
-
Get the code
git clone https://github.com/yourusername/sentiment-analyzer-app.git cd sentiment-analyzer-app -
Build it
mvn clean compile
-
Run it
mvn spring-boot:run
-
Open in browser
- Web Interface: http://localhost:8080
- API Endpoint: http://localhost:8080/api/analyze
- Health Check: http://localhost:8080/api/health
- Open your browser and go to
http://localhost:8080 - Type or paste text in the input field
- Click "Analyze Sentiment" or press Enter
- View the results with confidence scores
- Check your analysis history below
curl -X POST http://localhost:8080/api/analyze \
-H "Content-Type: application/json" \
-d '{"text": "This is absolutely wonderful!"}'Example Response:
{
"text": "This is absolutely wonderful!",
"sentiment": "Positive",
"confidence": 0.75,
"positiveScore": 0.75,
"negativeScore": 0.0,
"neutralScore": 0.25
}curl http://localhost:8080/api/healthAnalyzes the sentiment of your text.
Request:
{
"text": "Your text here"
}Response:
{
"text": "Your text here",
"sentiment": "Positive|Negative|Neutral",
"confidence": 0.75,
"positiveScore": 0.75,
"negativeScore": 0.0,
"neutralScore": 0.25
}Simple health check to see if the app is running.
Response:
Sentiment Analyzer App is running!
The app uses a layered architecture:
┌─────────────────┐
│ Frontend │ ← User interface
├─────────────────┤
│ Controller │ ← API endpoints
├─────────────────┤
│ Service │ ← Business logic
├─────────────────┤
│ Stanford │ ← NLP processing
│ CoreNLP │
└─────────────────┘
What happens when you analyze text:
- Frontend sends your text to the backend
- Controller receives the request and passes it to the service
- Service processes the text through Stanford CoreNLP
- CoreNLP analyzes each sentence for sentiment
- Service calculates overall scores and classification
- Controller returns the results to the frontend
- Frontend displays the results and updates counters
The app uses sensible defaults but you can customize:
- Port: Change
server.portinapplication.properties - CORS: Currently allows all origins for development
- CoreNLP: Configured with tokenize, ssplit, pos, parse, lemma, and sentiment annotators
src/
├── main/
│ ├── java/
│ │ └── com/sentiment/analyzer/
│ │ ├── SentimentAnalyzerApplication.java ← Main app class
│ │ ├── controller/
│ │ │ └── SentimentController.java ← API endpoints
│ │ ├── service/
│ │ │ └── SentimentAnalysisService.java ← Business logic
│ │ └── dto/
│ │ ├── SentimentRequest.java ← Request data
│ │ └── SentimentResponse.java ← Response data
│ └── resources/
│ ├── static/
│ │ ├── index.html ← Main page
│ │ └── js/
│ │ └── sentiment-analyzer.js ← Frontend logic
│ └── application.properties ← Configuration
└── test/
└── java/
└── com/sentiment/analyzer/
└── SentimentAnalyzerApplicationTests.java
# Clean and compile
mvn clean compile
# Run tests
mvn test
# Package as JAR
mvn package
# Run the JAR
java -jar target/sentiment-analyzer-app-1.0.0.jarThe code is organized to make it easy to add new features:
- New API endpoints: Add methods to
SentimentController - Business logic: Extend
SentimentAnalysisService - Frontend features: Modify
sentiment-analyzer.js - Data models: Update the DTOs in the
dtopackage
I welcome contributions! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Commit with a clear message (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
Port 8080 already in use:
# Find what's using the port
netstat -ano | findstr :8080
# Kill the process (replace PID with actual process ID)
taskkill /F /PID <PID>Java version issues:
# Check your Java version
java -version
# Should show Java 17 or higherMaven issues:
# Clean and try again
mvn clean
mvn spring-boot:runApplication won't start:
- Check if port 8080 is free
- Make sure Java 17+ is installed
- Verify Maven is working:
mvn --version
Frontend not loading:
- Check browser console for errors
- Make sure the backend is running
- Try clearing browser cache
- First startup: Takes a few seconds to load CoreNLP models
- Memory usage: CoreNLP models use about 500MB RAM
- Response time: Analysis typically takes 100-500ms depending on text length
- Scalability: Built for single-user or small-scale use
- CORS: Currently allows all origins (fine for development)
- Input validation: Basic null/empty checks implemented
- Error handling: Generic error messages to avoid information leakage
- Local storage: Data stays on user's device
Some ideas for future versions:
- User authentication and accounts
- Batch processing for multiple texts
- Export results to CSV/PDF
- More detailed sentiment analysis
- Support for other languages
- Docker containerization
This project is open source under the MIT License. See the LICENSE file for details.
- Stanford CoreNLP for the powerful NLP capabilities
- Spring Boot for the excellent framework
- Tailwind CSS for the beautiful UI components
- Initial release
- Basic sentiment analysis
- Web interface
- REST API
- History tracking
- Local storage
Built with ❤️ by Vishnu using Spring Boot and Stanford CoreNLP