glazing.verbnet.search¶
Searching VerbNet data.
search
¶
VerbNet search functionality.
This module provides search capabilities for VerbNet data, including searches by thematic roles, syntactic patterns, semantic predicates, selectional restrictions, and member verbs.
| CLASS | DESCRIPTION |
|---|---|
VerbNetSearch |
Search interface for VerbNet data. |
Classes¶
VerbNetSearch(classes: list[VerbClass] | None = None)
¶
Search interface for VerbNet data.
Provides methods for finding verb classes by various criteria including thematic roles, syntactic patterns, semantic predicates, and selectional restrictions.
| PARAMETER | DESCRIPTION |
|---|---|
classes
|
Initial verb classes to index. If None, creates empty search.
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
_classes |
Mapping from class ID to verb class object.
TYPE:
|
_classes_by_member |
Mapping from member lemma to class IDs.
TYPE:
|
_classes_by_role |
Mapping from thematic role to class IDs.
TYPE:
|
_classes_by_predicate |
Mapping from semantic predicate to class IDs.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
add_class |
Add a verb class to the search index. |
by_themroles |
Find classes with specified thematic roles. |
by_syntax |
Find classes with matching syntactic patterns. |
by_predicate |
Find classes using a specific semantic predicate. |
by_predicates |
Find classes using multiple semantic predicates. |
by_restriction |
Find classes with selectional restrictions. |
by_members |
Find classes containing specific member verbs. |
complex_search |
Multi-criteria search for verb classes. |
Examples:
>>> search = VerbNetSearch()
>>> search.add_class(give_class)
>>> classes = search.by_themroles(["Agent", "Theme", "Recipient"])
>>> motion_classes = search.by_predicate("motion")
Initialize VerbNet search with optional initial classes.
Source code in src/glazing/verbnet/search.py
Functions¶
add_class(verb_class: VerbClass) -> None
¶
Add a verb class to the search index.
| PARAMETER | DESCRIPTION |
|---|---|
verb_class
|
Verb class to add to index.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If class with same ID already exists. |
Source code in src/glazing/verbnet/search.py
by_members(lemmas: list[str]) -> list[VerbClass]
¶
Find classes containing specific member verbs.
| PARAMETER | DESCRIPTION |
|---|---|
lemmas
|
List of verb lemmas to search for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[VerbClass]
|
Verb classes containing any of the specified members. |
Source code in src/glazing/verbnet/search.py
by_predicate(predicate: PredicateType) -> list[VerbClass]
¶
Find classes using a specific semantic predicate.
| PARAMETER | DESCRIPTION |
|---|---|
predicate
|
Semantic predicate to search for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[VerbClass]
|
Verb classes using the predicate. |
Source code in src/glazing/verbnet/search.py
by_predicates(predicates: list[PredicateType], require_all: bool = True) -> list[VerbClass]
¶
Find classes using multiple semantic predicates.
| PARAMETER | DESCRIPTION |
|---|---|
predicates
|
List of semantic predicates to search for.
TYPE:
|
require_all
|
If True, require all predicates. If False, require at least one.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[VerbClass]
|
Verb classes using the predicates. |
Source code in src/glazing/verbnet/search.py
by_restriction(role: ThematicRoleType, restriction_type: SelectionalRestrictionType, value: RestrictionValue) -> list[VerbClass]
¶
Find classes with selectional restrictions.
| PARAMETER | DESCRIPTION |
|---|---|
role
|
Thematic role to check restrictions on.
TYPE:
|
restriction_type
|
Type of selectional restriction.
TYPE:
|
value
|
Restriction value ("+" or "-").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[VerbClass]
|
Verb classes with matching restrictions. |
Source code in src/glazing/verbnet/search.py
by_role_properties(optional: bool | None = None, indexed: bool | None = None, verb_specific: bool | None = None, pp_type: str | None = None) -> list[VerbClass]
¶
Find classes by role properties.
| PARAMETER | DESCRIPTION |
|---|---|
optional
|
Filter for optional roles (? prefix).
TYPE:
|
indexed
|
Filter for indexed roles (_I, _J suffix).
TYPE:
|
verb_specific
|
Filter for verb-specific roles (V_ prefix).
TYPE:
|
pp_type
|
Filter for specific PP type.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[VerbClass]
|
Classes with matching role properties. |
Source code in src/glazing/verbnet/search.py
by_syntax(pattern: str) -> list[VerbClass]
¶
Find classes with matching syntactic patterns.
Supports hierarchical matching where general patterns match specific ones: - "NP V PP" matches "NP V PP.instrument", "NP V PP.goal", etc. - "NP V NP *" matches any frame with NP V NP followed by anything
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Syntactic pattern to search for (e.g., "NP V PP", "NP V PP.instrument").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[VerbClass]
|
Verb classes with frames matching the pattern. |
Source code in src/glazing/verbnet/search.py
by_themroles(roles: list[ThematicRoleType], only: bool = False) -> list[VerbClass]
¶
Find classes with specified thematic roles.
| PARAMETER | DESCRIPTION |
|---|---|
roles
|
List of thematic role types to search for.
TYPE:
|
only
|
If True, return only classes with exactly these roles. If False, return classes containing at least these roles.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[VerbClass]
|
Verb classes matching the role criteria. |
Source code in src/glazing/verbnet/search.py
complex_search(predicates: list[PredicateType] | None = None, themroles: list[ThematicRoleType] | None = None, restrictions: dict[ThematicRoleType, list[tuple[RestrictionValue, SelectionalRestrictionType]]] | None = None, syntax: str | None = None) -> list[VerbClass]
¶
Multi-criteria search for verb classes.
| PARAMETER | DESCRIPTION |
|---|---|
predicates
|
Semantic predicates to require.
TYPE:
|
themroles
|
Thematic roles to require.
TYPE:
|
restrictions
|
ThematicRoleType, list[tuple[RestrictionValue, SelectionalRestrictionType]]
TYPE:
|
syntax
|
Syntactic pattern to match.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[VerbClass]
|
Verb classes matching all specified criteria. |
Source code in src/glazing/verbnet/search.py
from_jsonl_file(path: Path | str) -> VerbNetSearch
classmethod
¶
Load search index from JSON Lines file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Path to JSON Lines file containing verb classes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
VerbNetSearch
|
Search index populated with classes from file. |
| RAISES | DESCRIPTION |
|---|---|
FileNotFoundError
|
If file does not exist. |
ValueError
|
If file contains invalid data. |
Source code in src/glazing/verbnet/search.py
get_all_classes() -> list[VerbClass]
¶
Get all verb classes in the search index.
| RETURNS | DESCRIPTION |
|---|---|
list[VerbClass]
|
All verb classes sorted by ID. |
get_all_members() -> list[str]
¶
Get all unique member lemmas.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Sorted list of unique member lemmas. |
get_all_predicates() -> list[PredicateType]
¶
Get all unique semantic predicates.
| RETURNS | DESCRIPTION |
|---|---|
list[PredicateType]
|
Sorted list of unique predicates. |
get_all_roles() -> list[ThematicRoleType]
¶
Get all unique thematic roles.
| RETURNS | DESCRIPTION |
|---|---|
list[ThematicRoleType]
|
Sorted list of unique roles. |
get_by_id(class_id: VerbClassID) -> VerbClass | None
¶
Get a verb class by its ID.
| PARAMETER | DESCRIPTION |
|---|---|
class_id
|
ID of the verb class to retrieve.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
VerbClass | None
|
The verb class if found, None otherwise. |
Source code in src/glazing/verbnet/search.py
get_statistics() -> dict[str, int]
¶
Get search index statistics.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, int]
|
Statistics about indexed data. |