Skip to content

Commit

Permalink
improve parser speed
Browse files Browse the repository at this point in the history
  • Loading branch information
caseydm committed Feb 13, 2025
1 parent 7e94173 commit 566619f
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions parseland_lib/parse_publisher_authors_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,23 @@ def has_affs(parsed):

for cls in PublisherParser.__subclasses__():
parser = cls(soup)
if parser.authors_found():
if parser.is_publisher_specific_parser():
both_conditions_parsers.append(parser)
else:
authors_found_parsers.append(parser)

for parser in both_conditions_parsers:
try:
parsed = parser.parse()
if has_affs(parsed):
return parsed
except Exception as e:
if parser.authors_found():
parsed = parser.parse()
if parser.is_publisher_specific_parser():
both_conditions_parsers.append((parser, parsed))
else:
authors_found_parsers.append((parser, parsed))
except Exception:
continue

for parser in authors_found_parsers:
try:
parsed = parser.parse()
if has_affs(parsed):
return parsed
except Exception as e:
continue
for parser, parsed in both_conditions_parsers:
if has_affs(parsed):
return parsed

for parser, parsed in authors_found_parsers:
if has_affs(parsed):
return parsed

generic_parser = GenericPublisherParser(soup)
if generic_parser.authors_found():
Expand Down

0 comments on commit 566619f

Please sign in to comment.