File size: 1,832 Bytes
59dd1d1 abe5199 59dd1d1 abe5199 bcf0f28 abe5199 bcf0f28 abe5199 bcf0f28 abe5199 bcf0f28 abe5199 bcf0f28 abe5199 59dd1d1 6b7c1ff bcf0f28 6b7c1ff abe5199 00b6f2e 6b7c1ff bcf0f28 6b7c1ff 00b6f2e 6b7c1ff bcf0f28 6b7c1ff bcf0f28 59dd1d1 6b7c1ff 59dd1d1 | 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import gradio as gr
from src.pipeline import SigmaPipeline
# Initialize pipeline once during startup
pipeline = SigmaPipeline()
def analyze_text(text):
"""
Run full SIGMA analysis pipeline and format results.
"""
result = pipeline.analyze(text)
formatted_output = []
formatted_output.append("## EXPLICIT FACTS\n")
for fact in result["explicit_facts"]:
formatted_output.append(
f"- **{fact['subject']}** → `{fact['action']}` → {fact['object']}"
)
formatted_output.append("\n## IMPLICIT INFERENCES\n")
for inference in result["implicit_inferences"]:
formatted_output.append(
f"- **[{inference['label']}]** "
f"{inference['hypothesis']} \n"
f" Confidence: `{inference['confidence']}` "
f"({inference['confidence_tier']})"
)
formatted_output.append("\n## ANALYTIC SUMMARY\n")
formatted_output.append(result["summary"])
return "\n".join(formatted_output)
demo = gr.Interface(
fn=analyze_text,
inputs=gr.Textbox(
lines=12,
label="Intelligence Report Input",
placeholder="Paste intelligence-style narrative text here.\nClick Submit and wait for results to appear on the right panel."
),
outputs=gr.Markdown(),
title="SIGMA: Structured Intelligence & Grounded Meaning Analyzer",
description=(
"SIGMA extracts explicit facts, evaluates implicit inferences using Natural Language Inference (MNLI), and generates "
"concise intelligence-style summaries using pretrained NLP models. "
"For details, refer to [README.md](https://huggingface.co/spaces/morinousagi/nlp-intelligence-analyzer/blob/main/README.md)"
),
show_progress="full"
)
if __name__ == "__main__":
demo.queue()
demo.launch() |