Nasty.Semantic.CoreferenceResolution behaviour (Nasty v0.3.0)

View Source

Behaviour for language-agnostic coreference resolution.

Coreference resolution identifies when different expressions in text refer to the same entity (e.g., "Mary" and "she" referring to the same person).

Summary

Callbacks

Returns resolution algorithms supported by this implementation.

Resolves coreferences in a document.

Types

options()

@type options() :: keyword()

Callbacks

algorithms()

(optional)
@callback algorithms() :: [atom()]

Returns resolution algorithms supported by this implementation.

resolve(document, opts)

@callback resolve(document :: Nasty.AST.Document.t(), opts :: options()) ::
  {:ok, Nasty.AST.Document.t()} | {:error, term()}

Resolves coreferences in a document.

Identifies coreference chains linking mentions that refer to the same entity.

Parameters

  • document - Document AST to process
  • opts - Resolution options
    • :algorithm - Resolution algorithm (:rule_based, :statistical)
    • :max_distance - Maximum sentence distance for coreference

Returns

  • {:ok, document} - Document with coref_chains populated
  • {:error, reason} - Resolution error

Examples

iex> doc = parse("Mary loves her cat. She feeds it daily.")
iex> {:ok, resolved} = Resolver.resolve(doc)
iex> resolved.coref_chains
[
  %CorefChain{mentions: [mention1, mention2], entity_type: :person},
  %CorefChain{mentions: [mention3, mention4], entity_type: :animal}
]