|
a |
|
b/test_negation.py |
|
|
1 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, TextClassificationPipeline |
|
|
2 |
tokenizer = AutoTokenizer.from_pretrained("bvanaken/clinical-assertion-negation-bert") |
|
|
3 |
model = AutoModelForSequenceClassification.from_pretrained("bvanaken/clinical-assertion-negation-bert") |
|
|
4 |
|
|
|
5 |
|
|
|
6 |
input = "The patient recovered during the night and now denies any [entity] shortness of breath [entity]." |
|
|
7 |
input = "Excess sodium from aspirin is not linked to elevations in blood pressure (BP)." |
|
|
8 |
|
|
|
9 |
|
|
|
10 |
classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer) |
|
|
11 |
|
|
|
12 |
classification = classifier(input) |
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
print(classification) |