Nasty.Semantic.SRL.PredicateDetector (Nasty v0.3.0)

View Source

Generic predicate (main verb) detection and voice identification for Semantic Role Labeling.

This module provides language-agnostic algorithms for:

  • Identifying predicates in clauses
  • Detecting voice (active vs passive)

Language-specific patterns are provided via configuration callbacks.

Summary

Types

Language configuration for predicate detection.

Functions

Detects voice (active vs passive) of the predicate.

Identifies main predicates (verbs) in a predicate phrase.

Types

language_config()

@type language_config() :: %{
  passive_auxiliary?: (Nasty.AST.Token.t() -> boolean()),
  passive_participle?: (Nasty.AST.Token.t() -> boolean())
}

Language configuration for predicate detection.

Required callbacks:

  • passive_auxiliary?/1 - Check if token is a passive auxiliary (e.g., "was", "were", "be")
  • passive_participle?/1 - Check if token is a passive participle form

Functions

detect_voice(predicate, verb_phrase, config)

@spec detect_voice(
  Nasty.AST.Token.t(),
  Nasty.AST.VerbPhrase.t() | nil,
  language_config()
) ::
  :active | :passive | :unknown

Detects voice (active vs passive) of the predicate.

Uses language configuration to identify passive constructions:

  • Passive auxiliary (be, was, were) + past participle
  • Returns :active, :passive, or :unknown

identify_predicates(arg1)

@spec identify_predicates(Nasty.AST.VerbPhrase.t() | nil) :: [Nasty.AST.Token.t()]

Identifies main predicates (verbs) in a predicate phrase.

Returns a list of predicate tokens. For most clauses, this is a single main verb.