Spaces:
Sleeping
Sleeping
Refactor: Production-grade modular layout, NLTK permissions fix, and editorial audit dashboard overhaul
405a3f0 Download main.py from amadmateen/SentinelReview-AI: direct link, hf CLI and curl.
- Browser
- Download file 2.33 kB
-
https://huggingface.co/spaces/amadmateen/SentinelReview-AI/resolve/main/main.py
- Command line
-
hf download hf://spaces/amadmateen/SentinelReview-AI/main.py
-
curl -L -o main.py https://huggingface.co/spaces/amadmateen/SentinelReview-AI/resolve/main/main.py
2.33 kB
| import sys | |
| import os | |
| import logging | |
| # Add the base directory to the Python path to make local package imports work cleanly | |
| sys.path.append(os.path.dirname(os.path.abspath(__file__))) | |
| from src.inference import get_or_load_resources, predict_review, generate_explanation | |
| # Configure minimal CLI logging | |
| logging.basicConfig(level=logging.WARNING, format='%(asctime)s [%(levelname)s] %(message)s') | |
| if __name__ == "__main__": | |
| print("=" * 70) | |
| print("SentinelReview AI - Review Authenticity Terminal Audit Utility") | |
| print("=" * 70) | |
| try: | |
| # Pre-warm resources | |
| print("\n[CLI Status] Loading local weights and preprocessors...") | |
| get_or_load_resources() | |
| print("[CLI Status] Initialization complete.\n") | |
| # User input text prompt | |
| print("Please enter the review text to analyze:") | |
| review_text = sys.stdin.read().strip() | |
| if not review_text: | |
| print("\n[CLI Error] Input review text cannot be empty.") | |
| sys.exit(1) | |
| print("\n" + "-" * 50) | |
| print("[CLI Audit] Executing multi-vector audit analysis...") | |
| print("-" * 50) | |
| # Perform prediction | |
| results = predict_review(review_text) | |
| # Fetch explanation | |
| explanation = generate_explanation(review_text, results['classification']) | |
| # Render clean, professional report | |
| print(f"\nAUDIT STATUS : {results['classification'].upper()}") | |
| print(f"CONFIDENCE LEVEL : {int(results['confidence'] * 100)}%") | |
| print(f"SENTIMENT METRIC : {results['metrics']['sentiment_score']} (VADER compound)") | |
| print(f"CHARACTER LENGTH : {results['metrics']['length']}") | |
| print(f"WORD COUNT : {results['metrics']['words_count']}") | |
| print(f"CAPITAL RATIO : {int(results['metrics']['capitalization_ratio'] * 100)}%") | |
| print(f"PUNCTUATION COUNT : {results['metrics']['punctuation_count']}") | |
| print("\nEXPLANATION ANALYSIS:") | |
| print(explanation) | |
| print("\n" + "=" * 70) | |
| except KeyboardInterrupt: | |
| print("\n[CLI Status] Execution interrupted by developer.") | |
| sys.exit(0) | |
| except Exception as e: | |
| print(f"\n[CLI Error] Critical execution crash: {e}") | |
| sys.exit(1) | |