From 276b954705f7a9d46c4241aa25e6bb19be8716e1 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Mon, 3 Feb 2020 15:25:42 +0000 Subject: langid-polyglot --- langid-polyglot | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 langid-polyglot (limited to 'langid-polyglot') diff --git a/langid-polyglot b/langid-polyglot new file mode 100755 index 0000000..0b0b20c --- /dev/null +++ b/langid-polyglot @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import polyglot +from polyglot.detect import Detector +import fileinput + +for line in fileinput.input(): + try: + for lang in Detector(line).languages: + if lang.confidence > 80.0: + print(lang.confidence) + else: + print("??") + break + except polyglot.detect.base.UnknownLanguage: + print("??") + pass + -- cgit v1.2.3