Is there a way (either a trained model or a deterministic function) in python3 that returns the length of numbering in a title. For example,
"I. This is a big title" ---> length=len("I.")=2
"1.10 This a small title" ---> length=len("1.10")=4
"A)b) This is another title" ---> length=len("A)b)")=4
"C.2 This is a regular title" ---> length=len("C.2")=3
"This is not a title" ---> length=0
etc....
?
I wrote a little function that uses regex to detect if a string begins with a numbering:
pattern = r'(^IX|IV|VI{0,3}|I{1,3})(\s|-|\s-|\)|\s\)|\.|\s\.|/|\s/|–|\s–)'
m_romans = re.search(pattern, text)
m_letters = re.search(r'^([a-zA-Z])(\s|-|\s-|\)|\s\)|\.|\s\.|/|\s/|–|\s–)', text)
m_digits = re.search(r'^(\d)(\s|-|\s-|\)|\s\)|\.|\s\.|/|\s/|–|\s–)', text)
Maybe regex can help ?