Download app.py from zeechimp/hv-wall: direct link, hf CLI and curl.
- Browser
- Download file 2.02 kB
-
https://huggingface.co/zeechimp/hv-wall/resolve/main/app.py
- Command line
-
hf download hf://zeechimp/hv-wall/app.py
-
curl -L -o app.py https://huggingface.co/zeechimp/hv-wall/resolve/main/app.py
2.02 kB
| """Gradio demo for hv-wall.""" | |
| import gradio as gr | |
| from hv_wall import HVWall, SAMPLE_OVERCLAIM, SAMPLE_CONTRADICTION, \ | |
| SAMPLE_GAP, SAMPLE_CLEAN | |
| model = HVWall() | |
| def analyze_text(text: str) -> str: | |
| if not text or not text.strip(): | |
| return "Please enter some text." | |
| report = model.analyze(text) | |
| return model.render(report) | |
| def wall_only(text: str) -> str: | |
| if not text or not text.strip(): | |
| return "Please enter some text." | |
| report = model.analyze(text) | |
| if report.wall_id is None: | |
| return "No wall detected." | |
| return ( | |
| f"wall at sentence {report.wall_id} " | |
| f"({report.wall_type}, score {report.wall_score:.3f})\n" | |
| f"{report.wall_text}" | |
| ) | |
| with gr.Blocks(title="hv-wall") as demo: | |
| gr.Markdown( | |
| "# hv-wall\n" | |
| "*Where the reader stops believing a text.*\n\n" | |
| "Not from difficulty. From a claim that outruns its evidence, a " | |
| "claim that contradicts an earlier one, or a conclusion that no " | |
| "prior sentence supports." | |
| ) | |
| with gr.Row(): | |
| with gr.Column(scale=2): | |
| text_in = gr.Textbox( | |
| label="Text", | |
| lines=12, | |
| placeholder=( | |
| "Paste a paragraph, a memo, an op-ed, a review..." | |
| ), | |
| ) | |
| with gr.Row(): | |
| btn = gr.Button("Analyze", variant="primary") | |
| w_btn = gr.Button("Wall only") | |
| with gr.Column(scale=3): | |
| out = gr.Textbox( | |
| label="Report", | |
| lines=32, | |
| show_copy_button=True, | |
| ) | |
| btn.click(analyze_text, [text_in], out) | |
| w_btn.click(wall_only, [text_in], out) | |
| gr.Examples( | |
| examples=[ | |
| [SAMPLE_OVERCLAIM], | |
| [SAMPLE_CONTRADICTION], | |
| [SAMPLE_GAP], | |
| [SAMPLE_CLEAN], | |
| ], | |
| inputs=[text_in], | |
| outputs=out, | |
| fn=analyze_text, | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |