hv-wall / example.py
zeechimp's picture
Create example.py
0fcc7ea verified
Raw History Blame Contribute Delete
1.54 kB
"""Minimal usage example for hv-wall."""
from hv_wall import HVWall
TEXT = (
"The data suggests some correlation between the policy and the outcome. "
"Results appear to indicate a modest effect in some subpopulations. "
"The mechanism remains unclear, and further work is needed to establish "
"causality. "
"Therefore, the policy definitively causes the outcome in all cases, "
"and this is unquestionably proven by the evidence."
)
def main() -> None:
model = HVWall()
report = model.analyze(TEXT)
print("=" * 60)
print("hv-wall")
print("=" * 60)
print(model.render(report))
print()
print("=" * 60)
print("Numeric summary")
print("=" * 60)
print(f" sentences : {report.n_sentences}")
print(f" words : {report.n_words}")
print(f" wall_id : {report.wall_id}")
print(f" wall_type : {report.wall_type}")
print(f" wall_score : {report.wall_score:.4f}")
print(f" conf style : {report.confidence_style}")
print(f" evid style : {report.evidence_style}")
print(f" trust curve : "
+ " ".join(f"{v:.2f}" for v in report.trust_curve))
print()
print("=" * 60)
print("Wall sentence")
print("=" * 60)
print(f" \"{report.wall_text}\"")
print()
print("=" * 60)
print("Reasons")
print("=" * 60)
if report.wall_id is not None:
for r in report.profiles[report.wall_id].reasons:
print(f" - {r}")
print()
if __name__ == "__main__":
main()