def get_graph(definition="Дерево", n=0):
    global tree
    if n < 3:
        definition_text = get_definition(definition)
        open('/tmp/rez.txt', 'a').write("=\n%s\n=\n" % definition_text)

        keywords = get_keywords(definition_text)

        keywords = filter_keywords(keywords, set(['гео', 'фам']))
        for word in keywords:
            if word != definition and len(word) > 3:
                tree.update({(definition, word): 1})
                get_graph(word, n + 1)
Esempio n. 2
0
def get_graph(word="Дерево", n=3):
    count = 0
    word = word.lower()

    if n > 0:
        definition = get_definition(word)
        open('/tmp/rez.txt', 'a').write("=\n%s\n=\n" % definition)
        for word_i in unwiki(filter_keywords(get_keywords(definition))):
            if word_i != word and not is_stop_word(word_i):
                count += 1
                if get_graph(word_i, n - 1):
                    try:
                        tree[(word, word_i)] += 1
                    except KeyError:
                        tree.update({(word, word_i): 1})
    return count
def get_graph(definition="Дерево", n=0):
    global tree

    print(n, definition, file=sys.stderr)

    if n < 3:
        definition_text = get_definition(definition)
        open('/tmp/rez.txt', 'a').write("=\n%s\n=\n" % definition_text)

        keywords = get_keywords(definition_text)
        keywords = filter_keywords(keywords, set(['гео', 'фам']),
                                   set([r'англ', r"displaystyle.*"]))

        for word in keywords:
            if word != definition and len(word) > 3:
                tree.update({(definition, word): 1})
                get_graph(word, n + 1)