Esempio n. 1
0
def _build_language(builder, language, path, start, count):
    """Build a language vector from a range of lines at the given path."""
    v = langrv.build(builder, "")
    def process_line(line):
        langrv.merge(v, langrv.build(builder, line))
    _for_lines(path, start, count, process_line)
    return v
Esempio n. 2
0
def _build_language(builder, language, path, start, count):
    """Build a language vector from a range of lines at the given path."""
    v = langrv.build(builder, "")

    def process_line(line):
        langrv.merge(v, langrv.build(builder, line))

    _for_lines(path, start, count, process_line)
    # print(langrv.save(builder, v))
    return v
Esempio n. 3
0
def _classify(builder, language_vectors, text):
    """Classify the given text (single string) under the given map of language vectors."""
    text_vector = langrv.build(builder, text)
    return max(language_vectors.keys(),
               key=lambda language: langrv.score(language_vectors[language], text_vector))
Esempio n. 4
0
 def process_line(line):
     langrv.merge(v, langrv.build(builder, line))
Esempio n. 5
0
def _classify(builder, language_vectors, text):
    """Classify the given text (single string) under the given map of language vectors."""
    text_vector = langrv.build(builder, text)
    return max(language_vectors.keys(),
               key=lambda language: langrv.score(language_vectors[language],
                                                 text_vector))
Esempio n. 6
0
 def process_line(line):
     langrv.merge(v, langrv.build(builder, line))