Ejemplo n.º 1
0
def map_word_on_two_pole_axis_for_graph(word, axis, score_graph, path_graph):
    result = np.zeros(len(axis))
    for i, (pole_p, pole_n) in enumerate(axis):
        if word in path_graph:
            path_p = shortestPath(path_graph, word, pole_p)
            path_n = shortestPath(path_graph, word, pole_n)
            score_p = calculate_similarity_score_using_path(
                path_p, score_graph)
            score_n = calculate_similarity_score_using_path(
                path_n, score_graph)
            result[i] = calculate_score_on_two_pole_axis(score_p, score_n)
            print word, pole_p, pole_n, result[i]
    return result
Ejemplo n.º 2
0
def map_word_on_one_pole_axis(word,
                              axis,
                              score_graph,
                              path_graph,
                              threshold=None):
    result = np.zeros(len(axis))
    for i, pole in enumerate(axis):
        if word in path_graph:
            path = shortestPath(path_graph, word, pole)
            result[i] = calculate_similarity_score_using_path(
                path, score_graph, path_graph, threshold=threshold)
            print word, pole, result[i]
    return result