Exemplo n.º 1
0
def topics_from_to(start, end):
    years = range(start, end+1)

    topicFiles = fileSys.traverseTopicDirecotry(model_path, 1, years)

    # fill the path where distances are stored
    clf_topic = path.join(root_path, 'dtm/distance')
    distanceFiles = fileSys.traverseDistanceDirectory(clf_topic, years)

    topic_graph = graph.createGraph(topicFiles, distanceFiles, 0)

    return topic_graph
Exemplo n.º 2
0
def topics_from_to(start, end):
    years = range(start, end+1)

    topicFiles = fileSys.traverseTopicDirecotry(model_path, 1, years)

    # fill the path where distances are stored
    clf_topic = path.join(root_path, 'dtm/distance')
    distanceFiles = fileSys.traverseDistanceDirectory(clf_topic, years)

    topic_graph = graph.createGraph(topicFiles, distanceFiles, 0)

    return topic_graph
Exemplo n.º 3
0
def topics_for_class(class_mode, class_name, start, end):
    if class_mode == 'acm-class':
        clf_topic = ioFile.load_object(path.join(root_path, 'class_topic/class_topic_acm-class.pkl'))
    elif class_mode == 'arxiv-category':
        clf_topic = ioFile.load_object(path.join(root_path, 'class_topic/class_topic_arxiv-category.pkl'))

    clf_topic_stat = []
    topic_num = []
    years = set(range(start, end+1))
    for year in range(start, end+1):
        try:
            clf_topic_stat.append(Counter(clf_topic[str(year)][class_name]))
            topic_num.append(len(set(clf_topic[str(year)][class_name])))
        except KeyError:
            years.remove(year)

    topicFiles = fileSys.traverseTopicDirecotry(model_path, 1, years)
    clf_topic = path.join(root_path, 'class_topic/distance')
    distanceFiles = fileSys.traverseDistanceDirectory(clf_topic, list(years))

    topic_graph = graph.createGraph(topicFiles, distanceFiles, 2, clf_topic_stat, topic_num)

    return topic_graph, years
Exemplo n.º 4
0
def topics_for_class(class_mode, class_name, start, end):
    if class_mode == 'acm-class':
        clf_topic = ioFile.load_object(path.join(root_path, 'class_topic/class_topic_acm-class.pkl'))
    elif class_mode == 'arxiv-category':
        clf_topic = ioFile.load_object(path.join(root_path, 'class_topic/class_topic_arxiv-category.pkl'))

    clf_topic_stat = []
    topic_num = []
    years = set(range(start, end+1))
    for year in range(start, end+1):
        try:
            clf_topic_stat.append(Counter(clf_topic[str(year)][class_name]))
            topic_num.append(len(set(clf_topic[str(year)][class_name])))
        except KeyError:
            years.remove(year)

    topicFiles = fileSys.traverseTopicDirecotry(model_path, 1, years)
    clf_topic = path.join(root_path, 'class_topic/distance')
    distanceFiles = fileSys.traverseDistanceDirectory(clf_topic, list(years))

    topic_graph = graph.createGraph(topicFiles, distanceFiles, 2, clf_topic_stat, topic_num)

    return topic_graph, years