Utterance¶
-
class
convokit.model.utterance.
Utterance
(owner=None, id: Union[str, NoneType] = None, speaker: Union[convokit.model.speaker.Speaker, NoneType] = None, user: Union[convokit.model.speaker.Speaker, NoneType] = None, conversation_id: Union[str, NoneType] = None, root: Union[str, NoneType] = None, reply_to: Union[str, NoneType] = None, timestamp: Union[int, NoneType] = None, text: str = '', meta: Union[Dict[KT, VT], NoneType] = None, from_db=False, storage: Union[convokit.storage.storageManager.StorageManager, NoneType] = None)¶ Represents a single utterance in the dataset.
Parameters: - id – the unique id of the utterance.
- speaker – the speaker giving the utterance.
- conversation_id – the id of the root utterance of the conversation.
- reply_to – id of the utterance this was a reply to.
- timestamp – timestamp of the utterance. Can be any comparable type.
- text – text of the utterance.
Variables: - id – the unique id of the utterance.
- speaker – the speaker giving the utterance.
- conversation_id – the id of the root utterance of the conversation.
- reply_to – id of the utterance this was a reply to.
- timestamp – timestamp of the utterance.
- text – text of the utterance.
- meta – A dictionary-like view object providing read-write access to utterance-level metadata.
-
add_meta
(key: str, value) → None¶ Adds a key-value pair to the metadata of the corpus object :param key: name of metadata attribute :param value: value of metadata attribute :return: None
-
add_vector
(vector_name: str)¶ Logs in the Corpus component object’s internal vectors list that the component object has a vector row associated with it in the vector matrix named vector_name. Transformers that add vectors to the Corpus should use this to update the relevant component objects during the transform() step. :param vector_name: name of vector matrix :return: None
-
delete_vector
(vector_name: str)¶ Delete a vector associated with this Corpus component object. :param vector_name: :return: None
-
classmethod
from_dbdoc
(doc: convokit.storage.dbMappings.DBDocumentMapping)¶ Initialize a corpusComponent object with data contained in the DB document represented by doc.
Parameters: - cls – class to initialize: Utterance, Conversation, or Speaker
- doc – DB document to initialize the corpusComponent from
Returns: the initialized corpusComponent object
-
get_conversation
()¶ Get the Conversation (identified by Utterance.conversation_id) this Utterance belongs to
Returns: a Conversation object
-
get_info
(key)¶ Gets attribute <key> of the corpus object. Returns None if the corpus object does not have this attribute. :param key: name of attribute :return: attribute <key>
-
get_speaker
()¶ Get the Speaker that made this Utterance.
Returns: a Speaker object
-
get_vector
(vector_name: str, as_dataframe: bool = False, columns: Union[List[str], NoneType] = None)¶ Get the vector stored as vector_name for this object. :param vector_name: name of vector :param as_dataframe: whether to return the vector as a dataframe (True) or in its raw array form (False). False
by default.Parameters: columns – optional list of named columns of the vector to include. All columns returned otherwise. This parameter is only used if as_dataframe is set to True Returns: a numpy / scipy array
-
retrieve_meta
(key: str)¶ Retrieves a value stored under the key of the metadata of corpus object :param key: name of metadata attribute :return: value
-
set_info
(key, value)¶ Sets attribute <key> of the corpus object to <value>. :param key: name of attribute :param value: value to set :return: None