diff importFromOpenMind/importer/ismi2model.py @ 23:45a823b5bf33

updated ismi2model importer and model2neo4j exporter.
author casties
date Wed, 23 Sep 2015 19:18:59 +0200
parents ca1e02a2a9c4
children 5bdcb5805d29
line wrap: on
line diff
--- a/importFromOpenMind/importer/ismi2model.py	Wed Sep 23 11:54:22 2015 +0200
+++ b/importFromOpenMind/importer/ismi2model.py	Wed Sep 23 19:18:59 2015 +0200
@@ -1,6 +1,7 @@
 import urllib.request
 import json
 import networkx
+import sys
 
 ## configure behaviour
 
@@ -110,7 +111,7 @@
             # date attribute
             key = att['name']
             val = att['ov']
-            #print("don't know what to do with date: %s=%s"%(key,val))
+            print("don't know what to do with date: %s=%s"%(key,val))
             
         elif ct == 'old':
             # ignore attribute
@@ -230,7 +231,7 @@
                 nx_graph.node[tar_id][att_name] = nx_graph.node[src_id]['label']
         
         # create relation with type
-        nx_rel = nx_graph.add_edge(src_id, tar_id, type=fixName(rel_name))
+        nx_rel = nx_graph.add_edge(src_id, tar_id, type=fixName(rel_name), ismi_id=rel_id)
         
         nx_relations[rel_id] = nx_rel
         
@@ -289,15 +290,22 @@
     relationsFromRels(ismi_relations, nx_nodes)
 
 
-# In[120]:
+## main
+
+print("Copy graph from OpenMind to networkx pickle")
 
+# parse command line parameters
+if len(sys.argv) > 1:
+    output_fn = sys.argv[1]
+
+# import everything
+print("Reading graph from OpenMind at %s"%baseURL)
 importAllEnts(ismi_defs)
 #importAllEnts(['TEXT'])
 
 print("Graph info: %s"%networkx.info(nx_graph))
-print("Number of nodes: %s"%networkx.number_of_nodes(nx_graph))
-print("Number of edges: %s"%networkx.number_of_edges(nx_graph))
 #print(" nodes:%s"%repr(nx_graph.nodes(data=True)))
+
 # export pickle
 networkx.write_gpickle(nx_graph, output_fn)
-print("Wrote file %s"%output_fn)
+print("Wrote networkx pickle file %s"%output_fn)