function to detect days
This commit is contained in:
parent
2feb6219f7
commit
0b9fe19b3a
@ -28,8 +28,38 @@ class Extractor(ABC):
|
||||
else:
|
||||
return start_day
|
||||
|
||||
def guess_startswith(text, strs):
|
||||
t = remove_accents(text).lower()
|
||||
for i, s in enumerate(strs):
|
||||
if t.startswith(s):
|
||||
return i + 1
|
||||
return None
|
||||
|
||||
def guess_day_name(text, exact=False):
|
||||
if exact:
|
||||
return Extractor.guess_startswith(text, [
|
||||
"lundi",
|
||||
"mardi",
|
||||
"mercredi",
|
||||
"jeudi",
|
||||
"vendredi",
|
||||
"samedi",
|
||||
"dimanche",
|
||||
])
|
||||
else:
|
||||
return Extractor.guess_startswith(text, [
|
||||
"lun",
|
||||
"mar",
|
||||
"mer",
|
||||
"jeu",
|
||||
"ven",
|
||||
"sa",
|
||||
"di",
|
||||
])
|
||||
|
||||
|
||||
def guess_month(text):
|
||||
mths = [
|
||||
return Extractor.guess_startswith(text, [
|
||||
"jan",
|
||||
"fe",
|
||||
"mar",
|
||||
@ -42,12 +72,7 @@ class Extractor(ABC):
|
||||
"oct",
|
||||
"nov",
|
||||
"dec",
|
||||
]
|
||||
t = remove_accents(text).lower()
|
||||
for i, m in enumerate(mths):
|
||||
if t.startswith(m):
|
||||
return i + 1
|
||||
return None
|
||||
])
|
||||
|
||||
def parse_french_date(text):
|
||||
# format NomJour Numero Mois Année
|
||||
|
Loading…
Reference in New Issue
Block a user