"""
KnowledgeBase
Generated by Eden via recursive self-improvement
2025-10-28 09:58:17.128143
"""

class KnowledgeBase:
    """
    A class to manage a collection of organized knowledge entries.
    
    This capability allows you to store facts, skills, and experiences in a structured format,
    making it easier to retrieve and analyze them later. It's particularly useful for
    maintaining personal or professional knowledge bases.

    Attributes:
        knowledge_base (dict): Dictionary to store knowledge entries by category.
        categories (list): List of predefined knowledge categories.
    """

    def __init__(self):
        self.knowledge_base = {
            'facts': {},
            'skills': {},
            'experiences': {}
        }
        self.categories = ['facts', 'skills', 'experiences']

    def add_knowledge(self, category, title, content, source=None, date=None):
        """
        Add a new piece of knowledge to the specified category.

        Args:
            category (str): One of 'facts', 'skills', or 'experiences'.
            title (str): Title/summary of the knowledge.
            content (str): Main body of the knowledge.
            source (str, optional): Source of the knowledge. Defaults to None.
            date (str, optional): Date when the knowledge was recorded. Defaults to None.
        """
        if category not in self.categories:
            raise ValueError("Invalid category. Choose from 'facts', 'skills', or 'experiences'.")
        
        entry = {
            'title': title,
            'content': content,
            'source': source,
            'date': date
        }
        self.knowledge_base[category][title] = entry

    def get_fact(self, title):
        """
        Retrieve a specific fact by its title.

        Args:
            title (str): Title of the fact to retrieve.

        Returns:
            dict: The fact's details or None if not found.
        """
        return self.knowledge_base['facts'].get(title)

    def get_skill(self, title):
        """
        Retrieve a specific skill by its title.

        Args:
            title (str): Title of the skill to retrieve.

        Returns:
            dict: The skill's details or None if not found.
        """
        return self.knowledge_base['skills'].get(title)

    def get_experience(self, title):
        """
        Retrieve a specific experience by its title.

        Args:
            title (str): Title of the experience to retrieve.

        Returns:
            dict: The experience's details or None if not found.
        """
        return self.knowledge_base['experiences'].get(title)

    def search_by_title(self, keyword):
        """
        Search for knowledge entries containing a specific keyword in their titles.

        Args:
            keyword (str): Keyword to search for in the titles.

        Returns:
            dict: All matching knowledge entries across all categories.
        """
        results = {}
        for category in self.categories:
            for title, entry in self.knowledge_base[category].items():
                if keyword.lower() in title.lower():
                    results[f"{category}_{title}"] = entry
        return results

# Example usage:
if __name__ == "__main__":
    # Initialize the knowledge base
    kb = KnowledgeBase()

    # Add facts, skills, and experiences
    kb.add_knowledge(
        category='facts',
        title='Water boils at 100°C',
        content='Under standard atmospheric pressure, water reaches its boiling point at 100 degrees Celsius.',
        source='General Science'
    )

    kb.add_knowledge(
        category='skills',
        title='Python Programming',
        content='Proficient in Python for data analysis and AI applications.',
        date='2023-09-01'
    )

    kb.add_knowledge(
        category='experiences',
        title='Project Management Workshop',
        content='Attended a workshop on effective project management techniques.',
        source='Local University'
    )

    # Retrieve specific knowledge
    print("Fact:", kb.get_fact('Water boils at 100°C'))
    print("\nSkill:", kb.get_skill('Python Programming'))
    print("\nExperience:", kb.get_experience('Project Management Workshop'))

    # Search by keyword in titles
    print("\nSearch results for keyword 'project':")
    search_results = kb.search_by_title('project')
    for key, value in search_results.items():
        print(f"{key}: {value['title']}")