Entity Post-Processing
When an NLP pipeline extracts an entity from a document, you can attach a post-processing script that runs immediately after extraction. The script can inspect the matched text and its surrounding document, then decide to accept the entity as-is, override its resolved node UID or display value, or discard it entirely.
This is useful for:
- Disambiguating entities that map to multiple nodes (e.g. choosing the correct product version).
- Normalizing extracted values before they are stored (e.g. uppercasing identifiers).
- Suppressing low-confidence or irrelevant matches based on document context.
Execution Scope
Post-processing code runs inside an EntityPostProcessingScope.
| Property / Method | Type | Description |
|---|---|---|
Graph |
Mosaik.GraphDB.Safe.Graph |
Thread-safe access to the full graph for lookups during processing. |
Query() / Q() |
IQuery |
Creates a new graph query scoped to this execution. |
CancellationToken |
CancellationToken |
Cancellation token. |
DocumentUID |
UID128 |
The UID of the source document being parsed. |
NodeUID |
UID128 |
The UID of the entity node that was resolved from the extracted text. |
Document |
Document |
The full NLP Document object, providing access to sentences, tokens, and spans. |
Tokens |
ITokens |
The token span that matched the entity, for inspecting the raw extracted text. |
Logger |
ILogger |
Logger for diagnostics. |
OverrideUID(uid) |
void |
Replace the resolved node UID with a different one (e.g. after a graph lookup). |
OverrideValue(newValue) |
void |
Replace the extracted string value before it is stored. |
Ignore() |
void |
Discard this entity — it will not be linked to the document. |
Examples
Suppress short or noisy matches
// Discard any match shorter than 3 characters
if (Tokens.Value.Length < 3)
{
Ignore();
return;
}
Resolve ambiguous entities via a graph lookup
// If the extracted text exactly matches a known alias, redirect to the canonical node
var canonical = Q()
.StartFrom(N.Product.Type)
.Where(N.Product.Alias, Tokens.Value)
.GetFirst();
if (canonical is not null)
{
OverrideUID(canonical.UID);
}
else
{
Ignore();
}
Normalize an extracted identifier
// Store ticket IDs in uppercase
OverrideValue(Tokens.Value.ToUpperInvariant());
Next Steps
- Learn how to configure NLP pipelines: NLP Pipelines
- Understand entity linking options: Entity Linking