Skip to content

Commit

Permalink
refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Mar 9, 2024
1 parent c2897f6 commit 9cb9d09
Showing 1 changed file with 34 additions and 40 deletions.
74 changes: 34 additions & 40 deletions ceurws/dblp.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,54 +204,48 @@ def get_all_ceur_proceedings(
force_query(bool): if True force query
"""
query = self.qm.queriesByName["CEUR-WS all Volumes"]
cache_name = "dblp/volumes"
cache_name="dblp/volumes"
lod=self.get_lod(cache_name,"CEUR-WS all Volumes",force_query)
volumes = []
if not force_query:
lod = self.cache_manager.load(cache_name)
volumes = [DblpProceeding(**d) for d in lod]
if force_query or lod is None:
lod = self.sparql.queryAsListOfDicts(query.query)
editors = self.get_all_ceur_editors(force_query=force_query)
editorsById = {a.dblp_author_id: a for a in editors}
papers = self.get_all_ceur_papers(force_query=force_query)
papersByProceeding = {
key: list(group)
for key, group in groupby(
editors = self.get_all_ceur_editors(force_query=force_query)
editorsById = {a.dblp_author_id: a for a in editors}
papers = self.get_all_ceur_papers(force_query=force_query)
papersByProceeding = {
key: list(group)
for key, group in groupby(
papers, lambda paper: paper.dblp_proceeding_id
)
}
volumes = []
for d in lod:
if int(d.get("volume_number")) == 3000:
pass
vol_editors = []
editor_str = d.get("editor", "")
# >;< qlever quirk until 2023-12
if ">;<" in editor_str:
delim = ">;<"
else:
delim = ";"
for dblp_author_id in editor_str.split(delim):
editor = editorsById.get(dblp_author_id, None)
if editor:
vol_editors.append(editor)
volume = DblpProceeding(
dblp_publication_id=d.get("proceeding"),
volume_number=int(d.get("volume_number")),
dblp_event_id=d.get("dblp_event_id"),
title=d.get("title"),
editors=vol_editors,
papers=papersByProceeding.get(d.get("proceeding")),
)
volumes.append(volume)
)
}
for d in lod:
if int(d.get("volume_number")) == 3000:
pass
vol_editors = []
editor_str = d.get("editor", "")
# >;< qlever quirk until 2023-12
if ">;<" in editor_str:
delim = ">;<"
else:
delim = ";"
for dblp_author_id in editor_str.split(delim):
editor = editorsById.get(dblp_author_id, None)
if editor:
vol_editors.append(editor)
volume = DblpProceeding(
dblp_publication_id=d.get("proceeding"),
volume_number=int(d.get("volume_number")),
dblp_event_id=d.get("dblp_event_id"),
title=d.get("title"),
editors=vol_editors,
papers=papersByProceeding.get(d.get("proceeding")),
)
volumes.append(volume)
self.cache_manager.store(
cache_name, [dataclasses.asdict(volume) for volume in volumes]
)
volume_by_number, _errors = LOD.getLookup(volumes, "volume_number")
for number, volume in volume_by_number.items():
self.cache_manager.store(
f"dblp/Vol-{number}/metadata", dataclasses.asdict(volume)
f"dblp/Vol-{number}/metadata", volume
)
return volumes

Expand Down

0 comments on commit 9cb9d09

Please sign in to comment.