glazing.propbank.search¶
Searching PropBank data.
search
¶
PropBank search functionality.
This module provides search capabilities for PropBank data, including searches by predicate lemma, roleset ID, semantic roles, and external resource mappings.
| CLASS | DESCRIPTION |
|---|---|
PropBankSearch |
Search interface for PropBank data. |
Classes¶
PropBankSearch(framesets: list[Frameset] | None = None)
¶
Search interface for PropBank data.
Provides methods for finding framesets and rolesets by various criteria including predicate lemma, roleset ID, semantic roles, function tags, and external resource mappings.
| PARAMETER | DESCRIPTION |
|---|---|
framesets
|
Initial framesets to index. If None, creates empty search.
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
_framesets |
Mapping from predicate lemma to frameset object.
TYPE:
|
_rolesets |
Mapping from roleset ID to roleset object.
TYPE:
|
_rolesets_by_role |
Mapping from argument number to roleset IDs.
TYPE:
|
_rolesets_by_function |
Mapping from function tag to roleset IDs.
TYPE:
|
_rolesets_by_resource |
Mapping from resource type to roleset IDs.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
add_frameset |
Add a frameset to the search index. |
by_lemma |
Find frameset by predicate lemma. |
by_roleset_id |
Find roleset by ID. |
by_pattern |
Find framesets matching a lemma pattern. |
by_role |
Find rolesets with specific semantic roles. |
by_resource |
Find rolesets linked to external resources. |
search_aliases |
Search for rolesets by alias patterns. |
get_all_lemmas |
Get all unique predicate lemmas. |
get_all_rolesets |
Get all rolesets. |
get_statistics |
Get search index statistics. |
Examples:
>>> search = PropBankSearch()
>>> search.add_frameset(give_frameset)
>>> frameset = search.by_lemma("give")
>>> rolesets = search.by_role("0", "PAG")
Initialize PropBank search with optional initial framesets.
Source code in src/glazing/propbank/search.py
Functions¶
add_frameset(frameset: Frameset) -> None
¶
Add a frameset to the search index.
| PARAMETER | DESCRIPTION |
|---|---|
frameset
|
Frameset to add to index.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If frameset with same lemma already exists. |
Source code in src/glazing/propbank/search.py
by_arg_properties(is_core: bool | None = None, modifier_type: str | None = None, prefix: str | None = None, arg_number: str | None = None) -> list[Roleset]
¶
Find rolesets by argument properties.
| PARAMETER | DESCRIPTION |
|---|---|
is_core
|
Filter for core arguments (ARG0-6).
TYPE:
|
modifier_type
|
Filter for specific modifier type (e.g., "LOC", "TMP").
TYPE:
|
prefix
|
Filter for continuation or reference prefix ("C" or "R").
TYPE:
|
arg_number
|
Filter for specific argument number (e.g., "0", "1", "2").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Roleset]
|
Rolesets with matching argument properties. |
Source code in src/glazing/propbank/search.py
by_lemma(lemma: PredicateLemma) -> Frameset | None
¶
Find frameset by predicate lemma.
| PARAMETER | DESCRIPTION |
|---|---|
lemma
|
Predicate lemma to look up.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Frameset | None
|
Frameset if found, None otherwise. |
Source code in src/glazing/propbank/search.py
by_pattern(pattern: str, case_sensitive: bool = False) -> list[Frameset]
¶
Find framesets matching a lemma pattern.
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Regular expression pattern to match against lemmas.
TYPE:
|
case_sensitive
|
Whether search should be case-sensitive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Frameset]
|
Framesets with lemmas matching the pattern. |
| RAISES | DESCRIPTION |
|---|---|
error
|
If pattern is invalid regular expression. |
Source code in src/glazing/propbank/search.py
by_resource(resource_type: ResourceType, class_name: str | None = None) -> list[Roleset]
¶
Find rolesets linked to external resources.
| PARAMETER | DESCRIPTION |
|---|---|
resource_type
|
Type of resource (e.g., "VerbNet", "FrameNet").
TYPE:
|
class_name
|
Specific class/frame name to match.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Roleset]
|
Rolesets linked to the specified resource. |
Source code in src/glazing/propbank/search.py
by_role(arg_num: ArgumentNumber | None = None, function_tag: FunctionTag | None = None) -> list[Roleset]
¶
Find rolesets with specific semantic roles.
| PARAMETER | DESCRIPTION |
|---|---|
arg_num
|
Argument number to search for (e.g., "0", "1", "M").
TYPE:
|
function_tag
|
Function tag to search for (e.g., "PAG", "PPT").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Roleset]
|
Rolesets matching the role criteria. |
Source code in src/glazing/propbank/search.py
by_roleset_id(roleset_id: RolesetID) -> Roleset | None
¶
Find roleset by ID.
| PARAMETER | DESCRIPTION |
|---|---|
roleset_id
|
Roleset ID to look up.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Roleset | None
|
Roleset if found, None otherwise. |
Source code in src/glazing/propbank/search.py
by_syntax(pattern: str) -> list[Roleset]
¶
Find rolesets with examples matching a syntactic pattern.
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Syntactic pattern (e.g., "NP V NP", "NP V PP").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Roleset]
|
Rolesets with examples matching the syntactic pattern. |
Source code in src/glazing/propbank/search.py
from_jsonl_file(path: Path | str) -> PropBankSearch
classmethod
¶
Load search index from JSON Lines file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Path to JSON Lines file containing framesets.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PropBankSearch
|
Search index populated with framesets from file. |
| RAISES | DESCRIPTION |
|---|---|
FileNotFoundError
|
If file does not exist. |
ValueError
|
If file contains invalid data. |
Source code in src/glazing/propbank/search.py
get_all_framesets() -> list[Frameset]
¶
Get all framesets in the search index.
| RETURNS | DESCRIPTION |
|---|---|
list[Frameset]
|
All framesets sorted by predicate lemma. |
Source code in src/glazing/propbank/search.py
get_all_function_tags() -> list[FunctionTag]
¶
Get all unique function tags.
| RETURNS | DESCRIPTION |
|---|---|
list[FunctionTag]
|
Sorted list of unique function tags. |
get_all_lemmas() -> list[PredicateLemma]
¶
Get all unique predicate lemmas.
| RETURNS | DESCRIPTION |
|---|---|
list[PredicateLemma]
|
Sorted list of unique lemmas. |
get_all_rolesets() -> list[Roleset]
¶
Get all rolesets.
| RETURNS | DESCRIPTION |
|---|---|
list[Roleset]
|
All rolesets in the index, sorted by ID. |
get_statistics() -> dict[str, int]
¶
Get search index statistics.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, int]
|
Statistics about indexed data. |
Source code in src/glazing/propbank/search.py
search_aliases(pattern: str, case_sensitive: bool = False) -> list[Roleset]
¶
Search for rolesets by alias patterns.
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Regular expression pattern to match against aliases.
TYPE:
|
case_sensitive
|
Whether search should be case-sensitive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Roleset]
|
Rolesets with aliases matching the pattern. |
| RAISES | DESCRIPTION |
|---|---|
error
|
If pattern is invalid regular expression. |