forked from 0xWheatyz/SPARC
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>
This commit is contained in:
@@ -1,10 +1,43 @@
|
||||
from SPARC.serp_api import SERP
|
||||
"""SPARC - Semiconductor Patent & Analytics Report Core
|
||||
|
||||
patents = SERP.query("nvidia")
|
||||
Example usage of the company performance analyzer.
|
||||
|
||||
for patent in patents.patents:
|
||||
patent = SERP.save_patents(patent)
|
||||
patent.summary = SERP.parse_patent_pdf(patent.pdf_path)
|
||||
print(patent.summary)
|
||||
Before running:
|
||||
1. Create a .env file with:
|
||||
API_KEY=your_serpapi_key
|
||||
ANTHROPIC_API_KEY=your_anthropic_key
|
||||
|
||||
print(patents)
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user