@@ -1166,18 +1166,33 @@ def _accrual_periodicity_to_graph(self, dataset_ref, accrual_periodicity):
1166
1166
))
1167
1167
1168
1168
def _publisher_to_graph (self , dataset_ref , dataset_dict ):
1169
+ """ Supporting both FOAF.Agent (with multilingual names)
1170
+ and FOAF.Organization (with a single name)
1171
+ """
1169
1172
g = self .g
1170
1173
publisher_uri , publisher_name = \
1171
1174
dh .get_publisher_dict_from_dataset (
1172
1175
dataset_dict .get ('publisher' )
1173
1176
)
1174
- if publisher_uri :
1175
- publisher_ref = URIRef (publisher_uri )
1177
+
1178
+ # determine publisher structure FOAF.Agent or FOAF.Organization
1179
+ if isinstance (publisher_name , dict ):
1180
+ entity_type = FOAF .Agent
1181
+ publisher_ref = URIRef (publisher_uri ) if publisher_uri else BNode ()
1182
+
1183
+ g .add ((publisher_ref , RDF .type , entity_type ))
1184
+ for lang , name in publisher_name .items ():
1185
+ if name : # check if the name is not empty
1186
+ g .add ((publisher_ref , FOAF .name , Literal (name , lang = lang )))
1176
1187
else :
1177
- publisher_ref = BNode ()
1178
- g .add ((publisher_ref , RDF .type , FOAF .Organization ))
1179
- if publisher_name :
1180
- g .add ((publisher_ref , FOAF .name , Literal (publisher_name )))
1188
+ entity_type = FOAF .Organization
1189
+ publisher_ref = URIRef (publisher_uri ) if publisher_uri else BNode ()
1190
+
1191
+ g .add ((publisher_ref , RDF .type , entity_type ))
1192
+ if publisher_name :
1193
+ g .add ((publisher_ref , FOAF .name , Literal (publisher_name )))
1194
+
1195
+ # link the publisher to the dataset
1181
1196
g .add ((dataset_ref , DCT .publisher , publisher_ref ))
1182
1197
1183
1198
0 commit comments