Nasty.Language.English.CoreferenceConfig (Nasty v0.3.0)

View Source

English-specific configuration for coreference resolution.

Provides language-specific functions for:

  • Pronoun classification (gender, number)
  • Gender inference from names
  • Determiner classification
  • Plural markers

These functions are passed as callbacks to the generic coreference resolver.

Summary

Functions

Classifies a pronoun by gender and number.

Returns the complete language configuration map.

Checks if a determiner is definite.

Infers gender from a person's name or entity type.

Checks if a text indicates plural form.

Checks if a token is a pronoun.

Functions

classify_pronoun(text)

@spec classify_pronoun(String.t()) :: {atom(), atom()}

Classifies a pronoun by gender and number.

Returns a tuple of {gender, number} where:

  • Gender: :male, :female, :neutral, :plural, or :unknown
  • Number: :singular or :plural

Examples

iex> CoreferenceConfig.classify_pronoun("he")
{:male, :singular}

iex> CoreferenceConfig.classify_pronoun("they")
{:plural, :plural}

iex> CoreferenceConfig.classify_pronoun("it")
{:neutral, :singular}

config()

@spec config() :: map()

Returns the complete language configuration map.

This map contains all callback functions needed by the generic resolver.

Examples

iex> config = CoreferenceConfig.config()
iex> config.pronoun?.(%Token{text: "he", pos_tag: :pron})
true

definite_determiner?(text)

@spec definite_determiner?(String.t()) :: boolean()

Checks if a determiner is definite.

Definite determiners: the, this, that, these, those

Examples

iex> CoreferenceConfig.definite_determiner?("the")
true

iex> CoreferenceConfig.definite_determiner?("a")
false

infer_person_gender(text, entity_type)

@spec infer_person_gender(String.t(), atom()) :: atom()

Infers gender from a person's name or entity type.

This is a simple heuristic-based approach. A production system would use a name database or external service for better accuracy.

Parameters

  • text - The name or entity text
  • entity_type - The entity type (:person, :org, :gpe, etc.)

Returns

Gender atom: :male, :female, :neutral, or :unknown

Examples

iex> CoreferenceConfig.infer_person_gender("John Smith", :person)
:male

iex> CoreferenceConfig.infer_person_gender("Google", :org)
:neutral

plural_marker?(text)

@spec plural_marker?(String.t()) :: boolean()

Checks if a text indicates plural form.

Simple heuristic: words ending in 's' are likely plural. This is a basic check - a production system would use morphological analysis.

Examples

iex> CoreferenceConfig.plural_marker?("cats")
true

iex> CoreferenceConfig.plural_marker?("cat")
false

pronoun?(token)

@spec pronoun?(Nasty.AST.Token.t()) :: boolean()

Checks if a token is a pronoun.

Returns true for personal, possessive, and reflexive pronouns.

Examples

iex> token = %Token{text: "he", pos_tag: :pron}
iex> CoreferenceConfig.pronoun?(token)
true

iex> token = %Token{text: "cat", pos_tag: :noun}
iex> CoreferenceConfig.pronoun?(token)
false