Created
February 4, 2021 13:30
-
-
Save nikopartanen/f77ab9c4a85974138b7a1c3b300965ee to your computer and use it in GitHub Desktop.
An example script to run Copius transliterator with Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an example from Niko Partanen how to use Copius transliterator from Python. | |
# The idea is to replicate the form that the website uses, and send that information | |
# there directly. For the website it essentially looks like someone would be just using | |
# it normally. | |
import requests | |
from lxml import html | |
def run_copius_transliterator(language, text, direction): | |
files = { | |
'inField': (None, text), | |
'dir': (None, direction), | |
} | |
r = requests.post(f'https://www.copius.eu/trtr.php?lang={language}', files = files) | |
tree = html.fromstring(r.content) | |
text = tree.xpath('//div[@class="trans"]/text()') | |
return(''.join(text)) | |
sentence = 'Пусьылі, пусьылі тшаксӧ, а из понды пусьыны.' | |
print(run_copius_transliterator(language = 'kom', text = sentence, direction = 'cl')) | |
print(run_copius_transliterator(language = 'kom', text = sentence, direction = 'ci')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment