|
from styleformer import Styleformer |
|
import torch |
|
import warnings |
|
|
|
warnings.filterwarnings("ignore") |
|
import gradio as gr |
|
|
|
|
|
|
|
def para1(source_sentences): |
|
choices = "Active to passive", |
|
sf = Styleformer(style=2) |
|
sentance1 = list(source_sentences.split(".")) |
|
output_sentance = [] |
|
for source_sentence in sentance1: |
|
target_sentence = sf.transfer(source_sentence) |
|
if target_sentence is not None: |
|
output_sentance.append(target_sentence) |
|
|
|
else: |
|
output_sentance.append(target_sentence) |
|
|
|
output_sentance.append(target_sentence) |
|
res = [i for i in output_sentance if i is not None] |
|
|
|
|
|
final = "" |
|
for value in res: |
|
joint_value = "".join(value) |
|
if final == "": |
|
final += joint_value |
|
else: |
|
final = f"{final}.{joint_value}" |
|
final = final.replace("..", ".") |
|
new_output = final.replace('Active to passive:', "") |
|
|
|
return new_output |
|
|
|
iface = gr.Interface(fn=para1, inputs=[gr.inputs.Textbox(lines=5)], outputs="text") |
|
if __name__ == "__main__": |
|
iface.launch(debug=True) |