Skip to content
Snippets Groups Projects
Commit 45061591 authored by vvye's avatar vvye
Browse files

Fix another bug

parent 5f9d59e8
No related branches found
No related tags found
No related merge requests found
......@@ -42,13 +42,16 @@ def mentioned_dates_by_sentence(filename, pub_date):
if not sentence.strip():
continue
dates_for_this_sentence = []
root = ET.fromstring('<root>' + sentence + '</root>')
for child in root:
if child.tag == 'TIMEX3' and child.attrib['type'] in ['DATE', 'TIME']:
match = date_format_regex.match(child.attrib['value'])
if match is not None:
dates_for_this_sentence.append(match[0])
dates_by_sentences.append(dates_for_this_sentence)
try:
root = ET.fromstring('<root>' + sentence + '</root>')
for child in root:
if child.tag == 'TIMEX3' and child.attrib['type'] in ['DATE', 'TIME']:
match = date_format_regex.match(child.attrib['value'])
if match is not None:
dates_for_this_sentence.append(match[0])
dates_by_sentences.append(dates_for_this_sentence)
except ET.ParseError:
continue
# change directory back
os.chdir(working_dir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment