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
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
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))
def process_line(line): langrv.merge(v, langrv.build(builder, line))