Create example.py
Browse files- example.py +46 -0
example.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Minimal usage example for hv-core."""
|
| 2 |
+
from hv_core import HVCore
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
TEXT = (
|
| 6 |
+
"The patient presented with chest pain. The ECG showed ST elevation "
|
| 7 |
+
"in leads V2 through V5. Troponin levels were elevated at 0.8 ng/mL. "
|
| 8 |
+
"A cardiologist was consulted within 20 minutes. The patient is "
|
| 9 |
+
"hemodynamically stable. Therefore the patient is having an acute "
|
| 10 |
+
"myocardial infarction. Immediate catheterization is indicated."
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def main() -> None:
|
| 15 |
+
model = HVCore()
|
| 16 |
+
|
| 17 |
+
report = model.analyze(TEXT)
|
| 18 |
+
|
| 19 |
+
print("=" * 60)
|
| 20 |
+
print("hv-core")
|
| 21 |
+
print("=" * 60)
|
| 22 |
+
print(model.render(report))
|
| 23 |
+
print()
|
| 24 |
+
|
| 25 |
+
print("=" * 60)
|
| 26 |
+
print("Numeric summary")
|
| 27 |
+
print("=" * 60)
|
| 28 |
+
print(f" conclusion : {report.conclusion['text']}")
|
| 29 |
+
print(f" robustness : {report.robustness}")
|
| 30 |
+
print(f" tier : {report.robustness_tier}")
|
| 31 |
+
print(f" cut size : {report.cut_size}")
|
| 32 |
+
print(f" min flip cost : {report.min_flip_cost}")
|
| 33 |
+
print(f" redundancy : {report.redundancy_index:.3f}")
|
| 34 |
+
print(f" load-bearing : {report.load_bearing_claim}")
|
| 35 |
+
print()
|
| 36 |
+
|
| 37 |
+
print("=" * 60)
|
| 38 |
+
print("Flip set")
|
| 39 |
+
print("=" * 60)
|
| 40 |
+
for f in model.flips(TEXT, top=5):
|
| 41 |
+
print(f" cost={f.cost:.3f} node=[{f.node_id}] {f.edit}")
|
| 42 |
+
print()
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
if __name__ == "__main__":
|
| 46 |
+
main()
|