usersimcrs.items.item_collection ================================ .. py:module:: usersimcrs.items.item_collection .. autoapi-nested-parse:: Represents a collection of items. Items are characterized by a set of properties, which correspond to slots in a domain. Items are stored in a SQLite database and can be populated from a CSV file. Attributes ---------- .. autoapisummary:: usersimcrs.items.item_collection.MappingConfig usersimcrs.items.item_collection.SQL_DELIMITER Classes ------- .. autoapisummary:: usersimcrs.items.item_collection.ItemCollection Module Contents --------------- .. py:data:: MappingConfig .. py:data:: SQL_DELIMITER :value: '|' .. py:class:: ItemCollection(db_path: str, table_name: str) Initializes an item collection. :param db_path: Path to the SQLite database. :param table_name: Name of the table containing the items. .. py:method:: connect() -> None Connects to the SQLite database. .. py:method:: close() -> None Closes the connection to the SQLite database. Connection and cursor are set to None to allow pickling. .. py:method:: get_item(item_id: str) -> usersimcrs.items.item.Item Returns an item from the collection based on its ID. :param item_id: Item ID. :returns: Item or None, if not found. .. py:method:: get_random_item() -> usersimcrs.items.item.Item Returns a random item from the collection. :returns: Random item. .. py:method:: exists(item_id: str) -> bool Checks if a given item exists in the item collection. :param item_id: Item ID. :returns: True if the item exists in the collection. .. py:method:: num_items() -> int Returns the number of items in the collection. :returns: Number of items. .. py:method:: add_item(item: usersimcrs.items.item.Item) -> None Adds an item to the collection. :param item: Item. .. py:method:: load_items_csv(file_path: str, domain: usersimcrs.core.simulation_domain.SimulationDomain, domain_mapping: MappingConfig, id_col: str = 'ID', delimiter: str = ',') -> None Loads an item collection from a CSV file. If items are connected to a Domain, only domain properties will be kept. :param file_path: Path to CSV file. :param domain: Domain of the items. :param domain_mapping: Mapping configuration. :param id_col: Name of the column containing the item ID. :param delimiter: CSV delimiter. .. py:method:: get_possible_property_values(property: str) -> Set[str] Returns the possible values for a given property. :param property: Property name. :returns: Set of possible values. .. py:method:: get_items_by_properties(annotations: List[dialoguekit.core.slot_value_annotation.SlotValueAnnotation]) -> List[usersimcrs.items.item.Item] Returns items that match the given slot-value annotations. :param annotations: List of slot-value pair annotations. :returns: List of matching items.