hv-core / example.py
zeechimp's picture
Create example.py
94bbd6a verified
Raw History Blame Contribute Delete
1.32 kB
"""Minimal usage example for hv-core."""
from hv_core import HVCore
TEXT = (
"The patient presented with chest pain. The ECG showed ST elevation "
"in leads V2 through V5. Troponin levels were elevated at 0.8 ng/mL. "
"A cardiologist was consulted within 20 minutes. The patient is "
"hemodynamically stable. Therefore the patient is having an acute "
"myocardial infarction. Immediate catheterization is indicated."
)
def main() -> None:
model = HVCore()
report = model.analyze(TEXT)
print("=" * 60)
print("hv-core")
print("=" * 60)
print(model.render(report))
print()
print("=" * 60)
print("Numeric summary")
print("=" * 60)
print(f" conclusion : {report.conclusion['text']}")
print(f" robustness : {report.robustness}")
print(f" tier : {report.robustness_tier}")
print(f" cut size : {report.cut_size}")
print(f" min flip cost : {report.min_flip_cost}")
print(f" redundancy : {report.redundancy_index:.3f}")
print(f" load-bearing : {report.load_bearing_claim}")
print()
print("=" * 60)
print("Flip set")
print("=" * 60)
for f in model.flips(TEXT, top=5):
print(f" cost={f.cost:.3f} node=[{f.node_id}] {f.edit}")
print()
if __name__ == "__main__":
main()