File size: 1,312 Bytes
b5f1359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import zipfile
import requests
import subprocess

# Downloading the zip file
url = 'https://github.com/isi-nlp/uroman/archive/refs/tags/v1.2.8.zip'
zip_filename = 'uroman.zip'
with open(zip_filename, 'wb') as zip_file:
    response = requests.get(url)
    zip_file.write(response.content)

# Unzipping the downloaded file
with zipfile.ZipFile(zip_filename, 'r') as zip_ref:
    zip_ref.extractall()

# Function to call the unzipped code
def uroman(input_string, language=None, chart=False):
    script_path = 'C:/Users/caleb/Bible Translation Project/guidance/uroman-1.2.8/bin/uroman.pl'  # Adjust if necessary
    command = ["perl", script_path]

    # Add language flag if specified
    if language:
        command.extend(["-l", language])
    
    # Add chart flag if specified
    if chart:
        command.append("--chart")
    
    process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout, stderr = process.communicate(input=input_string.encode())

    if process.returncode != 0:
        # There was an error
        print(f"Error code {process.returncode}: {stderr.decode()}")
        return None

    # Return the output as a string
    return stdout.decode()

# Example usage
# print(uroman("γ‚γŸγ—γ―γ«γ»γ‚“γ˜γ‚“γ§γ™"))