Commit beb68dcf authored by delanoe's avatar delanoe

Now some parameters are saved in the Node (hyperdata):

- Map List Node id
- Group List Node id

- Start date (UTC format)
- End date (UTC format)

For now, this parameters should be added:
- distance (conditional or distributional)
- bridgeness

Need some refactoring to enable this.
parent c7b5ad3f
...@@ -49,6 +49,11 @@ def countCooccurrences( corpus_id=None , test= False ...@@ -49,6 +49,11 @@ def countCooccurrences( corpus_id=None , test= False
# Security test # Security test
field1,field2 = str(field1), str(field2) field1,field2 = str(field1), str(field2)
# Parameters to save in hyperdata of the Node Cooc
parameters = dict()
parameters['field1'] = field1
parameters['field2'] = field2
# Get corpus as Python object # Get corpus as Python object
corpus = session.query(Node).filter(Node.id==corpus_id).first() corpus = session.query(Node).filter(Node.id==corpus_id).first()
...@@ -65,7 +70,7 @@ def countCooccurrences( corpus_id=None , test= False ...@@ -65,7 +70,7 @@ def countCooccurrences( corpus_id=None , test= False
if not coocNode_id: if not coocNode_id:
coocNode = corpus.add_child( coocNode = corpus.add_child(
typename = "COOCCURRENCES", typename = "COOCCURRENCES",
name = "GRAPH EXPLORER COOC (in:%s)" % corpus.id name = "GRAPH (in corpus %s)" % corpus.id
) )
session.add(coocNode) session.add(coocNode)
...@@ -168,6 +173,8 @@ def countCooccurrences( corpus_id=None , test= False ...@@ -168,6 +173,8 @@ def countCooccurrences( corpus_id=None , test= False
.filter( Start.value_utc >= date_start_utc) .filter( Start.value_utc >= date_start_utc)
) )
parameters['start'] = date_start_utc
if end is not None: if end is not None:
# TODO : more complexe date format here. # TODO : more complexe date format here.
...@@ -183,6 +190,7 @@ def countCooccurrences( corpus_id=None , test= False ...@@ -183,6 +190,7 @@ def countCooccurrences( corpus_id=None , test= False
.filter( End.value_utc <= date_end_utc ) .filter( End.value_utc <= date_end_utc )
) )
parameters['end'] = date_end_utc
if isMonopartite: if isMonopartite:
# Cooc is symetric, take only the main cooccurrences and cut at the limit # Cooc is symetric, take only the main cooccurrences and cut at the limit
...@@ -202,8 +210,20 @@ def countCooccurrences( corpus_id=None , test= False ...@@ -202,8 +210,20 @@ def countCooccurrences( corpus_id=None , test= False
matrix = WeightedMatrix(cooc_query) matrix = WeightedMatrix(cooc_query)
cooc = filterMatrix(matrix, mapList_id, groupList_id) cooc = filterMatrix(matrix, mapList_id, groupList_id)
parameters['MapList_id'] = str(mapList_id)
parameters['GroupList_id'] = str(mapList_id)
if save_on_db: if save_on_db:
# Saving cooc Matrix
cooc.save(coocNode_id) cooc.save(coocNode_id)
# Saving the parameters
coocNode = session.query(Node).filter(Node.id==coocNode_id).first()
coocNode.hyperdata = parameters
session.add(coocNode)
session.commit()
# Log message
print("Cooccurrence Matrix saved") print("Cooccurrence Matrix saved")
return cooc return cooc
...@@ -43,8 +43,8 @@ def get_graph( request=None , corpus=None ...@@ -43,8 +43,8 @@ def get_graph( request=None , corpus=None
2) filter and cluster By Distances (function clusterByDistances) 2) filter and cluster By Distances (function clusterByDistances)
main parameter: distance main parameter: distance
3) filter By Bridgeness (filter By Bridgeness) 3) filter By Bridgeness (function filterByBridgeness)
main parameter: bridgness main parameter: bridgeness
4) format the graph (formatGraph) 4) format the graph (formatGraph)
main parameter: format_ main parameter: format_
......
...@@ -25,16 +25,15 @@ ...@@ -25,16 +25,15 @@
<div class="col-md-5 content"> <div class="col-md-5 content">
<a href="/projects/{{project.id}}/corpora/{{corpus.id}}/explorer?cooc_id={{cooc.id}}"> <a href="/projects/{{project.id}}/corpora/{{corpus.id}}/explorer?cooc_id={{cooc.id}}">
{{cooc.id}} {{ cooc.name }} {{cooc.id}} {{ cooc.name }} {{cooc.hyperdata}}
(size =
(
{% for key, value in coocs_count.items %} {% for key, value in coocs_count.items %}
{% if key == cooc.id %} {% if key == cooc.id %}
{{value}} {{value}}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
) nodes)
</a> </a>
</div> </div>
<div class="col-md-3 content"> <div class="col-md-3 content">
......
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