action2.py
Action Pattern Processor Documentation
Overview
The ActionPatternProcessor
implements pattern discovery in tokenized data through co-occurrence analysis and custom scoring. It uses ReLU activation and normalized scoring to identify meaningful patterns without maintaining state between runs.
Table of Contents
Installation
Core Components
Pattern Discovery
Scoring System
Usage Examples
Installation
Dependencies
Core Components
ActionPatternProcessor Class
Constructor
Core Methods
process_tokens(tokens: List[str], cluster_type: str) -> Dict[str, Any]
Process token list for pattern discovery.
Input: List of tokens and their cluster type
Output: Dictionary containing patterns and metadata
Performance: O(n * w) where n is number of tokens, w is window size
batch_process(token_groups: Dict[str, List[str]]) -> Dict[str, Any]
Process multiple groups of tokens.
Input: Dictionary of cluster types to token lists
Output: Comprehensive analysis across clusters
Performance: O(m * n * w) where m is number of clusters
Pattern Discovery
Sliding Window Implementation
Frequency Calculation
Scoring System
Score Normalization
Pattern Scoring
Output Format
Pattern Analysis Result
Batch Processing Result
Usage Examples
Basic Usage
Custom Configuration
Performance Considerations
Memory Usage
Pattern storage: O(n * w) where n is number of tokens
Score matrices: O(p) where p is number of patterns
Temporary calculations: O(n)
Processing Speed
Sliding window operations: O(n * w)
Score normalization: O(p)
Batch processing: O(m * n * w)
Optimization Tips
Adjust window_size based on token characteristics
Use appropriate min_threshold to filter noise
Process tokens in batches for efficiency
Contributing
Guidelines for extending functionality:
Maintain stateless processing
Document edge cases
Follow existing naming conventions
Add unit tests
Last updated