conversation.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:facebook-message-analysis 作者: szheng17 项目源码 文件源码
def get_time_interval_to_message_statistic(self, time_interval,
                                               message_statistic):
        """
        Maps each value of time interval to the sum of the values of a message
        statistic over all messages from that time interval value. Wrapper
        function for the functions 'get_' + time_interval.replace(' ', '_') +
        '_to_message_statistic'.

        Args:
            time_interval: One of 'minute in hour', 'minute in day', 'hour',
                'date', 'week', 'month', 'year'.
            message_statistic: A function mapping a Message object to an int or
                a float.

        Returns:
            time_interval_to_message_statistic: A dict mapping each value of a
                time interval to the sum of the values of message_statistic
                over all messages in self.messages from that time interval
                value.
        """

        if time_interval not in self.TIME_INTERVALS:
            raise ValueError('time_interval must be in {}'.format(self.TIME_INTERVALS))
        getter = getattr(self, 'get_' + time_interval.replace(' ', '_') + '_to_message_statistic')
        time_interval_to_message_statistic = getter(message_statistic)
        return time_interval_to_message_statistic
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号