import feedparser
from obsidian_tools import ObsidianClient

class CognitiveFeeder:
    def __init__(self):
        self.sources = {
            'arxiv': 'http://export.arxiv.org/rss/cs.AI',
            'nature': 'https://www.nature.com/nature.rss'
        }
        self.obsidian = ObsidianClient(vault_path="CognitiveOS")
        
    def process_feed(self):
        for name, url in self.sources.items():
            feed = feedparser.parse(url)
            for entry in feed.entries:
                content = f"""---
tags: [feed/{name}]
confidence: {self.calculate_confidence(entry)}
---

# {entry.title}

**核心论点提取**  
{self.extract_thesis(entry.summary)}

[[认知验证模板]]"""
                self.obsidian.create_note(
                    path=f"01_DataFeeds/{name}/{entry.id}.md",
                    content=content
                )
                
    def calculate_confidence(self, entry):
        # 暂时返回固定值，后续实现完整逻辑
        return 0.85
        
    @staticmethod
    def extract_thesis(text):
        # 占位函数，后续集成NLP处理
        return text[:200] + "..."

if __name__ == "__main__":
    feeder = CognitiveFeeder()
    feeder.process_feed()