Spaces:
Sleeping
Sleeping
Create hoax_scan.py
Browse files- hoax_scan.py +28 -0
hoax_scan.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# hoax_scan.py
|
| 2 |
+
import argparse
|
| 3 |
+
import sys
|
| 4 |
+
from nexis_signal_engine import NexisSignalEngine
|
| 5 |
+
|
| 6 |
+
def main():
|
| 7 |
+
p = argparse.ArgumentParser(description="Nexis/Nexus hoax scan")
|
| 8 |
+
p.add_argument("--db", default="signals.db", help="SQLite DB path (.db)")
|
| 9 |
+
p.add_argument("--source", default=None, help="Source URL (optional)")
|
| 10 |
+
p.add_argument("text", nargs="*", help="Text to scan (or stdin)")
|
| 11 |
+
args = p.parse_args()
|
| 12 |
+
|
| 13 |
+
engine = NexisSignalEngine(memory_path=args.db)
|
| 14 |
+
|
| 15 |
+
if args.text:
|
| 16 |
+
text = " ".join(args.text)
|
| 17 |
+
else:
|
| 18 |
+
text = sys.stdin.read()
|
| 19 |
+
|
| 20 |
+
result = engine.process_news(text, source_url=args.source)
|
| 21 |
+
print(json_dump(result))
|
| 22 |
+
|
| 23 |
+
def json_dump(obj):
|
| 24 |
+
import json
|
| 25 |
+
return json.dumps(obj, indent=2, sort_keys=True, ensure_ascii=False)
|
| 26 |
+
|
| 27 |
+
if __name__ == "__main__":
|
| 28 |
+
main()
|