Extractors¶
Extractors are responsible for identifying and creating facts from source content.
Available Extractors¶
- ManualExtractor - API-driven fact creation
- LLMExtractor - AI-powered extraction
- RuleBasedExtractor - Pattern matching
Base Class¶
All extractors inherit from FactDb::Extractors::Base:
class Base
attr_reader :config
def initialize(config = FactDb.config)
@config = config
end
def extract(content)
raise NotImplementedError
end
def extraction_method
self.class.name.split("::").last.sub("Extractor", "").underscore
end
end
Creating Custom Extractors¶
class MyExtractor < FactDb::Extractors::Base
def extract(source)
facts = []
# Your extraction logic
# Parse source.content
# Create fact records
facts
end
end
Using Extractors¶
Via FactDb¶
Directly¶
Extractor Selection¶
| Extractor | Best For | Accuracy | Speed |
|---|---|---|---|
| Manual | High-stakes facts | Highest | Slowest |
| LLM | Complex documents | High | Medium |
| Rule-based | Structured content | Medium | Fastest |