glazing.verbnet.models¶
VerbNet core data models.
models
¶
VerbNet core data models.
This module implements VerbNet verb classes, members, thematic roles, selectional restrictions, and frame models with support for role inheritance hierarchies.
| CLASS | DESCRIPTION |
|---|---|
SelectionalRestriction |
Single selectional restriction on a thematic role. |
SelectionalRestrictions |
Container for selectional restrictions with logical operators. |
ThematicRole |
Thematic role with selectional restrictions. |
WordNetCrossRef |
Cross-reference to WordNet from VerbNet. |
VerbNetFrameNetRoleMapping |
Role-level mapping between VerbNet and FrameNet. |
VerbNetFrameNetMapping |
VerbNet to FrameNet mapping with confidence. |
MappingMetadata |
Metadata for cross-dataset mappings. |
Member |
VerbNet member with cross-references. |
VerbClass |
A VerbNet verb class with members and frames. |
VNFrame |
Syntactic-semantic frame pattern. |
FrameDescription |
Frame syntactic pattern description. |
Example |
Frame example sentence. |
Syntax |
Syntactic structure of a frame. |
SyntaxElement |
Element in syntactic structure. |
SyntacticRestriction |
Syntactic restriction on an element. |
Semantics |
Semantic representation of a frame. |
Predicate |
Semantic predicate in frame representation. |
PredicateArgument |
Argument to a semantic predicate. |
Examples:
>>> from glazing.verbnet.models import VerbClass, Member, ThematicRole
>>> verb_class = VerbClass(
... id="give-13.1",
... members=[],
... themroles=[],
... frames=[],
... subclasses=[]
... )
>>> print(verb_class.id)
'give-13.1'
Classes¶
Example
pydantic-model
¶
Bases: GlazingBaseModel
Frame example sentence.
| ATTRIBUTE | DESCRIPTION |
|---|---|
text |
The example sentence text.
TYPE:
|
Examples:
Fields:
-
text(str)
FrameDescription
pydantic-model
¶
Bases: GlazingBaseModel
Frame syntactic pattern description.
| ATTRIBUTE | DESCRIPTION |
|---|---|
description_number |
The description number (e.g., "0.2", "2.5.1").
TYPE:
|
primary |
Raw primary pattern string.
TYPE:
|
secondary |
Raw secondary pattern string.
TYPE:
|
xtag |
XTag reference (usually empty, sometimes "0.1", "0.2", or preposition patterns).
TYPE:
|
primary_elements |
Computed list of primary pattern elements.
TYPE:
|
secondary_patterns |
Computed list of secondary patterns.
TYPE:
|
Examples:
>>> desc = FrameDescription(
... description_number="0.2",
... primary="NP V NP",
... secondary="Basic Transitive"
... )
Fields:
-
description_number(DescriptionNumber) -
primary(str) -
secondary(str) -
xtag(str) -
primary_elements(list[str]) -
secondary_patterns(list[str])
Validators:
-
validate_description_number→description_number -
validate_xtag→xtag
Functions¶
model_post_init(_: dict[str, str | int | float | bool] | None) -> None
¶
Parse primary and secondary patterns after initialization.
Source code in src/glazing/verbnet/models.py
validate_description_number(v: str) -> DescriptionNumber
pydantic-validator
¶
Validate description number format.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Description number to validate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Validated description number. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If description number format is invalid. |
Source code in src/glazing/verbnet/models.py
validate_xtag(v: str) -> str
pydantic-validator
¶
Validate xtag format.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
XTag value to validate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Validated xtag value. |
Source code in src/glazing/verbnet/models.py
Member
pydantic-model
¶
Bases: GlazingBaseModel
VerbNet member with cross-references.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Lemma form (validated).
TYPE:
|
verbnet_key |
Unique identifier with sense.
TYPE:
|
framenet_mappings |
FrameNet mappings with confidence.
TYPE:
|
propbank_mappings |
PropBank roleset mappings.
TYPE:
|
wordnet_mappings |
WordNet sense mappings.
TYPE:
|
features |
Semantic features.
TYPE:
|
mapping_metadata |
Metadata about mappings.
TYPE:
|
inherited_from_class |
If inherited from parent class.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
get_primary_framenet_frame |
Get highest confidence FrameNet frame. |
get_all_framenet_frames |
Get all FrameNet frames with confidence scores. |
get_wordnet_senses |
Get WordNet senses in percentage notation. |
get_propbank_rolesets |
Get PropBank roleset IDs. |
has_mapping_conflicts |
Check if there are conflicting high-confidence mappings. |
Examples:
>>> member = Member(
... name="give",
... verbnet_key="give#2",
... framenet_mappings=[],
... propbank_mappings=[],
... wordnet_mappings=[]
... )
>>> print(member.verbnet_key)
'give#2'
Fields:
-
name(str) -
verbnet_key(VerbNetKey) -
framenet_mappings(list[VerbNetFrameNetMapping]) -
propbank_mappings(list[CrossReference]) -
wordnet_mappings(list[WordNetCrossRef]) -
features(dict[str, str]) -
mapping_metadata(MappingMetadata | None) -
inherited_from_class(VerbClassID | None)
Validators:
Attributes¶
features: dict[str, str]
pydantic-field
¶
Semantic features
framenet_mappings: list[VerbNetFrameNetMapping]
pydantic-field
¶
FrameNet mappings with confidence
name: str
pydantic-field
¶
Lemma form
propbank_mappings: list[CrossReference]
pydantic-field
¶
PropBank roleset mappings
verbnet_key: VerbNetKey
pydantic-field
¶
Unique identifier with sense
wordnet_mappings: list[WordNetCrossRef]
pydantic-field
¶
WordNet sense mappings
Functions¶
get_all_framenet_frames() -> list[tuple[str, float | None]]
¶
Get all FrameNet frames with confidence scores.
| RETURNS | DESCRIPTION |
|---|---|
list[tuple[str, float | None]]
|
List of (frame_name, confidence_score) tuples. |
Source code in src/glazing/verbnet/models.py
get_primary_framenet_frame() -> str | None
¶
Get highest confidence FrameNet frame.
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
Frame name or None if no mappings. |
Source code in src/glazing/verbnet/models.py
get_propbank_rolesets() -> list[str]
¶
Get PropBank roleset IDs.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
List of PropBank roleset IDs. |
Source code in src/glazing/verbnet/models.py
get_wordnet_senses() -> list[str]
¶
Get WordNet senses in percentage notation.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
List of percentage notation strings. |
Source code in src/glazing/verbnet/models.py
has_mapping_conflicts() -> bool
¶
Check if there are conflicting high-confidence mappings.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if multiple high-confidence FrameNet mappings exist. |
Source code in src/glazing/verbnet/models.py
validate_member_name(v: str) -> str
pydantic-validator
¶
Validate member name (verb lemma).
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Member name to validate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Validated member name. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If member name format is invalid. |
Source code in src/glazing/verbnet/models.py
validate_verbnet_key(v: str) -> VerbNetKey
pydantic-validator
¶
Validate verbnet_key format.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
VerbNet key to validate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Validated VerbNet key. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If VerbNet key format is invalid. |
Source code in src/glazing/verbnet/models.py
Predicate
pydantic-model
¶
Bases: GlazingBaseModel
Semantic predicate in frame representation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
value |
The predicate type (e.g., "motion", "cause", "transfer").
TYPE:
|
args |
Arguments to the predicate.
TYPE:
|
negated |
Whether the predicate is negated (represents bool="!").
TYPE:
|
Examples:
>>> pred = Predicate(
... value="motion",
... args=[
... PredicateArgument(type="Event", value="e1"),
... PredicateArgument(type="ThemRole", value="Agent")
... ]
... )
Fields:
-
value(PredicateType) -
args(list[PredicateArgument]) -
negated(bool)
Validators:
-
parse_bool_attr→negated
Functions¶
parse_bool_attr(v: str | bool | int | None) -> bool
pydantic-validator
¶
Parse XML bool attribute.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Value to parse.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if value is "!", False otherwise. |
Source code in src/glazing/verbnet/models.py
PredicateArgument
pydantic-model
¶
Bases: GlazingBaseModel
Argument to a semantic predicate.
| ATTRIBUTE | DESCRIPTION |
|---|---|
type |
Type of argument (Event, ThemRole, etc.).
TYPE:
|
value |
Argument value (e.g., "e1", "Agent", "?Theme").
TYPE:
|
Examples:
>>> arg = PredicateArgument(type="ThemRole", value="Agent")
>>> event_arg = PredicateArgument(type="Event", value="e1")
Fields:
-
type(ArgumentType) -
value(str)
Validators:
-
validate_arg_value→value
Functions¶
validate_arg_value(v: str, info: ValidationInfo) -> str
pydantic-validator
¶
Validate argument values based on type.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Value to validate.
TYPE:
|
info
|
Validation context.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Validated value. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If event variable format is invalid. |
Source code in src/glazing/verbnet/models.py
SelectionalRestriction
pydantic-model
¶
Bases: GlazingBaseModel
Single selectional restriction.
| ATTRIBUTE | DESCRIPTION |
|---|---|
value |
Restriction polarity ("+" or "-").
TYPE:
|
type |
Type of selectional restriction (e.g., "animate", "concrete").
TYPE:
|
Examples:
>>> restriction = SelectionalRestriction(value="+", type="animate")
>>> print(restriction.type)
'animate'
Fields:
-
value(RestrictionValue) -
type(SelectionalRestrictionType)
SelectionalRestrictions
pydantic-model
¶
Bases: GlazingBaseModel
Container for selectional restrictions with logic.
| ATTRIBUTE | DESCRIPTION |
|---|---|
logic |
Logical operator ("or", "and", or None for implicit AND).
TYPE:
|
restrictions |
List of restrictions or nested restriction groups.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
is_complex |
Check if this contains nested restrictions. |
Examples:
>>> restrictions = SelectionalRestrictions(
... logic="or",
... restrictions=[
... SelectionalRestriction(value="+", type="animate"),
... SelectionalRestriction(value="+", type="human")
... ]
... )
>>> print(restrictions.is_complex())
False
Fields:
-
logic(LogicType | None) -
restrictions(list[SelectionalRestriction | SelectionalRestrictions])
Attributes¶
logic: LogicType | None = None
pydantic-field
¶
Logical operator for combining restrictions
restrictions: list[SelectionalRestriction | SelectionalRestrictions]
pydantic-field
¶
List of restrictions or nested groups
Functions¶
check_contradiction() -> bool
¶
Check if restrictions contain contradictions.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if contradictions are found (e.g., +animate and -animate). |
Source code in src/glazing/verbnet/models.py
flatten_restrictions() -> list[SelectionalRestriction]
¶
Flatten nested restrictions into a single list.
| RETURNS | DESCRIPTION |
|---|---|
list[SelectionalRestriction]
|
Flattened list of all restrictions. |
Source code in src/glazing/verbnet/models.py
is_complex() -> bool
¶
Check if this contains nested restrictions.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if any restriction is a SelectionalRestrictions object. |
Source code in src/glazing/verbnet/models.py
validate_logic_consistency() -> bool
¶
Validate that logic operators are used consistently.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if logic is consistent throughout the structure. |
Source code in src/glazing/verbnet/models.py
Semantics
pydantic-model
¶
Bases: GlazingBaseModel
Semantic representation of a frame.
| ATTRIBUTE | DESCRIPTION |
|---|---|
predicates |
List of semantic predicates.
TYPE:
|
Examples:
>>> semantics = Semantics(predicates=[
... Predicate(
... value="motion",
... args=[PredicateArgument(type="Event", value="e1")]
... )
... ])
Fields:
-
predicates(list[Predicate])
SyntacticRestriction
pydantic-model
¶
Bases: GlazingBaseModel
Syntactic restriction on an element.
| ATTRIBUTE | DESCRIPTION |
|---|---|
type |
The type of syntactic restriction.
TYPE:
|
value |
The restriction value ("+" or "-").
TYPE:
|
Examples:
Fields:
-
type(SyntacticRestrictionType) -
value(RestrictionValue)
Syntax
pydantic-model
¶
Bases: GlazingBaseModel
Syntactic structure of a frame.
| ATTRIBUTE | DESCRIPTION |
|---|---|
elements |
List of syntactic elements in order.
TYPE:
|
Examples:
>>> syntax = Syntax(elements=[
... SyntaxElement(pos="NP", value="Agent"),
... SyntaxElement(pos="VERB"),
... SyntaxElement(pos="NP", value="Theme")
... ])
Fields:
-
elements(list[SyntaxElement])
SyntaxElement
pydantic-model
¶
Bases: GlazingBaseModel
Element in syntactic structure.
| ATTRIBUTE | DESCRIPTION |
|---|---|
pos |
Part of speech (NP, VERB, PREP, ADV, ADJ, LEX, ADVP, S, SBAR).
TYPE:
|
value |
Role name or specific preposition values.
TYPE:
|
synrestrs |
Syntactic restrictions on this element.
TYPE:
|
selrestrs |
Selectional restrictions (for PREP).
TYPE:
|
Examples:
>>> element = SyntaxElement(
... pos="NP",
... value="Agent"
... )
>>> prep_element = SyntaxElement(
... pos="PREP",
... value="to for at"
... )
Fields:
-
pos(SyntacticPOS) -
value(str | None) -
synrestrs(list[SyntacticRestriction]) -
selrestrs(list[SelectionalRestriction])
Validators:
-
validate_prep_value→value
Functions¶
validate_prep_value(v: str | None, info: ValidationInfo) -> str | None
pydantic-validator
¶
Validate preposition values.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Value to validate.
TYPE:
|
info
|
Validation context.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
Validated value. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If preposition value format is invalid. |
Source code in src/glazing/verbnet/models.py
ThematicRole
pydantic-model
¶
Bases: GlazingBaseModel
Thematic role with selectional restrictions.
| ATTRIBUTE | DESCRIPTION |
|---|---|
type |
Type of thematic role (e.g., "Agent", "Theme", "Patient").
TYPE:
|
sel_restrictions |
Selectional restrictions on this role.
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
_class_id |
The class ID this role belongs to (set during parsing).
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
class_id |
Get the class ID this role belongs to. |
Examples:
>>> role = ThematicRole(
... type="Agent",
... sel_restrictions=SelectionalRestrictions(
... restrictions=[SelectionalRestriction(value="+", type="animate")]
... )
... )
>>> print(role.type)
'Agent'
Fields:
-
type(ThematicRoleType) -
sel_restrictions(SelectionalRestrictions | None)
VNFrame
pydantic-model
¶
Bases: GlazingBaseModel
Syntactic-semantic frame pattern.
| ATTRIBUTE | DESCRIPTION |
|---|---|
description |
Frame syntactic pattern description.
TYPE:
|
examples |
Example sentences for this frame.
TYPE:
|
syntax |
Syntactic structure.
TYPE:
|
semantics |
Semantic representation.
TYPE:
|
Examples:
>>> frame = VNFrame(
... description=FrameDescription(
... description_number="0.1",
... primary="NP V NP",
... secondary="Basic Transitive"
... ),
... examples=[Example(text="John hit the ball")],
... syntax=Syntax(elements=[...]),
... semantics=Semantics(predicates=[...])
... )
Fields:
-
description(FrameDescription) -
examples(list[Example]) -
syntax(Syntax) -
semantics(Semantics)
VerbClass
pydantic-model
¶
Bases: GlazingBaseModel
A VerbNet verb class with members and frames.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
Validated VerbNet class ID (e.g., "give-13.1").
TYPE:
|
members |
Verb members in this class.
TYPE:
|
themroles |
Thematic roles (may be empty for inheritance).
TYPE:
|
frames |
Frame specifications.
TYPE:
|
subclasses |
Recursive subclasses.
TYPE:
|
parent_class |
Parent class ID for subclasses.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
get_effective_roles |
Get effective roles considering inheritance from parent classes. |
get_all_members |
Get all members including those from subclasses. |
get_member_by_key |
Find a member by its VerbNet key. |
has_subclasses |
Check if this class has subclasses. |
Examples:
>>> verb_class = VerbClass(
... id="give-13.1",
... members=[],
... themroles=[
... ThematicRole(type="Agent"),
... ThematicRole(type="Theme"),
... ThematicRole(type="Recipient")
... ],
... frames=[],
... subclasses=[]
... )
>>> roles = verb_class.get_effective_roles()
>>> print(len(roles))
3
Fields:
-
id(VerbClassID) -
members(list[Member]) -
themroles(list[ThematicRole]) -
frames(list[VNFrame]) -
subclasses(list[VerbClass]) -
parent_class(VerbClassID | None)
Validators:
Attributes¶
frames: list[VNFrame]
pydantic-field
¶
Frame specifications
id: VerbClassID
pydantic-field
¶
VerbNet class ID
members: list[Member]
pydantic-field
¶
Verb members
parent_class: VerbClassID | None = None
pydantic-field
¶
Parent class ID for subclasses
subclasses: list[VerbClass]
pydantic-field
¶
Recursive subclasses
themroles: list[ThematicRole]
pydantic-field
¶
Thematic roles (empty for inheritance)
Functions¶
get_all_members(include_subclasses: bool = True) -> list[Member]
¶
Get all members including those from subclasses.
| PARAMETER | DESCRIPTION |
|---|---|
include_subclasses
|
Whether to include members from subclasses.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Member]
|
All members in this class and optionally its subclasses. |
Source code in src/glazing/verbnet/models.py
get_effective_roles(parent_roles: list[ThematicRole] | None = None) -> list[ThematicRole]
¶
Get effective roles considering inheritance from parent classes.
| PARAMETER | DESCRIPTION |
|---|---|
parent_roles
|
Roles from parent class.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[ThematicRole]
|
Effective roles after applying inheritance rules. |
Notes
If themroles is empty and parent_roles is provided, inherits all parent roles. Otherwise, subclass roles override parent roles of the same type.
Source code in src/glazing/verbnet/models.py
get_member_by_key(verbnet_key: str) -> Member | None
¶
Find a member by its VerbNet key.
| PARAMETER | DESCRIPTION |
|---|---|
verbnet_key
|
The VerbNet key to search for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Member | None
|
The member if found, None otherwise. |
Source code in src/glazing/verbnet/models.py
has_subclasses() -> bool
¶
Check if this class has subclasses.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the class has subclasses. |
validate_verbclass_id(v: str) -> VerbClassID
pydantic-validator
¶
Validate VerbNet class ID format.
| PARAMETER | DESCRIPTION |
|---|---|
v
|
Class ID to validate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Validated class ID. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If class ID format is invalid. |
Source code in src/glazing/verbnet/models.py
WordNetCrossRef
pydantic-model
¶
Bases: GlazingBaseModel
Cross-reference to WordNet from VerbNet.
| ATTRIBUTE | DESCRIPTION |
|---|---|
sense_key |
WordNet sense key (preferred, stable across versions).
TYPE:
|
synset_offset |
WordNet synset offset (version-specific).
TYPE:
|
lemma |
The lemma form.
TYPE:
|
pos |
Part of speech ("n", "v", "a", "r", "s").
TYPE:
|
sense_number |
Sense number in WordNet.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
to_percentage_notation |
Convert to VerbNet percentage notation. |
from_percentage_notation |
Parse VerbNet percentage notation. |
Examples:
Fields:
-
sense_key(WordNetSense | None) -
synset_offset(str | None) -
lemma(str) -
pos(str) -
sense_number(int | None)
Functions¶
from_percentage_notation(notation: str) -> Self
classmethod
¶
Parse VerbNet percentage notation.
| PARAMETER | DESCRIPTION |
|---|---|
notation
|
Percentage notation string (e.g., "word%2:40:00").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
WordNetCrossRef
|
Parsed cross-reference. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If notation format is invalid. |
Source code in src/glazing/verbnet/models.py
to_percentage_notation() -> str
¶
Convert to VerbNet percentage notation.
| RETURNS | DESCRIPTION |
|---|---|
str
|
Percentage notation string or empty string if incomplete. |