Fix fasttext for multiline posts

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-11-05 20:16:32 +01:00
parent 80dbbd5501
commit 17d885fed8

View file

@ -25,7 +25,7 @@ defmodule Pleroma.Language.LanguageDetector.Fasttext do
def detect(text) do
text_path = Path.join(System.tmp_dir!(), "fasttext-#{Ecto.UUID.generate()}")
File.write(text_path, text)
File.write(text_path, text |> String.replace(~r/\s+/, " "))
detected_language =
case System.cmd("fasttext", ["predict", get_model(), text_path]) do