polyglot
polyglot copied to clipboard
No handlers could be found for logger "polyglot.detect.base"
I wrote this simple script that takes a source file and transliterate it into the target file specified from the arguments:
#!/usr/bin/env python
import io
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from polyglot.text import Text
args = sys.argv[1:]
with io.open(args[0], 'r', encoding='utf-8') as infile:
with io.open(args[1], 'w', encoding='utf-8') as outfile:
target=''
for line in infile:
text = Text(line)
for word in text.transliterate("en"):
target += word + " "
target += "\n"
outfile.write(target)
so you will use it like python transliterate.py source.txt target.txt
. When I run it I get a warning
No handlers could be found for logger "polyglot.detect.base"
and the transliteration works ok. In this case the input file was Tamil
and I have downloaded the models:
polyglot download embeddings2.ta transliteration2.ta