Refactor fetch_holidays.py
This commit is contained in:
parent
aaa44da716
commit
b04a46ac71
|
|
@ -5,6 +5,7 @@ import argparse
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
|
from itertools import chain
|
||||||
from typing import Iterator, List, Optional, Tuple
|
from typing import Iterator, List, Optional, Tuple
|
||||||
|
|
||||||
import bs4
|
import bs4
|
||||||
|
|
@ -157,14 +158,13 @@ class SentenceParser:
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
text = text.replace('(', '(').replace(')', ')')
|
text = text.replace('(', '(').replace(')', ')')
|
||||||
for method in self.date_extraction_methods:
|
for i in chain(method(self, text) for method in self.date_extraction_methods):
|
||||||
for i in method(self, text):
|
count += 1
|
||||||
count += 1
|
is_seen = i in self.parent.date_history
|
||||||
is_seen = i in self.parent.date_history
|
self.parent.date_history.append(i)
|
||||||
self.parent.date_history.append(i)
|
if is_seen:
|
||||||
if is_seen:
|
continue
|
||||||
continue
|
yield i
|
||||||
yield i
|
|
||||||
|
|
||||||
if not count:
|
if not count:
|
||||||
raise NotImplementedError(text)
|
raise NotImplementedError(text)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user