def run_with_context(interactions_path, candidate_tree_path, dirname=None, to_original_graph=False, undirected=False):
    if not os.path.exists(dirname):
        os.makedirs(dirname)

    try:
        interactions = json.load(open(interactions_path))
    except ValueError as e:
        print(e)
        interactions = load_json_by_line(interactions_path)

    interactions = IU.clean_interactions(interactions, undirected=undirected)

    output_path = get_output_path(candidate_tree_path, dirname)

    K = 5
    events = detect_events_given_path(candidate_tree_path, K)

    contexted_events = []
    for e in events:
        context_dag = extract_event_context(interactions, e, undirected=undirected)

        if to_original_graph:
            context_dag = convert_to_original_graph(context_dag)
            e = convert_to_original_graph(e)

        contexted_events.append(add_subgraph_specific_attributes_to_graph(context_dag, [(e, {"event": True})]))
    d3_events = [to_d3_graph(ce) for ce in contexted_events]

    print("writing to {}".format(output_path))
    json_dump(d3_events, output_path)
def build_default_summary_kws(interactions,
                              people_info,
                              dictionary,
                              lda,
                              people_repr_template,
                              undirected=False):
    interactions = IU.clean_interactions(interactions, undirected=undirected)
    summary_kws = {
        'basic_structure_stats': {},
        'time_span': {},
        # Deprecated
        'topics': {
            'interactions': interactions,
            'dictionary': dictionary,
            'lda': lda,
            'top_k': 10
        },
        'email_content': {
            'interactions': interactions,
            'top_k': 5
        },
        'participants': {
            'people_info': people_info,
            'interactions': interactions,
            'top_k': 5,
            'people_repr_template': people_repr_template,
            'undirected': undirected
        },
        'link_type_freq': {
            'interactions': interactions,
            'undirected': undirected
        },
        # 'frequent_terms': {
        #     'interactions': interactions,
        #     'top_k': 10
        # },
        # 'tfidf_terms': {
        #     'interactions': interactions,
        #     'dictionary': dictionary,
        #     'top_k': 10
        # }
    }
    return summary_kws
def run_with_context(interactions_path,
                     candidate_tree_path,
                     dirname=None,
                     to_original_graph=False,
                     undirected=False):
    if not os.path.exists(dirname):
        os.makedirs(dirname)

    try:
        interactions = json.load(open(interactions_path))
    except ValueError as e:
        print(e)
        interactions = load_json_by_line(interactions_path)

    interactions = IU.clean_interactions(interactions,
                                         undirected=undirected)

    output_path = get_output_path(candidate_tree_path, dirname)

    K = 5
    events = detect_events_given_path(candidate_tree_path, K)

    contexted_events = []
    for e in events:
        context_dag = extract_event_context(
            interactions, e,
            undirected=undirected
        )

        if to_original_graph:
            context_dag = convert_to_original_graph(context_dag)
            e = convert_to_original_graph(e)

        contexted_events.append(
            add_subgraph_specific_attributes_to_graph(
                context_dag, [(e, {'event': True})])
        )
    d3_events = [to_d3_graph(ce)
                 for ce in contexted_events]
    
    print('writing to {}'.format(output_path))
    json_dump(d3_events, output_path)
Exemple #4
0
def build_default_summary_kws(interactions, people_info,
                              dictionary, lda, people_repr_template,
                              undirected=False):
    interactions = IU.clean_interactions(interactions,
                                         undirected=undirected)
    summary_kws = {
        'basic_structure_stats': {},
        'time_span': {},
        # Deprecated
        'topics': {
            'interactions': interactions,
            'dictionary': dictionary,
            'lda': lda,
            'top_k': 10
        },
        'email_content': {
            'interactions': interactions,
            'top_k': 5
        },
        'participants': {
            'people_info': people_info,
            'interactions': interactions,
            'top_k': 5,
            'people_repr_template': people_repr_template,
            'undirected': undirected
        },
        'link_type_freq': {
            'interactions': interactions,
            'undirected': undirected
        },
        # 'frequent_terms': {
        #     'interactions': interactions,
        #     'top_k': 10
        # },
        # 'tfidf_terms': {
        #     'interactions': interactions,
        #     'dictionary': dictionary,
        #     'top_k': 10
        # }
    }
    return summary_kws
Exemple #5
0
 def setUp(self):
     self.interactions = IU.clean_interactions(
         json_load(
             make_path('test/data/enron_test.json')
         )
     )
Exemple #6
0
 def setUp(self):
     self.interactions = IU.clean_interactions(
         json_load(make_path('test/data/enron_test.json')))