diff options
author | Patrick Simianer <pks@pks.rocks> | 2020-08-12 07:32:06 +0200 |
---|---|---|
committer | Patrick Simianer <pks@pks.rocks> | 2020-08-12 07:32:06 +0200 |
commit | 64e8bdba930479249b8dfbc4b5d4b659a95433f0 (patch) | |
tree | e26969b03d8380ee8d2cbc1328f851772006133c /langid-polyglot | |
parent | 74e20e00dfbffdcf117778049e47acd79e320110 (diff) | |
parent | 4732fb3be94ba3f88b18295cf1c00e8c616eec73 (diff) |
Merge branch 'master' of ssh://github.com/pks/nlp_scripts
Diffstat (limited to 'langid-polyglot')
-rwxr-xr-x | langid-polyglot | 18 |
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 + |