Skip to content

Commit

Permalink
citations opr index v1
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanhb committed Sep 11, 2023
1 parent 175cd4a commit b31f2b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion index_v1.hf
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ WHERE {
#type operation
#dois str(\"?10\..+[^_\"]((__|\" \")10\..+[^_])*\"?)
#preprocess lower(dois) --> split_dois2omids(dois)
#postprocess metadata()
#postprocess metadata(val)
#method get
#description This operation retrieves the bibliographic metadata for each of the bibliographic entities identified by one or more input DOIs.

Expand Down Expand Up @@ -529,6 +529,7 @@ SELECT ?val (count(?oci) as ?citation_count) (GROUP_CONCAT(?citing; separator=";
#type operation
#doi str(10\..+)
#preprocess lower(doi) --> doi2omid(doi)
#postprocess metadata(cited)
#method get
#description This operation retrieves the citation data for all the references appearing in the reference lists of other citing works to the bibliographic entity identified by the input DOI, that constitute the incoming citations of that identified bibliographic entity.

Expand Down
23 changes: 14 additions & 9 deletions indexapi_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ def __get_omid_of_doi(s):
return ""

def metadata(res, *args):
# doi, reference, citation_count
header = res[0]
entity_field = header.index("val")
field_idx = []
if len(args) > 0:
for field in args:
field_idx.append(header.index(field))

additional_fields = ["author", "year", "title",
"source_title", "volume", "issue", "page", "source_id"]

Expand All @@ -135,14 +138,16 @@ def metadata(res, *args):
rows_to_remove = []

for row in res[1:]:
# org value: <https://w3id.org/oc/meta/br/06NNNNNN>
entity = row[entity_field][1].split("oc/meta/")[1][:-1]

r = __ocmeta_parser(entity,"omid")
if r is None or all([i in ("", None) for i in r]):
rows_to_remove.append(row)
else:
row.extend(r)
for f in field_idx:
# org value: <https://w3id.org/oc/meta/br/06NNNNNN>
entity = row[f][1].split("oc/meta/")[1][:-1]

r = __ocmeta_parser(entity,"omid")
if r is None or all([i in ("", None) for i in r]):
rows_to_remove.append(row)
else:
row.extend(r)

for row in rows_to_remove:
res.remove(row)
Expand Down

0 comments on commit b31f2b7

Please sign in to comment.