Skip to content

Commit

Permalink
Merge pull request #140 from MaRDI4NFDI/zbmath_changes
Browse files Browse the repository at this point in the history
changed zbmath to include arxiv id
  • Loading branch information
LizzAlice authored Apr 25, 2024
2 parents a5fe09f + ea4419e commit 59e881a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion mardi_importer/mardi_importer/openml/OpenMLSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setup(self):
# Import entities from Wikidata
filename = self.filepath + "/wikidata_entities.txt"
self.integrator.import_entities(filename=filename)
self.create_local_entities()
#self.create_local_entities()
# self.de_number_prop = self.integrator.get_local_id_by_label(
# "zbMATH DE Number", "property"
# )
Expand Down
4 changes: 1 addition & 3 deletions mardi_importer/mardi_importer/zbmath/ZBMathAuthor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def init_item(self):
# instance of: human
item.add_claim("wdt:P31", "wd:Q5")
profile_prop = self.api.get_local_id_by_label("MaRDI profile type", "property")
profile_target = self.api.get_local_id_by_label("MaRDI person profile", "item")[
0
]
profile_target = self.api.get_local_id_by_label("MaRDI person profile", "item")[0]
item.add_claim(profile_prop, profile_target)
if self.zbmath_author_id:
# if self.name:
Expand Down
27 changes: 21 additions & 6 deletions mardi_importer/mardi_importer/zbmath/ZBMathPublication.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ZBMathPublication:
creation date of entry
zbl_id:
zbl_id
arxiv_id:
arxiv_id
review_text:
review text
reviewer:
Expand Down Expand Up @@ -49,6 +51,7 @@ def __init__(
links,
creation_date,
zbl_id,
arxiv_id,
review_text,
reviewer,
classifications,
Expand All @@ -60,9 +63,12 @@ def __init__(
self.api = integrator
self.title = title
self.zbl_id = zbl_id
self.arxiv_id = arxiv_id
self.QID = None
self.language = language
self.doi = doi.lower()
self.doi = doi
if self.doi:
self.doi = self.doi.lower()
self.authors = authors
self.journal = journal
self.time = time
Expand Down Expand Up @@ -100,6 +106,8 @@ def insert_claims(self):
# zbmath document id
if self.zbl_id:
self.item.add_claim("wdt:P894", self.zbl_id)
if self.arxiv_id:
self.item.add_claim("wdt:P818", self.arxiv_id)
if self.doi:
self.item.add_claim("wdt:P356", self.doi)
author_claims = []
Expand Down Expand Up @@ -160,17 +168,24 @@ def exists(self):
# instance of scholarly article
if self.title:
self.QID = self.item.is_instance_of_with_property(
"wd:Q13442814", "P1451", self.de_number
"wd:Q13442814", self.de_number_prop, self.de_number
)
if not self.QID:
if self.arxiv_id:
self.QID = self.item.is_instance_of_with_property(
"wd:Q13442814", "wdt:P818", self.arxiv_id)
else:
QID_list = self.api.search_entity_by_value(
self.de_number_prop, self.de_number
)
if not QID_list:
self.QID = None
else:
# should not be more than one
self.QID = QID_list[0]
if self.arxiv_id:
QID_list = self.api.search_entity_by_value("wdt:P818", self.arxiv_id)
if not QID_list:
self.QID = None
return(self.QID)
# should not be more than one
self.QID = QID_list[0]
return self.QID

def update(self):
Expand Down
13 changes: 10 additions & 3 deletions mardi_importer/mardi_importer/zbmath/ZBMathSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def setup(self):
# Import entities from Wikidata
filename = self.filepath + "/wikidata_entities.txt"
self.integrator.import_entities(filename=filename)
self.create_local_entities()
#self.create_local_entities()
self.de_number_prop = self.integrator.get_local_id_by_label(
"zbMATH DE Number", "property"
)
Expand All @@ -104,8 +104,9 @@ def create_local_entities(self):
item = self.integrator.item.new()
item.labels.set(language="en", value=item_element["label"])
item.descriptions.set(language="en", value=item_element["description"])
for key, value in item_element["claims"].items():
item.add_claim(key, value=value)
if "claims" in item_element:
for key, value in item_element["claims"].items():
item.add_claim(key, value=value)
if not item.exists():
item.write()

Expand Down Expand Up @@ -416,6 +417,11 @@ def push(self):
links = [
x.strip() for x in links if (pattern.match(x) and "http" in x)
]
arxiv_prefix = "https://arxiv.org/abs/"
arxiv_id = None
for l in links:
if arxiv_prefix in l:
arxiv_id = l.removeprefix(arxiv_prefix)
else:
links = []

Expand Down Expand Up @@ -523,6 +529,7 @@ def push(self):
links=links,
creation_date=creation_date,
zbl_id=zbl_id,
arxiv_id=arxiv_id,
review_text=review_text,
reviewer=reviewer,
classifications=classifications,
Expand Down
9 changes: 7 additions & 2 deletions mardi_importer/mardi_importer/zbmath/new_entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
"datatype": "external-id"
},
{
"label": "zbMATH keyword string",
"label": "zbMATH Keywords",
"description": "keyword string from zbMATH",
"datatype": "string"
}
],
"items": []
"items": [
{
"label": "MaRDI person profile",
"description": "type of MaRDI profile"
}
]
}

0 comments on commit 59e881a

Please sign in to comment.