Spaces:
Sleeping
Sleeping
Download reasoning_engine.py from FuzzyD1no/kasaysayan-check: direct link, hf CLI and curl.
- Browser
- Download file 12.2 kB
-
https://huggingface.co/spaces/FuzzyD1no/kasaysayan-check/resolve/main/reasoning_engine.py
- Command line
-
hf download hf://spaces/FuzzyD1no/kasaysayan-check/reasoning_engine.py
-
curl -L -o reasoning_engine.py https://huggingface.co/spaces/FuzzyD1no/kasaysayan-check/resolve/main/reasoning_engine.py
12.2 kB
| import collections | |
| import collections.abc | |
| # Python 3.10 patch for experta | |
| collections.Mapping = collections.abc.Mapping | |
| from experta import * | |
| # ========================================== | |
| # 1. DEFINE FACT SCHEMAS | |
| # ========================================== | |
| class MLClaim(Fact): | |
| """Data coming from the multi-layered AI pipeline.""" | |
| pass | |
| class KBRecord(Fact): | |
| """Verified data pulled from your Knowledge Base/Database.""" | |
| pass | |
| # ========================================== | |
| # 2. THE REASONING ENGINE | |
| # ========================================== | |
| class KasaysayanEngine(KnowledgeEngine): | |
| # ---------------------------------------------------- | |
| # RULE 1: The Nostalgia Filter (Semantic Override) | |
| # ---------------------------------------------------- | |
| def apply_nostalgia_filter(self, text): | |
| print("\n[TRIGGERED: NOSTALGIA FILTER (SEMANTIC MATCH)] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: FALSE / MISLEADING") | |
| print("Reasoning: This claim perfectly aligns with the 'Golden Age' semantic narrative. The Knowledge Base verifies severe economic debt and documented violations during this period.") | |
| # ---------------------------------------------------- | |
| # RULE 2: Election Integrity Defense (Entity/Semantic Override) | |
| # ---------------------------------------------------- | |
| def apply_election_defense(self, text): | |
| print("\n [TRIGGERED: INSTITUTIONAL ATTACK DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: UNVERIFIED / POTENTIAL DISINFORMATION") | |
| print("Reasoning: Claim makes allegations against the COMELEC. The Knowledge Base currently shows no verified systemic fraud that supports this claim.") | |
| # ---------------------------------------------------- | |
| # RULE 3: Human Rights Denial Defense (Semantic Override) | |
| # ---------------------------------------------------- | |
| def apply_human_rights_defense(self, text): | |
| print("\n [TRIGGERED: ATROCITY DENIAL DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: FALSE / HISTORICAL REVISIONISM") | |
| print("Reasoning: This claim denies documented atrocities. The Knowledge Base independently verifies that severe human rights violations occurred during this period.") | |
| # ---------------------------------------------------- | |
| # RULE 4: Economy Myth Defense | |
| # ---------------------------------------------------- | |
| def apply_economy_defense(self, text): | |
| print("\n [TRIGGERED: ECONOMIC REVISIONISM DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: FALSE / MISLEADING") | |
| print("Reasoning: The Knowledge Base confirms massive debt existed during this period.") | |
| # ---------------------------------------------------- | |
| # RULE 5: Crime Myth Defense | |
| # ---------------------------------------------------- | |
| def apply_crime_myth_defense(self, text): | |
| print("\n [TRIGGERED: PEACE & ORDER MYTH DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: FALSE / MISLEADING") | |
| print("Reasoning: The Knowledge Base confirms thousands were arbitrarily arrested without trial during this period.") | |
| # ---------------------------------------------------- | |
| # RULE 6: Marcos Best President Defense | |
| # ---------------------------------------------------- | |
| def apply_marcos_best_defense(self, text): | |
| print("\n [TRIGGERED: LEADERSHIP GLORIFICATION DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: DISPUTED / MISLEADING") | |
| print("Reasoning: The Knowledge Base confirms billions in ill-gotten wealth were stolen from the Filipino people.") | |
| # ---------------------------------------------------- | |
| # RULE 7: Press Freedom Myth Defense | |
| # ---------------------------------------------------- | |
| def apply_press_myth_defense(self, text): | |
| print("\n [TRIGGERED: PRESS FREEDOM MYTH DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: FALSE") | |
| print("Reasoning: The Knowledge Base confirms all major media outlets were shut down or controlled by the regime.") | |
| # ---------------------------------------------------- | |
| # RULE 8: Infrastructure Myth Defense | |
| # ---------------------------------------------------- | |
| def apply_infrastructure_myth_defense(self, text): | |
| print("\n [TRIGGERED: INFRASTRUCTURE MYTH DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: FALSE / MISLEADING") | |
| print("Reasoning: The Knowledge Base confirms many projects were overpriced and funded through foreign debt that burdened future generations.") | |
| # ---------------------------------------------------- | |
| # RULE 9: Anti-Vaccine Myth Defense | |
| # ---------------------------------------------------- | |
| def apply_antivax_defense(self, text): | |
| print("\n [TRIGGERED: ANTI-VACCINE MISINFORMATION DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: FALSE / DANGEROUS MISINFORMATION") | |
| print("Reasoning: The Knowledge Base confirms vaccines are WHO-approved and the scientific consensus finds no link between vaccines and autism.") | |
| # ---------------------------------------------------- | |
| # RULE 10: COVID Misinformation Defense | |
| # ---------------------------------------------------- | |
| def apply_covid_defense(self, text): | |
| print("\n [TRIGGERED: COVID MISINFORMATION DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: FALSE / DANGEROUS MISINFORMATION") | |
| print("Reasoning: The Knowledge Base confirms COVID-19 was a WHO-declared global pandemic and vaccines contain no microchips.") | |
| # ---------------------------------------------------- | |
| # RULE 11: West Philippine Sea Denial Defense | |
| # ---------------------------------------------------- | |
| def apply_wps_defense(self, text): | |
| print("\n [TRIGGERED: WEST PHILIPPINE SEA DENIAL DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: FALSE / LEGALLY BASELESS") | |
| print("Reasoning: The Knowledge Base confirms the Philippines won the 2016 UNCLOS arbitration ruling. China's claim has no basis under international law.") | |
| # ---------------------------------------------------- | |
| # RULE 12: Climate Change Denial Defense | |
| # ---------------------------------------------------- | |
| def apply_climate_defense(self, text): | |
| print("\n [TRIGGERED: CLIMATE CHANGE DENIAL DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: FALSE / ANTI-SCIENCE") | |
| print("Reasoning: The Knowledge Base confirms that 97% of climate scientists agree climate change is real and primarily caused by human activity.") | |
| # ---------------------------------------------------- | |
| # RULE 13: Social Media Propaganda Defense | |
| # ---------------------------------------------------- | |
| def apply_social_media_defense(self, text): | |
| print("\n [TRIGGERED: ANTI-MEDIA PROPAGANDA DETECTED] ") | |
| print(f"Analyzing Claim: '{text}'") | |
| print("VERDICT: MISLEADING / PROPAGANDA") | |
| print("Reasoning: The Knowledge Base confirms mainstream media is regulated and fact-checked, while social media remains largely unverified and prone to disinformation.") |