action.py
Action Processor Documentation
Overview
The ActionProcessor module provides semantic analysis and action inference capabilities using natural language processing and neural network concepts. It determines the probability of text representing an action through contextual understanding rather than simple classification.
Table of Contents
Installation
Core Components
Implementation Details
Usage Guide
API Reference
Performance Considerations
Examples
Installation
Requirements
Dependencies
Core Components
1. Semantic Analysis
SpaCy-based linguistic processing
Verb pattern recognition
Object relationship mapping
Contextual relevance scoring
2. Neural Processing
ReLU activation function
Feature weight management
Probability normalization
Confidence scoring
3. Feature Engineering
Implementation Details
Feature Extraction
Processing Pipeline
Text Input → Spacy Processing
Feature Extraction → Weight Application
ReLU Activation → Probability Calculation
Semantic Analysis → Result Generation
Output Structure
Usage Guide
Basic Usage
Weight Adjustment
API Reference
ActionProcessor Class
Constructor
Initializes processor with default weights and loads SpaCy model.
Core Methods
process_text(text: str) → Dict[str, Any]
Processes single text input.
Input: Text string
Output: Complete analysis dictionary
Performance: O(n) where n is text length
batch_process(texts: List[str]) → List[Dict[str, Any]]
Processes multiple texts.
Input: List of text strings
Output: List of analysis dictionaries
Performance: O(n*m) where n is number of texts
update_weights(training_data: List[Tuple[str, bool]]) → None
Updates feature weights based on training examples.
Input: List of (text, is_action) pairs
Effect: Modifies internal weights
Learning Rate: 0.1
Performance Considerations
Memory Usage
SpaCy model loading (~100MB)
Batch processing memory scaling
Feature vector size
Processing Speed
Single text: ~10ms
Batch processing: Linear scaling
Weight updates: O(n) for n training examples
Optimization Tips
Batch process when possible
Reuse processor instance
Limit text length if needed
Monitor memory usage
Examples
Detailed Analysis
Batch Processing
Best Practices
Text Preparation
Clean input text
Remove unnecessary whitespace
Handle special characters
Normalize case if needed
Processing
Use batch processing for multiple texts
Monitor confidence scores
Validate results
Handle edge cases
Weight Management
Start with default weights
Use representative training data
Monitor weight changes
Validate after updates
Contributing
Guidelines for extending functionality:
Maintain semantic focus
Document feature additions
Follow typing conventions
Add test cases
Last updated