-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
26 lines (20 loc) · 640 Bytes
/
app.py
File metadata and controls
26 lines (20 loc) · 640 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from flask import Flask, request, jsonify
import spacy
# Load spaCy NLP model
nlp = spacy.load("en_core_web_md")
app = Flask(__name__)
# Auto-tagging function
def generate_tags(text):
doc = nlp(text)
tags = list(set(ent.text for ent in doc.ents)) # Extract unique named entities
return tags
@app.route("/analyze", methods=["POST"])
def analyze():
data = request.get_json()
text = data.get("text", "")
if not text:
return jsonify({"error": "No text provided"}), 400
tags = generate_tags(text)
return jsonify({"tags": tags})
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)