Skip to content
Snippets Groups Projects

Compute confidence scores by char, word or line

Merged Solene Tarride requested to merge 33-compute-confidence-scores-by-char-word-or-line into main
All threads resolved!
1 file
+ 4
7
Compare changes
  • Side-by-side
  • Inline
+ 4
7
@@ -218,14 +218,11 @@ def compute_prob_by_separator(characters, probabilities, separator):
# match anything except separators, get start and end index
pattern = re.compile(f"[^{separator.pattern}]+")
matches = [(m.start(), m.end()) for m in re.finditer(pattern, characters)]
return [
np.mean(probabilities[start:end])
for (start, end) in matches
]
# Iterate over text pieces and compute mean confidence
probs = []
for match in matches:
start = match[0]
end = match[1]
probs.append(np.mean(probabilities[start:end]))
return probs
def run(
Loading