Nasty.Language.English.CoreferenceConfig (Nasty v0.3.0)
View SourceEnglish-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
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}
@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
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
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 textentity_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
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
@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