
| Current Path : /usr/local/lib/python3.8/dist-packages/pdf/string/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //usr/local/lib/python3.8/dist-packages/pdf/string/get_numeric_ratio.py |
def get_numeric_ratio(s): """ gets the ratio of numeric characters to the total alphanumerics :type s: str :rtype: float or NoneType """ num_numeric = 0 num_alphabetic = 0 if len(s) == 0: return None else: for character in s: if character.isnumeric(): num_numeric += 1 elif character.isalpha(): num_alphabetic += 1 return num_numeric / (num_numeric + num_alphabetic)