Upload app.py
Browse files
app.py
CHANGED
|
@@ -69,7 +69,9 @@ def ali(ref, hyp, col=80, remove_punc=False, file=None):
|
|
| 69 |
def process_ours(path):
|
| 70 |
with open(path) as f:
|
| 71 |
ours = f.read()
|
|
|
|
| 72 |
ours = [i.split('\u3000', maxsplit=1)[-1] for i in ours.splitlines()]
|
|
|
|
| 73 |
ours = ' '.join(ours)
|
| 74 |
return ours
|
| 75 |
|
|
@@ -82,18 +84,18 @@ def process_theirs(path):
|
|
| 82 |
if theirs[i].startswith('會議記錄:'):
|
| 83 |
break
|
| 84 |
i+=1
|
| 85 |
-
theirs = theirs[i:]
|
| 86 |
-
transcript = ''
|
| 87 |
-
for i in range(0, len(theirs), 4):
|
| 88 |
-
|
| 89 |
-
|
| 90 |
return transcript
|
| 91 |
|
| 92 |
def compare_transcripts(ours_file, theirs_file, remove_punc, number_box):
|
| 93 |
ours = process_ours(ours_file)
|
| 94 |
theirs = process_theirs(theirs_file)
|
| 95 |
output = io.StringIO()
|
| 96 |
-
ali(theirs, ours, remove_punc=remove_punc, file=output, col=int(number_box))
|
| 97 |
return output.getvalue()
|
| 98 |
|
| 99 |
custom_css = """
|
|
@@ -104,7 +106,7 @@ textarea[data-testid="textbox"] {
|
|
| 104 |
|
| 105 |
with gr.Blocks(title="Transcript Alignment Viewer",css=custom_css) as demo:
|
| 106 |
gr.Markdown("## Transcript Alignment Viewer")
|
| 107 |
-
gr.Markdown("
|
| 108 |
|
| 109 |
with gr.Row(equal_height=True):
|
| 110 |
ours_file = gr.File(label="Our Transcript", file_types=[".txt"], scale=1)
|
|
|
|
| 69 |
def process_ours(path):
|
| 70 |
with open(path) as f:
|
| 71 |
ours = f.read()
|
| 72 |
+
print(ours)
|
| 73 |
ours = [i.split('\u3000', maxsplit=1)[-1] for i in ours.splitlines()]
|
| 74 |
+
print(ours)
|
| 75 |
ours = ' '.join(ours)
|
| 76 |
return ours
|
| 77 |
|
|
|
|
| 84 |
if theirs[i].startswith('會議記錄:'):
|
| 85 |
break
|
| 86 |
i+=1
|
| 87 |
+
theirs = theirs[i+1:]
|
| 88 |
+
transcript = ' '.join(theirs)
|
| 89 |
+
# for i in range(0, len(theirs), 4):
|
| 90 |
+
# text = (theirs[i+2])
|
| 91 |
+
# transcript += text
|
| 92 |
return transcript
|
| 93 |
|
| 94 |
def compare_transcripts(ours_file, theirs_file, remove_punc, number_box):
|
| 95 |
ours = process_ours(ours_file)
|
| 96 |
theirs = process_theirs(theirs_file)
|
| 97 |
output = io.StringIO()
|
| 98 |
+
ali(theirs.replace(' ', ''), ours.replace(' ', ''), remove_punc=remove_punc, file=output, col=int(number_box))
|
| 99 |
return output.getvalue()
|
| 100 |
|
| 101 |
custom_css = """
|
|
|
|
| 106 |
|
| 107 |
with gr.Blocks(title="Transcript Alignment Viewer",css=custom_css) as demo:
|
| 108 |
gr.Markdown("## Transcript Alignment Viewer")
|
| 109 |
+
gr.Markdown("上傳請確認你用的是 `不分段會議紀錄`")
|
| 110 |
|
| 111 |
with gr.Row(equal_height=True):
|
| 112 |
ours_file = gr.File(label="Our Transcript", file_types=[".txt"], scale=1)
|