feat: add multi-company batch processing
- Add CompanyAnalysisResult and BatchAnalysisResult dataclasses - Implement analyze_companies() for concurrent batch analysis - Implement analyze_companies_sequential() for rate-limited scenarios - Add progress callback support for monitoring batch jobs - Include 5 new tests for batch processing functionality - Fix pre-existing test mock issue in test_llm.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,8 @@ SPARC automatically collects, parses, and analyzes patents from companies to pro
|
||||
- **Content Minimization**: Removes verbose descriptions to reduce LLM token usage
|
||||
- **AI Analysis**: Uses Claude 3.5 Sonnet via OpenRouter to analyze innovation quality and market potential
|
||||
- **Portfolio Analysis**: Evaluates multiple patents holistically for comprehensive insights
|
||||
- **Robust Testing**: 26 tests covering all major functionality
|
||||
- **Batch Processing**: Analyze multiple companies concurrently with progress tracking
|
||||
- **Robust Testing**: 31 tests covering all major functionality
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -99,6 +100,33 @@ result = analyzer.analyze_single_patent(
|
||||
)
|
||||
```
|
||||
|
||||
### Multi-Company Batch Analysis
|
||||
|
||||
```python
|
||||
from SPARC.analyzer import CompanyAnalyzer
|
||||
|
||||
analyzer = CompanyAnalyzer()
|
||||
|
||||
# Analyze multiple companies concurrently (default 3 workers)
|
||||
batch_result = analyzer.analyze_companies(
|
||||
["nvidia", "amd", "intel", "qualcomm"],
|
||||
max_workers=3
|
||||
)
|
||||
|
||||
# Access results
|
||||
print(f"Analyzed: {batch_result.total_companies}")
|
||||
print(f"Successful: {batch_result.successful}")
|
||||
print(f"Failed: {batch_result.failed}")
|
||||
|
||||
for result in batch_result.results:
|
||||
if result.success:
|
||||
print(f"{result.company_name}: {result.patent_count} patents")
|
||||
print(result.analysis)
|
||||
|
||||
# Or use sequential processing (safer for rate limits)
|
||||
batch_result = analyzer.analyze_companies_sequential(["nvidia", "amd"])
|
||||
```
|
||||
|
||||
## Running Tests
|
||||
|
||||
```bash
|
||||
@@ -130,7 +158,7 @@ pytest tests/ --cov=SPARC --cov-report=term-missing
|
||||
- [X] Extract and minimize patent content
|
||||
- [X] LLM integration for analysis
|
||||
- [X] Company performance estimation
|
||||
- [ ] Multi-company batch processing
|
||||
- [X] Multi-company batch processing
|
||||
- [ ] FastAPI web service wrapper
|
||||
- [X] Docker containerization
|
||||
- [X] Results persistence (database)
|
||||
|
||||
Reference in New Issue
Block a user