Skip to content

Commit

Permalink
Merge pull request #135 from MaRDI4NFDI/reitnroduce_contributor
Browse files Browse the repository at this point in the history
reintroduce contributor and creator
  • Loading branch information
LizzAlice authored Mar 28, 2024
2 parents d875e2d + 93b7d4e commit 74a8ef8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
15 changes: 14 additions & 1 deletion mardi_importer/mardi_importer/openml/OpenMLDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(
dataset_id,
version,
creators,
contributors,
collection_date,
upload_date,
license,
Expand All @@ -68,6 +69,7 @@ def __init__(
self.dataset_id = str(dataset_id) #done
self.version = version #done
self.creators = creators
self.contributors = contributors
self.collection_date = collection_date
self.upload_date = upload_date
self.license = license
Expand Down Expand Up @@ -109,13 +111,24 @@ def insert_claims(self):
prop_nr = self.api.get_local_id_by_label("dataset version identifier", "property")
self.item.add_claim(prop_nr, str(self.version))
if self.creators and self.creators != "None":
#object has role
qualifier = [self.api.get_claim("wdt:P3831", "wd:Q59275219")]
creator_claims = []
if not isinstance(self.creators, list):
self.creators = [self.creators]
for c in self.creators:
claim = self.api.get_claim("wdt:P2093", c)
claim = self.api.get_claim("wdt:P2093", c, qualifiers=qualifier)
creator_claims.append(claim)
self.item.add_claims(creator_claims)
if self.contributors and self.contributors != "None":
qualifier = [self.api.get_claim("wdt:P3831", "wd:Q20204892")]
contributor_claims = []
if not isinstance(self.contributors, list):
self.contributors = [self.contributors]
for c in self.contributors:
claim = self.api.get_claim("wdt:P2093", c, qualifiers=qualifier)
contributor_claims.append(claim)
self.item.add_claims(contributor_claims)
if self.collection_date and self.collection_date != "None":
prop_nr = self.api.get_local_id_by_label("collection date", "property")
self.item.add_claim(prop_nr, str(self.collection_date))
Expand Down
3 changes: 2 additions & 1 deletion mardi_importer/mardi_importer/openml/OpenMLSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create_local_entities(self):

def pull(self):
dataset_dict = {"name": [], "dataset_id": [], "version": [], "creators": [],
"collection_date": [], "upload_date": [],
"contributors" : [], "collection_date": [], "upload_date": [],
"license": [], "url":[], "default_target_attribute":[], "row_id_attribute":[],
"tags":[], "original_data_url":[], "paper_url":[],
"md5_checksum": [], "num_binary_features":[],
Expand All @@ -67,6 +67,7 @@ def pull(self):
dataset_dict["dataset_id"].append(did)
dataset_dict["version"].append(ds.version)
dataset_dict["creators"].append(ds.creator)
dataset_dict["contributors"].append(ds.contributor)
dataset_dict["collection_date"].append(ds.collection_date)
dataset_dict["upload_date"].append(ds.upload_date)
dataset_dict["license"].append(ds.licence)
Expand Down
2 changes: 1 addition & 1 deletion mardi_importer/mardi_importer/openml/new_entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"description": "OpenML semantic tag"
},
{
"label": "text & Literature",
"label": "Text & Literature",
"description": "OpenML semantic tag"
},
{
Expand Down
5 changes: 4 additions & 1 deletion mardi_importer/mardi_importer/openml/wikidata_entities.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ Q6938433
Q13442814
Q185235
P459
P11238
P11238
P3831
Q59275219
Q20204892

0 comments on commit 74a8ef8

Please sign in to comment.