clinical-ner / app /test_clinical_ner.py
santanche's picture
feat (pos-tagging): new pos-tagging feature
75c061c
Raw
History Blame
954 Bytes
from clinical_ner import ClinicalNER
# Initialize the NER system with POS tagging
ner = ClinicalNER(use_pos=True)
# Sample clinical text
text = "Patient presents with hypertension and diabetes. Prescribed metformin 500mg."
print("="*70)
print("NAMED ENTITY RECOGNITION")
print("="*70)
results = ner.basic_ner(text)
for entity in results:
print(f" {entity['word']} -> {entity['entity_group']} (score: {entity['score']:.4f})")
print("\n" + "="*70)
print("PART-OF-SPEECH TAGGING")
print("="*70)
pos_results = ner.pos_tagging(text)
for token in pos_results:
print(f" {token['token']:15} | POS: {token['pos']:6} | Tag: {token['tag']:6} | Dep: {token['dep']}")
print("\n" + "="*70)
print("PROLOG FACTS - NER")
print("="*70)
print(ner.prolog_ner(text))
print("\n" + "="*70)
print("PROLOG FACTS - POS")
print("="*70)
print(ner.prolog_pos(text))
print("\n" + "="*70)
print("COMBINED PROLOG FACTS")
print("="*70)
print(ner.prolog_combined(text))