marker-io / marker /ocr /utils.py
Ritvik19's picture
Add all files and directories
c8a32e7
raw
history blame contribute delete
258 Bytes
def alphanum_ratio(text):
text = text.replace(" ", "")
text = text.replace("\n", "")
alphanumeric_count = sum([1 for c in text if c.isalnum()])
if len(text) == 0:
return 1
ratio = alphanumeric_count / len(text)
return ratio