File size: 1,089 Bytes
1165618
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st

from visual_eval.evaluator import HebrewTextNormalizer
from visual_eval.visualization import render_visualize_jiwer_result_html
from substitutions_visualizer import visualize_substitutions
from utils import display_rtl

norm = HebrewTextNormalizer()


@st.fragment
def manual_eval_viz(ref, hyp):
    show_subs = st.toggle("Show Substitutions", value=False)
    norm_texts = st.toggle("Normalize Texts", value=True)
    if norm_texts:
        ref = norm(ref)
        hyp = norm(hyp)
    html = render_visualize_jiwer_result_html(ref, hyp)
    display_rtl(html)
    if show_subs:
        visualize_substitutions(ref, hyp)


def render_manual_eval():
    col_ref, col_hyp = st.columns([1, 1], gap="small")
    ref = None
    hyp = None
    with col_ref:
        ref = st.text_area("Reference Text", height=100)
    with col_hyp:
        hyp = st.text_area("Hypothesis Text", height=100)

    if st.button("Visualize"):
        if hyp and ref:
            manual_eval_viz(ref, hyp)
        else:
            st.error("Please enter both reference and hypothesis text.")