dialoguekit.core.recsys.item_collection¶
Represents a collection of items.
Classes¶
Initializes an empty item collection. |
Module Contents¶
- class dialoguekit.core.recsys.item_collection.ItemCollection¶
Initializes an empty item collection.
- get_item(item_id: str) dialoguekit.core.recsys.item.Item ¶
Returns an item from the collection based on its ID.
- Parameters:
item_id – Item ID.
- Returns:
Item or None, if not found.
- exists(item_id: str) bool ¶
Checks if a given item exists in the item collection.
- Parameters:
item_id – Item ID.
- Returns:
True if the item exists in the collection.
- num_items() int ¶
Returns the number of items in the collection.
- Returns:
Number of items.
- add_item(item: dialoguekit.core.recsys.item.Item) None ¶
Adds an item to the collection.
- Parameters:
item – Item.
- load_items_csv(file_path: str, fields: List[Any], delimiter: str = ',') None ¶
Loads an item collection from a CSV file.
The CSV file is assumed to have a header row, which is ignored. Instead, the fields argument specifies which item properties the values correspond to.
- Parameters:
file_path – Path to CSV file.
fields – Mapping of CSV fields to item properties. ID and NAME are designated values for mapping to item ID and name. A None value means that the field is ignored. Otherwise, the value if fields is used as the name (key) of the item property.
delimiter – Field separator (default: comma).