# HG changeset patch # User casties # Date 1454422589 -3600 # Node ID 74dfaed3600bf312fdbb1c1017944ea428c8f7ab # Parent 7e2e344c3b8750839c679f4246ec9cdb5b931405 keep relation attributes but no attributes from openmind. change relation type attribute to '_type' too. diff -r 7e2e344c3b87 -r 74dfaed3600b importFromOpenMind/importer/ismi2model.py --- a/importFromOpenMind/importer/ismi2model.py Tue Feb 02 14:41:08 2016 +0100 +++ b/importFromOpenMind/importer/ismi2model.py Tue Feb 02 15:16:29 2016 +0100 @@ -25,7 +25,7 @@ # name of type attribute node_type_attribute = '_type' -rel_type_attribute = 'type' +rel_type_attribute = '_type' entsURL=baseURL+"method=get_ents&oc=%s" @@ -56,13 +56,6 @@ def fixName(name, is_src_rel=False, is_tar_rel=False, att_from_rel=False): - # these are too embarrassing... - if 'FLORUIT' in name: - name = name.replace('FLORUIT', 'FLOURISH') - - elif 'floruit' in name: - name = name.replace('floruit', 'flourish') - if is_src_rel: #name = name + '>' pass @@ -227,10 +220,14 @@ if not tar_id in nodes: print("ERROR: relation %s tar node %s missing!"%(rel_id,tar_id)) continue - + + # TODO: what about attributes of relation? + if len(rel['atts']) > 0: + print("INFO: relation with attributes! name=%s id=%s atts=%s"%(rel_name, rel_id, repr(rel['atts']))) + # create relation with type rel_atts = {rel_type_attribute: fixName(rel_name), 'ismi_id': rel_id} - nx_rel = nx_graph.add_edge(src_id, tar_id, rel_atts) + nx_rel = nx_graph.add_edge(src_id, tar_id, attr_dict=rel_atts) nx_relations[rel_id] = nx_rel diff -r 7e2e344c3b87 -r 74dfaed3600b importFromOpenMind/importer/model2model.py --- a/importFromOpenMind/importer/model2model.py Tue Feb 02 14:41:08 2016 +0100 +++ b/importFromOpenMind/importer/model2model.py Tue Feb 02 15:16:29 2016 +0100 @@ -32,7 +32,7 @@ # name of type attribute node_type_attribute = '_type' -rel_type_attribute = 'type' +rel_type_attribute = '_type' def fixName(name, is_src_rel=False, is_tar_rel=False, att_from_rel=False): @@ -182,12 +182,13 @@ for nx_edge in edges: (nx_src, nx_tar) = nx_edge # get attributes of edge - rel_attrs = nx_graph.edge[nx_src][nx_tar][0] + rel_attrs = nx_graph.edge[nx_src][nx_tar][0][:] rel_type = rel_attrs[rel_type_attribute] rel_id = rel_attrs['ismi_id'] # create new relation - invrel_atts = {rel_type_attribute: fixName(rel_type, is_tar_rel=True), 'ismi_id': -rel_id} - nx_graph.add_edge(nx_tar, nx_src, invrel_atts) + rel_attrs[rel_type_attribute] = fixName(rel_type, is_tar_rel=True) + rel_attrs['ismi_id': -rel_id] + nx_graph.add_edge(nx_tar, nx_src, attr_dict=invrel_atts) cnt += 1 if cnt % 100 == 0: diff -r 7e2e344c3b87 -r 74dfaed3600b importFromOpenMind/importer/model2neo4j.py --- a/importFromOpenMind/importer/model2neo4j.py Tue Feb 02 14:41:08 2016 +0100 +++ b/importFromOpenMind/importer/model2neo4j.py Tue Feb 02 15:16:29 2016 +0100 @@ -15,7 +15,7 @@ # name of type attribute node_type_attribute = '_type' -rel_type_attribute = 'type' +rel_type_attribute = '_type' ## setup