Bahn: aisupport, Analyse-O2C-C2S, awesome-bahn-mcp-servers, beam-mcp,
Confluence_Bot, db-planet-mcp-server, O2C-Harness, project-audit,
Projekt-KIQ-HP, teamlandkarte-mcp
Dhive: Jury-Voting
Privat: CV, NoteGraph (NOTE: NoteGraph needs complete redo after consolidation)
Shared: AI-Orchestrator, OrgMyLife, power_skills_and_more
Shared/references: symphony (read-only)
Bahn repos remain available as independent remotes - this monorepo
pulls them in via subtree, the originals are untouched.
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
"""Text extraction layer for various document formats."""
|
|
|
|
from pathlib import Path
|
|
|
|
from .base import ExtractionResult, TextExtractor
|
|
from .docx import DocxExtractor
|
|
from .ocr import OCRExtractor
|
|
from .pdf import PDFExtractor
|
|
from .text import PlainTextExtractor
|
|
|
|
|
|
def get_extractor(file_path: Path, config=None):
|
|
"""Get the appropriate extractor for a file.
|
|
|
|
Args:
|
|
file_path: Path to the file to extract.
|
|
config: Optional IngestionConfig for LLM-based extraction.
|
|
|
|
Returns:
|
|
An extractor instance that can handle the file, or None.
|
|
"""
|
|
suffix = file_path.suffix.lower()
|
|
|
|
if suffix in (".md", ".txt"):
|
|
return PlainTextExtractor()
|
|
elif suffix == ".pdf":
|
|
if config:
|
|
return PDFExtractor(
|
|
ocr_enabled=config.ocr_enabled,
|
|
ocr_language=config.ocr_language,
|
|
llm_provider=config.llm_provider,
|
|
llm_model=config.llm_model,
|
|
mistral_api_key=config.mistral_api_key,
|
|
)
|
|
return PDFExtractor()
|
|
elif suffix in (".jpg", ".jpeg", ".png"):
|
|
return OCRExtractor()
|
|
elif suffix == ".docx":
|
|
return DocxExtractor()
|
|
return None
|
|
|
|
|
|
__all__ = [
|
|
"ExtractionResult",
|
|
"TextExtractor",
|
|
"PlainTextExtractor",
|
|
"PDFExtractor",
|
|
"OCRExtractor",
|
|
"DocxExtractor",
|
|
"get_extractor",
|
|
]
|