File size: 3,092 Bytes
6aabd96 aec710a 6aabd96 aec710a 6aabd96 aec710a 6aabd96 aec710a 6aabd96 aec710a 6aabd96 aec710a 6aabd96 aec710a 6aabd96 aec710a 6aabd96 | 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | """
pipeline.py
Core orchestration layer for SIGMA Intelligence Analyzer.
Combines:
- Explicit fact extraction
- Hypothesis generation
- MNLI validation
- Summarization
"""
from .fact_extractor import FactExtractor
from .inference_engine import InferenceEngine
from .summarizer import BriefSummarizer
class SigmaPipeline:
def __init__(self):
self.fact_extractor = FactExtractor()
self.inference_engine = InferenceEngine()
self.summarizer = BriefSummarizer()
def analyze(self, text):
"""
Full intelligence analysis workflow.
"""
structured_facts = self.fact_extractor.extract_structured_facts(text)
hypotheses = self._generate_hypotheses(structured_facts)
validated_inferences = self.inference_engine.validate_hypotheses(
text,
hypotheses
)
summary = self.summarizer.summarize(text)
return {
"explicit_facts": structured_facts,
"implicit_inferences": validated_inferences,
"summary": summary
}
def _generate_hypotheses(self, structured_facts):
"""
Internal method to generate normalized hypotheses
from extracted structured facts.
Purpose:
Convert extracted factual structures into
standalone propositions suitable for MNLI validation.
"""
hypotheses = []
reporting_verbs = {
"report",
"confirm",
"state",
"announce",
"detect",
"record",
"identify"
}
assessment_verbs = {
"believe",
"assess",
"suspect",
"estimate"
}
for fact in structured_facts:
action = fact["action"]
obj = fact["object"]
if not obj:
continue
obj = obj.strip()
# -----------------------------------
# NEGATED ACTIONS
# -----------------------------------
if action.startswith("not "):
clean_action = action.replace("not ", "")
if clean_action == "attribute":
hypotheses.append(f"It is not confirmed that {obj}.")
else:
hypotheses.append(f"It did not occur that {obj}.")
# -----------------------------------
# REPORTING / OBSERVATION VERBS
# -----------------------------------
elif action in reporting_verbs:
hypotheses.append(f"There was {obj}.")
# -----------------------------------
# ANALYTIC / ASSESSMENT VERBS
# -----------------------------------
elif action in assessment_verbs:
hypotheses.append(obj)
# -----------------------------------
# DEFAULT FALLBACK
# -----------------------------------
else:
hypotheses.append(obj)
return hypotheses |