SPARC/main.py
0xWheatyz a91c3badab feat: implement company performance estimation orchestration
Created CompanyAnalyzer class that orchestrates the complete pipeline:
1. Retrieves patents via SERP API
2. Downloads and parses PDFs
3. Minimizes content (removes bloat)
4. Analyzes portfolio with LLM
5. Returns performance estimation

Features:
- Full company portfolio analysis
- Single patent analysis support
- Robust error handling (continues on partial failures)
- Progress logging for user visibility

Updated main.py with clean example usage demonstrating the high-level API.

Added comprehensive test suite (7 tests) covering:
- Full pipeline integration
- Error handling at each stage
- Single patent analysis
- Edge cases (no patents, all failures)

All 26 tests passing.

This completes the core functionality for patent-based company
performance estimation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-19 18:57:10 -05:00

44 lines
1.0 KiB
Python

"""SPARC - Semiconductor Patent & Analytics Report Core
Example usage of the company performance analyzer.
Before running:
1. Create a .env file with:
API_KEY=your_serpapi_key
ANTHROPIC_API_KEY=your_anthropic_key
2. Run: python main.py
"""
from SPARC.analyzer import CompanyAnalyzer
def main():
"""Analyze a company's performance based on their patent portfolio."""
# Initialize the analyzer (loads API keys from .env)
analyzer = CompanyAnalyzer()
# Analyze a company - this will:
# 1. Retrieve patents from SERP API
# 2. Download and parse patent PDFs
# 3. Minimize content (remove bloat)
# 4. Analyze with Claude to estimate performance
company_name = "nvidia"
print(f"\n{'=' * 70}")
print(f"SPARC Patent Analysis - {company_name.upper()}")
print(f"{'=' * 70}\n")
analysis = analyzer.analyze_company(company_name)
print(f"\n{'=' * 70}")
print("ANALYSIS RESULTS")
print(f"{'=' * 70}\n")
print(analysis)
print(f"\n{'=' * 70}\n")
if __name__ == "__main__":
main()