MCPcopy Index your code
hub / github.com/modelscope/FunASR / evaluate

Function evaluate

fun_text_processing/text_normalization/data_loader_utils.py:108–134  ·  view source on GitHub ↗

Evaluates accuracy given predictions and labels. Args: preds: predictions labels: labels input: optional, only needed for verbosity verbose: if true prints [input], golden labels and predictions Returns accuracy

(
    preds: List[str], labels: List[str], input: Optional[List[str]] = None, verbose: bool = True
)

Source from the content-addressed store, hash-verified

106
107
108def evaluate(
109 preds: List[str], labels: List[str], input: Optional[List[str]] = None, verbose: bool = True
110) -> float:
111 """
112 Evaluates accuracy given predictions and labels.
113
114 Args:
115 preds: predictions
116 labels: labels
117 input: optional, only needed for verbosity
118 verbose: if true prints [input], golden labels and predictions
119
120 Returns accuracy
121 """
122 acc = 0
123 nums = len(preds)
124 for i in range(nums):
125 pred_norm = clean_generic(preds[i])
126 label_norm = clean_generic(labels[i])
127 if pred_norm == label_norm:
128 acc = acc + 1
129 else:
130 if input:
131 print(f"inpu: {json.dumps(input[i])}")
132 print(f"gold: {json.dumps(label_norm)}")
133 print(f"pred: {json.dumps(pred_norm)}")
134 return acc / nums
135
136
137def training_data_to_tokens(

Callers 2

run_evaluate.pyFile · 0.90
run_evaluate.pyFile · 0.90

Calls 1

clean_genericFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…