示例#1
0
def main(file_path):
    # Validate raw data path
    if not os.path.exists(file_path):
        LOG_ERROR('Could not find file: {}'.format(file_path))
        return

    # Validate raw data file type
    if not file_path.endswith('.json'):
        LOG_ERROR('File path must be a json file')
        return

    # Parse JSON
    with open(file_path, encoding='utf-8') as f:
        LOG_INFO('Parsing JSON file: {}'.format(file_path))
        json_archive = json.load(f)

        if not 'conversation_state' in json_archive.keys():
            LOG_ERROR('Could not find `conversation_state` in file {}'.format(
                file_path))
            return

        # Parse each conversation
        for state in json_archive['conversation_state']:
            conv = Conversation(state)
            conv.parse()
            conv.print_summary()
            conv.serialize()

    LOG_INFO('Finished parsing conversations!')
示例#2
0
def main(file_path):
    # Validate raw data path
    if not os.path.exists(file_path):
        LOG_ERROR('Could not find file: {}'.format(file_path))
        return

    # Validate raw data file type
    if not file_path.endswith('.pkl'):
        LOG_ERROR('File path must be a pickle file')
        return

    with open(file_path, 'rb') as f:
        LOG_INFO('Parsing pickle file: {}'.format(file_path))
        conversation = pickle.load(f)

        LOG_INFO('Found conversation: {}'.format(conversation['conversation_name']))

        df = pd.DataFrame(conversation['messages'])
        df.columns = ['Timestamp', 'Type', 'Participant']
        # df['Datetime'] = pd.to_datetime(df['Timestamp'])
        df['Datetime'] = df['Timestamp'].apply(lambda x:
                datetime.datetime.fromtimestamp(float(x)).toordinal())

        histogram = ggplot.ggplot(df, ggplot.aes(x='Datetime', fill='Participant')) \
                        + ggplot.geom_histogram(alpha=0.6, binwidth=2) \
                        + ggplot.scale_x_date(labels='%b %Y') \
                        + ggplot.ggtitle(conversation['conversation_name']) \
                        + ggplot.ylab('Number of messages') \
                        + ggplot.xlab('Date')

        print(histogram)
示例#3
0
文件: flash.py 项目: CH4MPi/GUIFlash
 def createComponent(self, alias, type, props=None):
     if not g_guiCache.isComponent(alias):
         type = g_guiCache.getCustomizedType(type)
         if g_guiCache.isTypeValid(type):
             g_guiCache.create(alias, type, props)
             g_guiViews.create(alias, type, props)
         else:
             LOG_ERROR("Invalid type of component '%s'!" % alias)
     else:
         LOG_ERROR("Component '%s' already exists!" % alias)
示例#4
0
文件: flash.py 项目: angelsoft1/2
 def createComponent(self, alias, type, props=None):
     if not g_guiCache.isComponent(alias):
         type = g_guiCache.getCustomizedType(type)
         if g_guiCache.isTypeValid(type):
             g_guiCache.create(alias, type, props)
             g_guiViews.create(alias, type, props)
         else:
             LOG_ERROR('GUIFlash :',
                       'Invalid type of component "%s"!' % alias)
     else:
         LOG_ERROR('GUIFlash :', 'Component "%s" already exists!' % alias)
示例#5
0
文件: flash.py 项目: angelsoft1/2
 def deleteComponent(self, alias):
     if g_guiCache.isComponent(alias):
         g_guiCache.delete(alias)
         g_guiViews.delete(alias)
     else:
         LOG_ERROR('GUIFlash :', 'Component "%s" not found!' % alias)
示例#6
0
文件: flash.py 项目: CH4MPi/GUIFlash
 def deleteComponent(self, alias):
     if g_guiCache.isComponent(alias):
         g_guiCache.delete(alias)
         g_guiViews.delete(alias)
     else:
         LOG_ERROR("Component '%s' not found" % alias)
示例#7
0
文件: flash.py 项目: CH4MPi/GUIFlash
 def updateComponent(self, alias, props, params=None):
     if g_guiCache.isComponent(alias):
         g_guiCache.update(alias, props)
         g_guiViews.update(alias, props, params)
     else:
         LOG_ERROR("Component '%s' not found!" % alias)