summaryrefslogtreecommitdiff
path: root/langid-polyglot
diff options
context:
space:
mode:
authorPatrick Simianer <patrick@lilt.com>2020-02-03 15:25:42 +0000
committerPatrick Simianer <patrick@lilt.com>2020-02-03 15:25:42 +0000
commit276b954705f7a9d46c4241aa25e6bb19be8716e1 (patch)
tree36b4d19c0818093b105517ddd502d898a8b03e06 /langid-polyglot
parent0ff116339aff9b421e4ca5d4680b3981530d9b99 (diff)
langid-polyglot
Diffstat (limited to 'langid-polyglot')
-rwxr-xr-xlangid-polyglot18
1 files changed, 18 insertions, 0 deletions
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
+