names ¶
Broad named-span extraction for the GKG all-names field.
NameResult dataclass ¶
Named spans for an input body, including the recognizer's identity.
Attributes:
| Name | Type | Description |
|---|---|---|
text | str | Analyzed body. |
mentions | tuple[NameMention, ...] | Broad name spans with source offsets and labels. |
backend_name | str | Recognizer identity. |
to_gkg ¶
Serialize names and offsets, or an empty string for no matches.
analyze_names ¶
analyze_names(text: str, *, recognizer: EntityRecognizer | None = None, ner: NERResult | None = None) -> NameResult
Collect broad named spans from a recognizer or precomputed NER result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text | str | Prepared body. | required |
recognizer | EntityRecognizer | None | Entity recognizer. Defaults to the installed English model. | None |
ner | NERResult | None | Precomputed NER for this exact body; supply it instead of | None |
Returns:
| Type | Description |
|---|---|
NameResult | Name spans and the recognizer identity, preserving source coordinates. |
Raises:
| Type | Description |
|---|---|
TypeError | If |
ValueError | If both NER inputs are supplied or the result describes another body. |
NERUnavailableError | If the default model is unavailable. |
OptionalDependencyError | If the default recognizer's dependency is unavailable. |