changeset 34:74dfaed3600b

keep relation attributes but no attributes from openmind. change relation type attribute to '_type' too.
author casties
date Tue, 02 Feb 2016 15:16:29 +0100
parents 7e2e344c3b87
children d535f11a0d81
files importFromOpenMind/importer/ismi2model.py importFromOpenMind/importer/model2model.py importFromOpenMind/importer/model2neo4j.py
diffstat 3 files changed, 13 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- 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
         
--- 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:
--- 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