Skip to content

CLI Demo

Nick edited this page Mar 10, 2026 · 1 revision

PATAS CLI Demo - Educational Toy Version

⚠️ WARNING: This is a HEAVILY SIMPLIFIED educational demo.

The PATAS CLI Demo is a standalone Python package that demonstrates the basic concept of PATAS: logs → patterns → rules. It is designed for developers who want to understand how PATAS works without setting up the full system.

What This Demo Includes

  • ✅ Simple pattern detection (grouping by domains, phone numbers)
  • ✅ Basic rule generation (SQL-like examples)
  • ✅ Interactive CLI interface
  • ✅ Bundled demo data

What This Demo Does NOT Include

  • ❌ Advanced pattern mining algorithms
  • ❌ Rule lifecycle management (candidate → shadow → active → deprecated)
  • ❌ SQL safety checks and validation
  • ❌ Semantic analysis and embeddings
  • ❌ Production-grade evaluation metrics
  • ❌ Real-time processing
  • ❌ Integration with external systems

This is NOT the real PATAS Core. Do NOT use in production.

Installation

From GitHub Release (Recommended)

  1. Go to Releases
  2. Download patas_demo_cli-0.1.0-py3-none-any.whl from the latest release
  3. Install:
    pip install patas_demo_cli-0.1.0-py3-none-any.whl

From Git

pip install git+https://github.com/KikuAI-Lab/PATAS.git#subdirectory=apps/demo-cli

Development Installation

cd apps/demo-cli
pip install -e .

Usage

Show Demo Information

patas-demo demo

This command prints:

  • Description of what the demo does
  • Location of demo data
  • Available commands

Analyze Messages

Analyze the bundled demo data:

patas-demo analyze

Analyze your own JSON file:

patas-demo analyze --input path/to/messages.json

Export rules as SQL:

patas-demo analyze --export-sql

Input Format

The demo expects a JSON file with an array of message objects:

[
  {
    "id": "msg_1",
    "text": "Buy now! Visit http://spam.com",
    "is_spam": true,
    "timestamp": "2025-01-15T10:00:00Z"
  },
  {
    "id": "msg_2",
    "text": "Hello, how are you?",
    "is_spam": false,
    "timestamp": "2025-01-15T10:05:00Z"
  }
]

Example Output

============================================================
PATAS Demo - Pattern Analysis
============================================================

Loaded 15 messages
  - Spam: 9
  - Ham: 6

Discovering patterns...
Found 3 patterns

============================================================
Discovered Patterns
============================================================

Pattern 1: pattern_1
  Type: domain
  Description: Messages containing domain: spam-shop.com
  Messages matched: 4

  Example messages:
    - Buy now! Visit http://spam-shop.com for amazing deals!
    - Check out http://spam-shop.com - limited time offer!

How It Works (Simplified)

The demo uses very basic pattern detection:

  1. Domain Extraction: Finds URLs in messages and groups by domain
  2. Phone Number Extraction: Finds phone numbers and groups by number
  3. Simple Grouping: Messages with the same domain/phone are grouped together
  4. Rule Generation: Creates simple SQL-like rules for each pattern

This is NOT how the real PATAS Core works. The real PATAS uses:

  • Advanced semantic pattern mining
  • Rule lifecycle with shadow evaluation
  • SQL safety validation
  • Production-grade metrics

Comparison: Demo vs Real PATAS

Feature CLI Demo Real PATAS Core
Pattern Detection Simple regex grouping Advanced semantic mining
Rule Generation Basic SQL templates Validated SQL with safety checks
Rule Lifecycle None candidate → shadow → active → deprecated
Evaluation None Precision, recall, coverage, ham rate
SQL Safety None Full validation and sanitization
Semantic Analysis None Embeddings and similarity clustering
Production Ready ❌ No ✅ Yes

Important Notes

  1. This is a toy implementation - it uses simple regex-based grouping, not real pattern mining.

  2. Do NOT use in production - this demo is for educational purposes only.

  3. The real PATAS Core includes:

    • Advanced semantic pattern mining
    • Rule lifecycle with shadow evaluation
    • SQL safety validation
    • Production-grade metrics and monitoring
    • Integration capabilities
  4. For production use, see:

Resources

Next Steps

After trying the CLI demo:

  1. Explore the API: See API Quickstart for real PATAS integration
  2. Understand Architecture: Read Architecture Full to see how real PATAS works
  3. Production Integration: Follow Integration Guide for real deployments

Remember: The CLI demo is just a simplified illustration. For real spam detection, use the full PATAS Core via API.

Clone this wiki locally