semantica.semantic_extract extracts structured information from unstructured text: the foundation of every knowledge graph in Semantica:
NERExtractor: named entity recognition with confidence scores and source attributionRelationExtractor: typed relationship extraction (founded_by,located_in, and custom types)TripletExtractor: direct(subject, predicate, object)triplet generation for RDF outputEventDetector: event detection with participants, temporal context, and confidence- Three extraction modes on every extractor:
"pattern"(no API key),"huggingface","llm"
Getting Started
Prerequisites & Setup
Step 1: Install DependenciesExported Classes
Method Selection Guide
- Pattern: No Setup
- HuggingFace: Custom Models
- LLM: Best Accuracy
- Fallback Chain
Zero dependencies, no API key required. Uses spaCy rules and regex to match standard entity types.
Method Availability by Extractor
Method Fallback Chains
For reliability, extractors support fallback chains that try methods in order until one succeeds:Quick Start
Extractor Methods
NERExtractor
Custom Entity Types
v0.5.0 fix:
NERExtractor(method="llm") no longer silently falls back to pattern extraction on custom gateways. The response_format=json_object parameter is now conditionally omitted for incompatible gateways, with a plain generate() + JSON parsing fallback applied automatically.RelationExtractor
"pattern": rule-based pattern matching"dependency": spaCy dependency parsing"cooccurrence": proximity-based co-occurrence"huggingface": custom models"llm": highest accuracy, requires API key
TripletExtractor
Generate RDF-ready(subject, predicate, object) triplets directly from text:
EventDetector
Detect events with participants and temporal context:type: event category (e.g."founding","acquisition")participants: list of entities with rolestemporal: date or time referencelocation: location entity (when present)confidence: extraction confidence score
CoreferenceResolver
Resolve pronoun and alias references to canonical entities before extraction:Batch Processing
All extractors automatically detect batch input and process multiple texts efficiently:Using All Extractors Together
The standard extraction pipeline: entities → relationships → triplets:Extraction Method Comparison
- LLM Providers — Configure which LLM is used for extraction.
- Knowledge Graph — Build graphs from extracted entities and relationships.
- Parse Module — Parse documents before extraction.
- Deduplication — Resolve duplicate entities after extraction.
