Nasty.Semantic.Coreference.Resolver (Nasty v0.3.0)
View SourceGeneric coreference resolution coordinator.
Orchestrates the complete resolution pipeline:
- Mention detection - Extract mentions from document
- Clustering - Build coreference chains
- Attachment - Attach chains to document
This module is language-agnostic and delegates language-specific operations to callbacks provided in the language configuration.
Summary
Functions
Resolves coreferences in a document.
Types
@type language_config() :: Nasty.Semantic.Coreference.MentionDetector.language_config()
Functions
@spec resolve(Nasty.AST.Document.t(), language_config(), keyword()) :: {:ok, Nasty.AST.Document.t()} | {:error, term()}
Resolves coreferences in a document.
This is the main entry point for coreference resolution. It extracts mentions, builds coreference chains, and returns the document with chains attached.
Parameters
document- Document AST to processlanguage_config- Language-specific configuration map with callbacks::pronoun?- Check if token is pronoun:classify_pronoun- Get pronoun gender/number:infer_gender- Infer gender from name/entity type:definite_determiner?- Check if determiner is definite:plural_marker?- Check if text is plural
opts- Resolution options:max_sentence_distance- Max sentence gap (default: 3):min_score- Min score for merging (default: 0.3):merge_strategy- Clustering linkage (default: :average):weights- Custom scoring weights
Returns
{:ok, document}- Document withcoref_chainsfield populated{:error, reason}- Resolution error
Examples
iex> config = %{
...> pronoun?: &EnglishConfig.pronoun?/1,
...> classify_pronoun: &EnglishConfig.classify_pronoun/1,
...> infer_gender: &EnglishConfig.infer_person_gender/2,
...> definite_determiner?: &EnglishConfig.definite_determiner?/1,
...> plural_marker?: &EnglishConfig.plural_marker?/1
...> }
iex> {:ok, resolved} = Resolver.resolve(document, config, [])
iex> resolved.coref_chains
[%CorefChain{...}, ...]