docbrown/app/labor/language_detector.rb
Ben Halpern bd95c6a8bf
Fix human language detection (#2338)
* Update language detection

* Modify feed to account for languages
2019-04-08 15:47:29 -04:00

21 lines
398 B
Ruby

class LanguageDetector
def initialize(article)
@article = article
end
def detect
response = get_language
response[:code] if response[:reliable]
rescue StandardError
nil
end
def get_language
CLD.detect_language(text)
end
def text
@article.title + ". " +
FrontMatterParser::Parser.new(:md).call(@article.body_markdown).content.split("`")[0]
end
end