User¶
-
class
convokit.model.user.
User
(owner=None, id: str = None, name: str = None, utts=None, convos=None, meta: Optional[Dict] = None)¶ Represents a single user in a dataset.
- Parameters
id (str) – id of the user.
utts – dictionary of utterances by the user, where key is utterance id
convos – dictionary of conversations started by the user, where key is conversation id
meta (dict) – arbitrary dictionary of attributes associated with the user.
- Variables
id – id of the user.
meta – A dictionary-like view object providing read-write access to user-level metadata.
-
add_meta
(key: str, value) → None¶ Adds a key-value pair to the metadata of the corpus object
- Parameters
key – name of metadata
- Returns
None
-
get_conversation
(cid: str)¶ Get the Conversation with the specified Conversation id
- Parameters
cid – The id of the Conversation
- Returns
A Conversation object
-
get_conversation_ids
(selector=<function User.<lambda>>) → List[str]¶ - Returns
a List of the ids of Conversations started by the User
-
get_info
(key)¶ Gets attribute <key> of the corpus object. Returns None if the corpus object does not have this attribute.
- Parameters
key – name of attribute
- Returns
attribute <key>
-
get_utterance
(ut_id: str)¶ Get the Utterance with the specified Utterance id
- Parameters
ut_id – The id of the Utterance
- Returns
An Utterance object
-
get_utterance_ids
(selector=<function User.<lambda>>) → List[str]¶ - Returns
a List of the ids of Utterances made by the User
-
iter_conversations
(selector=<function User.<lambda>>)¶ - Returns
An iterator of the Conversations started by the User
-
iter_utterances
(selector=<function User.<lambda>>)¶ - Returns
An iterator of the Utterances made by the User
-
print_user_stats
()¶ Helper function for printing the number of Utterances and Conversations by the User
- Returns
None
-
retrieve_meta
(key: str)¶ Retrieves a value stored under the key of the metadata of corpus object
- Parameters
key – name of metadata
- Returns
value (if key not found, raises an error)
-
set_info
(key, value)¶ Sets attribute <key> of the corpus object to <value>.
- Parameters
key – name of attribute
value – value to set
- Returns
None