File size: 258 Bytes
c8a32e7
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
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