Commit d24461b7 authored by Administrator's avatar Administrator

Merge branch 'master' into alex

last results
parents 5a180df8 e885cc67
......@@ -133,7 +133,7 @@ def create_cooc(user=None, corpus=None, whitelist=None, size=150):
cursor.execute(query_cooc)
return cooc
def get_cooc(request=None, corpus_id=None, cooc_id=None, type="node_link", n=150):
def get_cooc(request=None, corpus_id=None, cooc_id=None, type=None, n=150):
import pandas as pd
from copy import copy
import numpy as np
......@@ -189,8 +189,11 @@ def get_cooc(request=None, corpus_id=None, cooc_id=None, type="node_link", n=150
partition = best_partition(G)
if type == "node_link":
for community in set(partition.values()):
#print(community)
G.add_node("cluster " + str(community), hidden=1)
for node in G.nodes():
try:
#node,type(labels[node])
......@@ -198,7 +201,7 @@ def get_cooc(request=None, corpus_id=None, cooc_id=None, type="node_link", n=150
G.node[node]['name'] = node
G.node[node]['size'] = weight[node]
G.node[node]['group'] = partition[node]
#G.add_edge(node, partition[node], weight=3)
G.add_edge(node, "cluster " + str(partition[node]), weight=3)
# G.node[node]['color'] = '19,180,300'
except Exception as error:
print(error)
......
......@@ -47,7 +47,7 @@ TEMPLATE_DIRS = (
#ALLOWED_HOSTS = ['*',]
ALLOWED_HOSTS = ['localhost', 'master.polemic.be', 'mat.polemic.be', 'alexandre.polemic.be']
ALLOWED_HOSTS = ['localhost', 'master.polemic.be', 'beta.gargantext.org']
......
......@@ -35,7 +35,7 @@ urlpatterns = patterns('',
# Getting data
url(r'^chart/corpus/(\d+)/data.csv$', views.send_csv),
url(r'^corpus/(\d+)/node_link.json$', views.node_link),
url(r'^corpus/(\d+)/adjacency.json$', views.node_link),
url(r'^corpus/(\d+)/adjacency.json$', views.adjacency),
url(r'^api$', gargantext_web.api.Root),
url(r'^api/nodes/(\d+)/children/metadata$', gargantext_web.api.NodesChildrenMetatadata.as_view()),
......
......@@ -5,11 +5,10 @@ from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.template.loader import get_template
from django.template import Context
#from documents.models import Project, Corpus, Document
from node.models import Language, ResourceType, Resource, \
Node, NodeType, Node_Resource, Project, Corpus, \
Node_Ngram, NodeNgramNgram
from node.admin import CorpusForm, ProjectForm, ResourceForm
from django.contrib.auth.models import User
......@@ -238,12 +237,8 @@ def project(request, project_id):
)
try:
#corpus.parse_resources.apply_async((), countdown=1)
corpus.parse_resources()
# async
corpus.children.filter(type_id=type_document.pk).extract_ngrams(keys=['title',])
#corpus.children.filter(type_id=type_document.pk).extract_ngrams(keys=['title',])
corpus.parse_and_extract_ngrams()
#corpus.parse_and_extract_ngrams.apply_async((), countdown=3)
except Exception as error:
print(error)
......
......@@ -157,7 +157,6 @@ class Node(CTENode):
node_resource.save()
return resource
@current_app.task(filter=task_method)
def parse_resources(self, verbose=False):
# parse all resources into a list of metadata
metadata_list = []
......@@ -200,7 +199,6 @@ class Node(CTENode):
self.node_resource.update(parsed=True)
@current_app.task(filter=task_method)
def extract_ngrams(self, keys, ngramsextractorscache=None, ngramscaches=None):
# if there is no cache...
if ngramsextractorscache is None:
......@@ -235,6 +233,13 @@ class Node(CTENode):
for ngram_text, weight in associations.items()
])
@current_app.task(filter=task_method)
def parse_and_extract_ngrams(self, keys=None, ngramsextractorscache=None, ngramscaches=None, verbose=False):
self.parse_resources()
type_document = NodeType.objects.get(name='Document')
self.children.filter(type_id=type_document.pk).extract_ngrams(keys=['title',])
class Node_Metadata(models.Model):
node = models.ForeignKey(Node)
metadata = models.ForeignKey(Metadata)
......
......@@ -29,7 +29,7 @@ text.active {
<div class="container theme-showcase" role="main">
<div class="jumbotron">
<h1>Adjancy Matrix</h1>
<h1>Adjacency Matrix</h1>
</div>
</div>
......
......@@ -76,9 +76,12 @@
<li>{{ key }}</li>
<ul>
{% for corpus in corpora %}
<li>
<li> {% ifnotequal corpus.count 0 %}
<a href="/project/{{project.id}}/corpus/{{corpus.id}}">{{corpus.name}}</a>
, {{ corpus.count }} Documents
{% else %}
{{corpus.name}} : Processing, drink a cup of tea, and refresh the page :)
{% endifnotequal %}
<button type="button" class="btn btn-xs btn-default" data-container="body" data-toggle="popover" data-placement="bottom"
data-content='
<ul>
......
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