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!
2 files
+ 34
32
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 4
8
# -*- coding: utf-8 -*-
import re
import cv2
import numpy as np
from PIL import Image
@@ -18,17 +20,11 @@ def split_text(text, level, word_separators, line_separators):
offset = 0
# split into words
elif level == "word":
main_sep = word_separators[0]
for other_sep in word_separators[1:]:
text = text.replace(other_sep, main_sep)
text_split = text.split(main_sep)
text_split = re.split(word_separators, text)
offset = 1
# split into lines
elif level == "line":
main_sep = line_separators[0]
for other_sep in line_separators[1:]:
text = text.replace(other_sep, main_sep)
text_split = text.split(main_sep)
text_split = re.split(line_separators, text)
offset = 1
else:
logger.error("Level should be either 'char', 'word', or 'line'")
Loading