glazing.framenet.search¶
Searching FrameNet data.
search
¶
FrameNet search functionality.
This module provides search capabilities for FrameNet data, including frame searches by name and definition, frame element searches across frames, and lexical unit pattern matching.
| CLASS | DESCRIPTION |
|---|---|
FrameNetSearch |
Search interface for FrameNet frame lookups. |
Classes¶
FrameNetSearch(frames: list[Frame] | None = None)
¶
Search interface for FrameNet frame lookups.
Provides search methods for frames, frame elements, and lexical units with pattern matching and cross-frame queries.
| PARAMETER | DESCRIPTION |
|---|---|
frames
|
Initial frames to index. If None, creates empty index.
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
_frames_by_id |
Mapping from frame ID to frame object.
TYPE:
|
_frames_by_name |
Mapping from frame name to frame object.
TYPE:
|
_frames_by_lemma |
Mapping from lemma to frames evoked by that lemma.
TYPE:
|
_fe_index |
Mapping from FE name to frames containing that FE.
TYPE:
|
_lu_index |
Mapping from lemma to lexical units.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
add_frame |
Add a frame to the index. |
get_frame_by_id |
Get frame by ID. |
get_frame_by_name |
Get frame by name. |
search_frames_by_name |
Search frames by name pattern. |
search_frames_by_definition |
Search frames by definition pattern. |
find_frames_with_fe |
Find frames containing a specific FE. |
find_frames_by_lemma |
Find frames evoked by a lemma. |
search_lexical_units |
Search lexical units by pattern. |
get_fe_across_frames |
Get FE definitions across all frames. |
Examples:
>>> search = FrameNetSearch()
>>> search.add_frame(abandonment_frame)
>>> frame = search.get_frame_by_name("Abandonment")
>>> frames = search.search_frames_by_definition("leave.*behind")
Initialize frame index with optional initial frames.
Source code in src/glazing/framenet/search.py
Functions¶
add_frame(frame: Frame) -> None
¶
Add a frame to the index.
| PARAMETER | DESCRIPTION |
|---|---|
frame
|
Frame to add to index.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If frame with same ID already exists. |
Source code in src/glazing/framenet/search.py
by_element_properties(core_type: str | None = None, semantic_type: str | None = None) -> list[Frame]
¶
Find frames by element properties.
| PARAMETER | DESCRIPTION |
|---|---|
core_type
|
Filter by core type ("Core", "Non-Core", "Extra-Thematic").
TYPE:
|
semantic_type
|
Filter by semantic type.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Frame]
|
Frames with matching element properties. |
Source code in src/glazing/framenet/search.py
by_syntax(pattern: str) -> list[Frame]
¶
Find frames with valence patterns matching a syntactic pattern.
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Syntactic pattern (e.g., "NP V NP", "NP V PP").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Frame]
|
Frames with matching valence patterns. |
Source code in src/glazing/framenet/search.py
find_frames_by_lemma(lemma: str, pos: FrameNetPOS | None = None) -> list[Frame]
¶
Find frames evoked by a lemma.
| PARAMETER | DESCRIPTION |
|---|---|
lemma
|
Lemma to search for.
TYPE:
|
pos
|
If specified, only return frames with LUs of this POS.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Frame]
|
Frames evoked by the lemma. |
Source code in src/glazing/framenet/search.py
find_frames_with_fe(fe_name: str, core_type: CoreType | None = None) -> list[Frame]
¶
Find frames containing a specific frame element.
| PARAMETER | DESCRIPTION |
|---|---|
fe_name
|
Name of frame element to search for.
TYPE:
|
core_type
|
If specified, only return frames where FE has this core type.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Frame]
|
Frames containing the specified FE. |
Source code in src/glazing/framenet/search.py
from_jsonl_file(path: Path | str) -> FrameNetSearch
classmethod
¶
Load index from JSON Lines file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Path to JSON Lines file containing frames.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FrameIndex
|
Index populated with frames from file. |
| RAISES | DESCRIPTION |
|---|---|
FileNotFoundError
|
If file does not exist. |
ValueError
|
If file contains invalid data. |
Source code in src/glazing/framenet/search.py
get_all_fe_names() -> list[str]
¶
Get all unique frame element names across all frames.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Sorted list of unique FE names. |
get_all_lemmas() -> list[str]
¶
Get all unique lemmas across all lexical units.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Sorted list of unique lemmas. |
get_fe_across_frames(fe_name: str) -> dict[str, FrameElement]
¶
Get frame element definitions across all frames.
| PARAMETER | DESCRIPTION |
|---|---|
fe_name
|
Name of frame element to retrieve.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, FrameElement]
|
Mapping from frame name to FE definition in that frame. |
Source code in src/glazing/framenet/search.py
get_frame_by_id(frame_id: FrameID) -> Frame | None
¶
Get frame by ID.
| PARAMETER | DESCRIPTION |
|---|---|
frame_id
|
Frame ID to look up.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Frame | None
|
Frame if found, None otherwise. |
Source code in src/glazing/framenet/search.py
get_frame_by_name(name: str) -> Frame | None
¶
Get frame by name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Frame name to look up.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Frame | None
|
Frame if found, None otherwise. |
Source code in src/glazing/framenet/search.py
get_statistics() -> dict[str, int]
¶
Get index statistics.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, int]
|
Statistics about indexed data. |
Source code in src/glazing/framenet/search.py
merge(other: FrameNetSearch) -> None
¶
Merge another index into this one.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
Index to merge into this one.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If there are conflicting frame IDs. |
Source code in src/glazing/framenet/search.py
search_frames_by_definition(pattern: str, case_sensitive: bool = False) -> list[Frame]
¶
Search frames by definition pattern.
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Regular expression pattern to match against frame definitions.
TYPE:
|
case_sensitive
|
Whether search should be case-sensitive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Frame]
|
Frames with definitions matching pattern. |
| RAISES | DESCRIPTION |
|---|---|
error
|
If pattern is invalid regular expression. |
Source code in src/glazing/framenet/search.py
search_frames_by_name(pattern: str, case_sensitive: bool = False) -> list[Frame]
¶
Search frames by name pattern.
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Regular expression pattern to match against frame names.
TYPE:
|
case_sensitive
|
Whether search should be case-sensitive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Frame]
|
Frames with names matching pattern. |
| RAISES | DESCRIPTION |
|---|---|
error
|
If pattern is invalid regular expression. |
Source code in src/glazing/framenet/search.py
search_lexical_units(pattern: str, pos: FrameNetPOS | None = None, case_sensitive: bool = False) -> list[LexicalUnit]
¶
Search lexical units by pattern.
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
Regular expression pattern to match against LU names.
TYPE:
|
pos
|
If specified, only return LUs with this POS.
TYPE:
|
case_sensitive
|
Whether search should be case-sensitive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[LexicalUnit]
|
Lexical units matching the pattern. |
| RAISES | DESCRIPTION |
|---|---|
error
|
If pattern is invalid regular expression. |