Commit 74b8dae7 authored by delanoe's avatar delanoe

[GRAPH] Graphs saved with distance and bridgeness parameters.

parent bb1e553b
......@@ -38,8 +38,10 @@ def cooc2graph( cooc_id, cooc_matrix, field1="ngrams", field2="ngrams", distance
print("GRAPH#%d ... Saving Graph in hyperdata as json." % cooc_id)
node = session.query(Node).filter(Node.id == cooc_id).first()
node.hyperdata[distance] = dict()
node.hyperdata[distance]["data"] = data
if node.hyperdata.get(distance, None) is None:
node.hyperdata[distance] = dict()
node.hyperdata[distance][bridgeness] = data
node.save_hyperdata()
session.commit()
......
......@@ -57,15 +57,24 @@ def get_graph( request=None , corpus=None
print("Getting data for matrix %d", int(cooc_id))
node = session.query(Node).filter(Node.id == cooc_id).first()
# Check if
# Structure of the Node.hyperdata[distance][bridbeness]
# All parameters (but distance and bridgeness)
# are in Node.hyperdata["parameters"]
# Check distance of the graph
if node.hyperdata.get(distance, None) is not None:
data = node.hyperdata[distance]["data"]
return data
graph = node.hyperdata[distance]
print(node.hyperdata[distance].keys())
# Check bridgeness of the graph
if graph.get(str(bridgeness), None) is not None:
return graph[str(bridgeness)]
# Case of graph has not been computed already
# First, check the parameters
# Case of mapList not big enough
# ==============================
......
......@@ -91,7 +91,8 @@ class Graph(APIView):
, field1=field1 , field2=field2
, mapList_id = mapList_id , groupList_id = groupList_id
, start=start , end=end
, threshold =threshold , distance=distance
, threshold =threshold
, distance=distance , bridgeness=bridgeness
, saveOnly=saveOnly
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment