File size: 1,323 Bytes
94bbd6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""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()