data.queries.Queries
Bases: BaseData
The Passages class inherits from the BaseData class. It is used to handle passages of text data.
Source code in pirate/data/passages.py
__init__(data, id_key=None, content_key=None)
Initialize the Passages object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Union[str, List, Mapping]
|
The data to be loaded. It can be a string (path to a file), a list, or a dictionary. |
required |
id_key
|
Optional[str]
|
The key used for the id in the data. Defaults to 'pid'. |
None
|
content_key
|
Optional[str]
|
The key used for the content in the data. Defaults to 'passage'. |
None
|
Source code in pirate/data/passages.py
__repr__()
Return the string representation of the BaseData object.
Source code in pirate/data/passages.py
add(content)
Add a passage to the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
The content of the passage. |
required |
Returns:
Type | Description |
---|---|
str
|
The ID of the passage. |
Source code in pirate/data/passages.py
get_id(content)
Get the ID of a passage given its content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
The content of the passage. |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
The ID of the passage if it exists, otherwise None. |
Source code in pirate/data/passages.py
options: show_source: false heading_level: 2