summaryrefslogtreecommitdiff
path: root/langid-polyglot
blob: 04f6b3b71e57d37f9bb5f7951acbad3cf08a73e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python3

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