Skip to content

data.queries.Queries

Bases: BaseData

Queries is a class that inherits from the BaseData class. It is used to handle query data.

Source code in pirate/data/queries.py
class Queries(BaseData):
    """
    Queries is a class that inherits from the BaseData class. It is used to handle query data.
    """
    def __init__(
        self,
        data: Union[str, List, Mapping],
        id_key: Optional[str] = None, 
        content_key: Optional[str] = None
    ):
        """
        Initialize the Queries object.

        Args:
            data: The data to be loaded. It can be a string (path to a file), a list, or a dictionary.
            id_key: The key used for the id in the data. Defaults to 'qid'.
            content_key: The key used for the content in the data. Defaults to 'query'.
        """
        id_key = id_key or "qid"
        content_key = content_key or "query"

        super().__init__(data, id_key, content_key)

    def __repr__(self):
        """ Return the string representation of the BaseData object. """
        string = textwrap.dedent(
            f"""Queries(
                data: {len(self.data)} entries
                id_key: {self.id_key}
                content_key: {self.content_key}
            )"""
        )

        return string

__init__(data, id_key=None, content_key=None)

Initialize the Queries 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 'qid'.

None
content_key Optional[str]

The key used for the content in the data. Defaults to 'query'.

None
Source code in pirate/data/queries.py
def __init__(
    self,
    data: Union[str, List, Mapping],
    id_key: Optional[str] = None, 
    content_key: Optional[str] = None
):
    """
    Initialize the Queries object.

    Args:
        data: The data to be loaded. It can be a string (path to a file), a list, or a dictionary.
        id_key: The key used for the id in the data. Defaults to 'qid'.
        content_key: The key used for the content in the data. Defaults to 'query'.
    """
    id_key = id_key or "qid"
    content_key = content_key or "query"

    super().__init__(data, id_key, content_key)

__repr__()

Return the string representation of the BaseData object.

Source code in pirate/data/queries.py
def __repr__(self):
    """ Return the string representation of the BaseData object. """
    string = textwrap.dedent(
        f"""Queries(
            data: {len(self.data)} entries
            id_key: {self.id_key}
            content_key: {self.content_key}
        )"""
    )

    return string

options: show_source: false heading_level: 2