mgbam commited on
Commit
0a3aede
·
verified ·
1 Parent(s): 428441b

Create nlp.py

Browse files
Files changed (1) hide show
  1. mcp/nlp.py +14 -0
mcp/nlp.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mcp/nlp.py
2
+
3
+ import spacy
4
+
5
+ try:
6
+ nlp = spacy.load("en_core_sci_sm")
7
+ except Exception:
8
+ nlp = spacy.load("en_core_web_sm") # Fallback to general English
9
+
10
+ def extract_keywords(text: str):
11
+ """Extract biomedical entities and drugs from text."""
12
+ doc = nlp(text)
13
+ keywords = list(set(ent.text for ent in doc.ents if len(ent.text) > 2))
14
+ return keywords