guess_month méthode de classe

This commit is contained in:
Jean-Marie Favreau 2024-10-12 17:55:01 +02:00
parent 654314a61b
commit de4b54baa4

View File

@ -27,7 +27,7 @@ class Extractor(ABC):
else: else:
return start_day return start_day
def guess_month(self, text): def guess_month(text):
mths = [ mths = [
"jan", "jan",
"fe", "fe",
@ -55,14 +55,14 @@ class Extractor(ABC):
) )
if m: if m:
day = m.group(1) day = m.group(1)
month = self.guess_month(m.group(2)) month = Extractor.guess_month(m.group(2))
year = m.group(3) year = m.group(3)
else: else:
# format Numero Mois Annee # format Numero Mois Annee
m = re.search("([0-9]+)[er]*[ ]*([a-zA-ZéÉûÛ:.]+)[ ]*([0-9]+)", text) m = re.search("([0-9]+)[er]*[ ]*([a-zA-ZéÉûÛ:.]+)[ ]*([0-9]+)", text)
if m: if m:
day = m.group(1) day = m.group(1)
month = self.guess_month(m.group(2)) month = Extractor.guess_month(m.group(2))
year = m.group(3) year = m.group(3)
else: else:
# format Numero Mois Annee # format Numero Mois Annee