user_modeling.user_model

Class for user modeling.

The user model stores the user’s preferences, in terms of slots and items in a structured (dictionary) and unstructured manner (utterances). These preferences serve two main purposes: 1. Input for the recommender system. 2. Input for the explainability component to generate an explainable user model.

Module Contents

Classes

UserModel

class user_modeling.user_model.UserModel
classmethod from_json(json_path: str) UserModel

Loads a user model from a JSON file.

Parameters:

json_path – Path to the JSON file.

Raises:

FileNotFoundError – If the JSON file is not found.

Returns:

User model.

save_as_json_file(json_path: str) None

Saves the user model to a JSON file.

Parameters:

json_path – Path to the JSON file.

get_utterances_with_item_preferences(item: str | None = None) List[dialoguekit.core.AnnotatedUtterance]

Returns the utterances with item preference.

If no item is provided, then all the utterances with item preference are returned. Else, only the utterances with item preference for the given item are returned.

Parameters:

item – Item. Defaults to None.

Returns:

Utterances with item preference.

get_item_preferences(item: str | None = None) Dict[str, float] | float

Returns the item preferences.

If no item is provided, then all the item preferences are returned. Else, only the item preferences for the given item are returned.

Parameters:

item – Item. Defaults to None.

Returns:

Item preferences.

get_utterances_with_slot_preferences(slot: str | None = None, value: str | None = None) Dict[str, List[dialoguekit.core.AnnotatedUtterance]] | List[dialoguekit.core.AnnotatedUtterance]

Returns the utterances with slot preference.

If no slot is provided, then all the utterances with slot preference are returned. Else, only the utterances with slot preference for the given slot are returned.

Parameters:
  • slot – Slot. Defaults to None.

  • value – Value. Defaults to None.

Returns:

Utterances with slot preference.

get_slot_preferences(slot: str | None = None) Dict[str, Dict[str, float]] | Dict[str, float]

Returns the slot preferences.

If no slot is provided, then all the slot preferences are returned. Else, only the slot preferences for the given slot are returned.

Parameters:

slot – Slot. Defaults to None.

Returns:

Slot preferences.