Skip to content

Commit 82dbc75

Browse files
committed
Implement TextRazor NLP Analyzer with frontend and backend integration
1 parent 44c094b commit 82dbc75

File tree

10 files changed

+3274
-0
lines changed

10 files changed

+3274
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# TextRazor API Integration - Project Summary
2+
3+
**Complete Implementation Ready!**
4+
5+
## What's Been Built
6+
7+
### 🔧 Backend (Node.js + Express)
8+
9+
- **Server**: Full REST API server with TextRazor integration
10+
- **Routes**: Comprehensive API endpoints for all NLP features
11+
- **Security**: Rate limiting, CORS, helmet protection
12+
- **Error Handling**: Robust error management and validation
13+
14+
### 🎨 Frontend (HTML/CSS/JavaScript)
15+
16+
- **Interface**: Clean, modern, responsive web interface
17+
- **Features**: Entity extraction, sentiment analysis, topic classification
18+
- **UX**: Real-time feedback, loading states, error handling
19+
- **Export**: JSON export functionality for results
20+
21+
### 📁 Project Structure
22+
23+
```
24+
TextRazor_API/
25+
├── README.md
26+
├── PROJECT_SUMMARY.md
27+
└── server/
28+
├── package.json
29+
├── package-lock.json
30+
├── server.js
31+
├── .env.example
32+
├── .env
33+
├── node_modules/
34+
├── routes/
35+
│ └── textrazor.js
36+
└── public/
37+
├── index.html
38+
├── styles.css
39+
└── script.js
40+
```
41+
42+
## 🚀 Ready to Use
43+
44+
### Server Endpoints Available:
45+
46+
- `POST /api/analyze` - Full text analysis
47+
- `POST /api/entities` - Entity extraction only
48+
- `POST /api/sentiment` - Sentiment analysis only
49+
- `POST /api/topics` - Topic classification only
50+
- `POST /api/language` - Language detection only
51+
- `GET /health` - Health check
52+
53+
### Frontend Features:
54+
55+
- Interactive text input with sample texts
56+
- Checkbox options for analysis types (entities, sentiment, topics, relations, language)
57+
- Real-time results display with visual indicators
58+
- Export functionality (JSON download)
59+
- Mobile-responsive design
60+
- Loading states and error handling
61+
62+
## 🔑 Next Steps
63+
64+
1. Get TextRazor API key from textrazor.com
65+
2. Create .env file with your API key in the server directory
66+
3. Run the server: `cd server && npm start`
67+
4. Open server/public/index.html in browser or visit http://localhost:5000
68+
5. Start analyzing text!
69+
70+
**All ready for deployment and use! 🎉**

New_APIs/TextRazor_API/README.md

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
# TextRazor API Integration
2+
3+
## Description
4+
5+
This API integration provides natural language processing capabilities using TextRazor's powerful NLP service. It offers entity extraction, sentiment analysis, topic classification, and relationship extraction from text documents. The application features a clean HTML/CSS/JavaScript frontend for interactive text analysis and a Node.js backend for API integration.
6+
7+
## Features
8+
9+
1. **Entity Extraction** - Identify and extract entities (people, places, organizations, etc.) from text
10+
2. **Sentiment Analysis** - Analyze the emotional tone and sentiment of text content
11+
3. **Topic Classification** - Automatically categorize text into relevant topics
12+
4. **Relationship Extraction** - Discover relationships between entities in the text
13+
5. **Language Detection** - Automatically detect the language of input text
14+
6. **Interactive Web Interface** - User-friendly HTML/CSS/JavaScript frontend for text analysis
15+
16+
## Requirements
17+
18+
- Node.js (v14 or higher)
19+
- npm or yarn
20+
- TextRazor API key (free tier available)
21+
- Modern web browser
22+
23+
## Installation
24+
25+
### 1. Clone the Repository:
26+
27+
```bash
28+
git clone <repository-url>
29+
cd TextRazor_API
30+
```
31+
32+
### 2. Install Server Dependencies:
33+
34+
```bash
35+
cd server
36+
npm install
37+
```
38+
39+
### 3. Setup Environment Variables:
40+
41+
Create a `.env` file in the server directory:
42+
43+
```env
44+
TEXTRAZOR_API_KEY=your_textrazor_api_key_here
45+
PORT=5000
46+
```
47+
48+
### 4. Get TextRazor API Key:
49+
50+
1. Visit [TextRazor](https://www.textrazor.com/)
51+
2. Sign up for a free account
52+
3. Get your API key from the dashboard
53+
4. Add it to your `.env` file
54+
55+
## Usage
56+
57+
### Start the Server:
58+
59+
```bash
60+
cd server
61+
npm start
62+
```
63+
64+
### Access the Application:
65+
66+
The server serves both the API and the web interface:
67+
68+
- **Web Interface**: Open your browser and go to `http://localhost:5000`
69+
- **API Endpoints**: Available at `http://localhost:5000/api/`
70+
71+
Alternatively, you can directly open the HTML file:
72+
73+
```bash
74+
# Navigate to server/public and open index.html in your browser
75+
cd server/public
76+
# Open index.html in your default browser (double-click or right-click -> Open with -> Browser)
77+
```
78+
79+
## API Endpoints
80+
81+
### 1. Analyze Text
82+
83+
```http
84+
POST /api/analyze
85+
Content-Type: application/json
86+
87+
{
88+
"text": "Your text to analyze here",
89+
"extractors": ["entities", "sentiment", "topics", "relations", "language"]
90+
}
91+
```
92+
93+
### 2. Extract Entities Only
94+
95+
```http
96+
POST /api/entities
97+
Content-Type: application/json
98+
99+
{
100+
"text": "Your text here"
101+
}
102+
```
103+
104+
### 3. Sentiment Analysis Only
105+
106+
```http
107+
POST /api/sentiment
108+
Content-Type: application/json
109+
110+
{
111+
"text": "Your text here"
112+
}
113+
```
114+
115+
### 4. Topic Classification
116+
117+
```http
118+
POST /api/topics
119+
Content-Type: application/json
120+
121+
{
122+
"text": "Your text here"
123+
}
124+
```
125+
126+
### 5. Language Detection
127+
128+
```http
129+
POST /api/language
130+
Content-Type: application/json
131+
132+
{
133+
"text": "Your text here"
134+
}
135+
```
136+
137+
## Example Response
138+
139+
### Entity Extraction Response:
140+
141+
```json
142+
{
143+
"success": true,
144+
"entities": [
145+
{
146+
"id": "Apple Inc.",
147+
"type": "Company",
148+
"confidence": 0.95,
149+
"relevanceScore": 0.8,
150+
"matchedText": "Apple"
151+
}
152+
],
153+
"sentiment": {
154+
"score": 0.2,
155+
"label": "positive"
156+
},
157+
"topics": [
158+
{
159+
"id": "Technology",
160+
"score": 0.85
161+
}
162+
]
163+
}
164+
```
165+
166+
### Language Detection Response:
167+
168+
```json
169+
{
170+
"success": true,
171+
"language": {
172+
"code": "eng",
173+
"isReliable": true
174+
},
175+
"metadata": {
176+
"textLength": 150
177+
}
178+
}
179+
```
180+
181+
## Technology Stack
182+
183+
- **Frontend**: HTML5, CSS3, JavaScript (Vanilla)
184+
- **Backend**: Node.js, Express.js
185+
- **API**: TextRazor NLP API
186+
- **HTTP Client**: Fetch API (built-in)
187+
188+
## Features Demo
189+
190+
1. **Text Input**: Large textarea for entering text to analyze with auto-resize functionality
191+
2. **Analysis Options**: Checkboxes to select which analysis to perform (entities, sentiment, topics, relations, language)
192+
3. **Results Display**: Organized sections showing entities, sentiment, topics, relationships, and language detection
193+
4. **Visual Indicators**: Color-coded sentiment results and confidence scores
194+
5. **Export Results**: Download analysis results as JSON file
195+
6. **Responsive Design**: Works on desktop, tablet, and mobile devices
196+
7. **Real-time Feedback**: Loading states and error handling
197+
8. **Sample Texts**: Pre-loaded example texts for quick testing
198+
199+
## Notes
200+
201+
- Free TextRazor account includes 500 requests per day
202+
- Ensure your API key is kept secure and not committed to version control
203+
- The application handles various text formats and languages
204+
- Error handling is implemented for API failures and network issues
205+
- The server serves both API endpoints and the web interface on the same port
206+
207+
## Contributing
208+
209+
Please follow the project's contributing guidelines and ensure all code is properly tested before submitting pull requests.
210+
211+
## License
212+
213+
This project is licensed under the MIT License.
214+
215+
## Project Structure
216+
217+
```
218+
TextRazor_API/
219+
├── README.md
220+
├── PROJECT_SUMMARY.md
221+
└── server/
222+
├── package.json
223+
├── package-lock.json
224+
├── server.js
225+
├── .env.example
226+
├── .env
227+
├── node_modules/
228+
├── routes/
229+
│ └── textrazor.js
230+
└── public/
231+
├── index.html
232+
├── styles.css
233+
└── script.js
234+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# TextRazor API Configuration
2+
TEXTRAZOR_API_KEY=your_textrazor_api_key_here
3+
4+
# Server Configuration
5+
PORT=5000
6+
NODE_ENV=development
7+
8+
# Client Configuration
9+
CLIENT_URL=http://localhost:3000

0 commit comments

Comments
 (0)