Commit aa4605c0 authored by PkSM3's avatar PkSM3

Merge branch 'unstable' of ssh://delanoe.org:1979/gargantext into samuel

parents 67eb3782 9147e552
...@@ -221,8 +221,8 @@ def get_cooc(request=None, corpus_id=None, cooc_id=None, type='node_link', size= ...@@ -221,8 +221,8 @@ def get_cooc(request=None, corpus_id=None, cooc_id=None, type='node_link', size=
n = n.sort(inplace=False) n = n.sort(inplace=False)
m = m.sort(inplace=False) m = m.sort(inplace=False)
print(n) #print(n)
print(m) #print(m)
nodes_included = 300 #int(round(size/20,0)) nodes_included = 300 #int(round(size/20,0))
#nodes_excluded = int(round(size/10,0)) #nodes_excluded = int(round(size/10,0))
...@@ -247,25 +247,25 @@ def get_cooc(request=None, corpus_id=None, cooc_id=None, type='node_link', size= ...@@ -247,25 +247,25 @@ def get_cooc(request=None, corpus_id=None, cooc_id=None, type='node_link', size=
xxx = xx.values xxx = xx.values
threshold = min(xxx.max(axis=1)) threshold = min(xxx.max(axis=1))
matrix_filtered = np.where(xxx >= threshold, xxx, 0) matrix_filtered = np.where(xxx >= threshold, xxx, 0)
#matrix_filtered = matrix_filtered.resize((90,90)) #matrix_filtered = matrix_filtered.resize((90,90))
except: except:
PrintException() PrintException()
try: try:
G = nx.from_numpy_matrix(matrix_filtered, create_using=nx.MultiDiGraph()) G = nx.from_numpy_matrix(np.matrix(matrix_filtered))
G = nx.relabel_nodes(G, dict(enumerate([ labels[label] for label in list(xx.columns)]))) #G = nx.from_numpy_matrix(matrix_filtered, create_using=nx.MultiDiGraph())
#print(G) G = nx.relabel_nodes(G, dict(enumerate([ labels[label] for label in list(xx.columns)])))
# Removing too connected nodes (find automatic way to do it) # Removing too connected nodes (find automatic way to do it)
#edges_to_remove = [ e for e in G.edges_iter() if #edges_to_remove = [ e for e in G.edges_iter() if
degree = G.degree() degree = G.degree()
nodes_to_remove = [n for n in degree if degree[n] <= 1] nodes_to_remove = [n for n in degree if degree[n] <= 1]
G.remove_nodes_from(nodes_to_remove) G.remove_nodes_from(nodes_to_remove)
uG = G.to_undirected()
partition = best_partition(G) partition = best_partition(uG)
except: except:
print("-" * 30)
PrintException() PrintException()
...@@ -281,7 +281,8 @@ def get_cooc(request=None, corpus_id=None, cooc_id=None, type='node_link', size= ...@@ -281,7 +281,8 @@ def get_cooc(request=None, corpus_id=None, cooc_id=None, type='node_link', size=
G.node[node]['group'] = partition[node] G.node[node]['group'] = partition[node]
# G.add_edge(node, "cluster " + str(partition[node]), weight=3) # G.add_edge(node, "cluster " + str(partition[node]), weight=3)
except Exception as error: except Exception as error:
print("error01: ",error) pass#PrintException()
#print("error01: ",error)
data = json_graph.node_link_data(G) data = json_graph.node_link_data(G)
......
...@@ -345,7 +345,11 @@ def test_ngrams(request , project_id, corpus_id ): ...@@ -345,7 +345,11 @@ def test_ngrams(request , project_id, corpus_id ):
ngrams_ids = Ngrams_Scores.keys() ngrams_ids = Ngrams_Scores.keys()
import math import math
occs_threshold = min ( 10 , math.sqrt(Sum / len(ngrams_ids)) )
if len(ngrams_ids) != 0:
occs_threshold = min ( 10 , math.sqrt(Sum / len(ngrams_ids)) )
else:
occs_threshold = 10
Metrics = { Metrics = {
"ngrams":[], "ngrams":[],
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-6">
<div class="jumbotron"> <div class="jumbotron">
<h3><a href="/project/{{project.id}}/corpus/{{corpus.id}}/chart">Advanced charts</a></h3> <h3><a href="/project/{{project.id}}/corpus/{{corpus.id}}/chart">Advanced charts</a></h3>
<ol> <ol>
...@@ -92,20 +92,8 @@ ...@@ -92,20 +92,8 @@
</div> </div>
</div> </div>
<div class="col-md-4">
<div class="jumbotron">
<!-- <h3><a href="/project/{{project.id}}/corpus/{{corpus.id}}/matrix">Matrix</a></h3> -->
<h3>Matrix (soon)</h3>
<ol>
<li>Sort</li>
<li>Group</li>
<li>Cluster</li>
</ol>
<h4><a href="/project/{{project.id}}/corpus/{{corpus.id}}/">Back to corpus</a></h3>
</div>
</div>
<div class="col-md-4"> <div class="col-md-6">
<div class="jumbotron"> <div class="jumbotron">
{% if processing > 0 %} {% if processing > 0 %}
<h3> <img width="20px" src="{% static "js/libs/img2/loading-bar.gif" %}"></img> Graph (later)</h3> <h3> <img width="20px" src="{% static "js/libs/img2/loading-bar.gif" %}"></img> Graph (later)</h3>
......
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