CalebKoster/Translation_Note_Alignment
0
1import os2import zipfile3import requests4import subprocess5 6# Downloading the zip file7url = 'https://github.com/isi-nlp/uroman/archive/refs/tags/v1.2.8.zip'8zip_filename = 'uroman.zip'9with open(zip_filename, 'wb') as zip_file:10 response = requests.get(url)11 zip_file.write(response.content)12 13# Unzipping the downloaded file14with zipfile.ZipFile(zip_filename, 'r') as zip_ref:15 zip_ref.extractall()16 17# Function to call the unzipped code18def uroman(input_string, language=None, chart=False):19 script_path = 'C:/Users/caleb/Bible Translation Project/guidance/uroman-1.2.8/bin/uroman.pl' # Adjust if necessary20 command = ["perl", script_path]21 22 # Add language flag if specified23 if language:24 command.extend(["-l", language])25 26 # Add chart flag if specified27 if chart:28 command.append("--chart")29 30 process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)31 stdout, stderr = process.communicate(input=input_string.encode())32 33 if process.returncode != 0:34 # There was an error35 print(f"Error code {process.returncode}: {stderr.decode()}")36 return None37 38 # Return the output as a string39 return stdout.decode()40 41# Example usage42# print(uroman("わたしはにほんじんです"))43 44 