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 attribution
  • RelationExtractor: typed relationship extraction (founded_by, located_in, and custom types)
  • TripletExtractor: direct (subject, predicate, object) triplet generation for RDF output
  • EventDetector: 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 Dependencies
Step 2: Set API Keys (for LLM methods only)
Step 3: First Extraction

Exported Classes

NamedEntityRecognizer is the high-level coordinator with confidence thresholding and overlap merging. NERExtractor is the lower-level implementation. For most use cases, start with NERExtractor for simplicity or NamedEntityRecognizer for fine-grained control.

Method Selection Guide

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

Semantic extraction pipeline: raw text fans into NER, Relation, and Coreference extractors, then merges into a Triplet Generator

Extractor Methods

NERExtractor

Output format:

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

Output format:
Available methods:
  • "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:
Triplets are suitable for loading directly into a triplet store or knowledge graph.

EventDetector

Detect events with participants and temporal context:
Output fields per event:
  • type: event category (e.g. "founding", "acquisition")
  • participants: list of entities with roles
  • temporal: date or time reference
  • location: 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:
Batch Input Options:

Using All Extractors Together

The standard extraction pipeline: entities → relationships → triplets:

Extraction Method Comparison