Commit d4a7fcc9 authored by Administrator's avatar Administrator

Merge branch 'samuel'

Merge with Samuels graph viz, Congrats to Sam!
parents e558ccba 20bd20e8
...@@ -12,12 +12,13 @@ from parsing.FileParsers import * ...@@ -12,12 +12,13 @@ from parsing.FileParsers import *
from time import time from time import time
from collections import defaultdict from collections import defaultdict
from gargantext_web.settings import MEDIA_ROOT
# Some usefull functions # Some usefull functions
# TODO: start the function name with an underscore (private) # TODO: start the function name with an underscore (private)
def _upload_to(instance, filename): def upload_to(instance, filename):
return MEDIA_ROOT + '/corpora/%s/%s' % (instance.user.username, filename) return 'corpora/%s/%s' % (instance.user.username, filename)
#return 'corpora/%s/%f/%s' % (instance.user.username, time(), filename)
# All classes here # All classes here
...@@ -41,10 +42,9 @@ class Ngram(models.Model): ...@@ -41,10 +42,9 @@ class Ngram(models.Model):
terms = models.CharField(max_length=255) terms = models.CharField(max_length=255)
class Resource(models.Model): class Resource(models.Model):
user = models.ForeignKey(User)
guid = models.CharField(max_length=255) guid = models.CharField(max_length=255)
type = models.ForeignKey(ResourceType, blank=True, null=True) type = models.ForeignKey(ResourceType, blank=True, null=True)
file = models.FileField(upload_to=_upload_to, blank=True) file = models.FileField(upload_to=upload_to, blank=True)
digest = models.CharField(max_length=32) # MD5 digest digest = models.CharField(max_length=32) # MD5 digest
class NodeType(models.Model): class NodeType(models.Model):
...@@ -52,6 +52,7 @@ class NodeType(models.Model): ...@@ -52,6 +52,7 @@ class NodeType(models.Model):
def __str__(self): def __str__(self):
return self.name return self.name
class NodeQuerySet(models.query.QuerySet): class NodeQuerySet(models.query.QuerySet):
"""Methods available from Node querysets.""" """Methods available from Node querysets."""
def extract_ngrams(self, keys, ngramsextractorscache=None, ngramscaches=None): def extract_ngrams(self, keys, ngramsextractorscache=None, ngramscaches=None):
...@@ -84,6 +85,12 @@ class Node(CTENode): ...@@ -84,6 +85,12 @@ class Node(CTENode):
date = models.DateField(default=timezone.now, blank=True) date = models.DateField(default=timezone.now, blank=True)
metadata = hstore.DictionaryField(blank=True) metadata = hstore.DictionaryField(blank=True)
# TODO: remove the three following fields
#fichier = models.FileField(upload_to=upload_to, blank=True)
#resource = models.ForeignKey(Resource, blank=True, null=True)
#ngrams = models.ManyToManyField(NGrams)
def __str__(self): def __str__(self):
return self.name return self.name
...@@ -111,8 +118,6 @@ class Node(CTENode): ...@@ -111,8 +118,6 @@ class Node(CTENode):
'isi' : IsiFileParser, 'isi' : IsiFileParser,
'ris' : RisFileParser, 'ris' : RisFileParser,
'europress' : EuropressFileParser, 'europress' : EuropressFileParser,
'europress_french' : EuropressFileParser,
'europress_english' : EuropressFileParser,
})[resource.type.name]() })[resource.type.name]()
metadata_list += parser.parse(str(resource.file)) metadata_list += parser.parse(str(resource.file))
# insert the new resources in the database! # insert the new resources in the database!
...@@ -166,6 +171,7 @@ class Node(CTENode): ...@@ -166,6 +171,7 @@ class Node(CTENode):
for ngram_text, weight in associations.items() for ngram_text, weight in associations.items()
]) ])
class Node_Resource(models.Model): class Node_Resource(models.Model):
node = models.ForeignKey(Node, related_name='node_resource') node = models.ForeignKey(Node, related_name='node_resource')
resource = models.ForeignKey(Resource) resource = models.ForeignKey(Resource)
......
/srv/gargantext_lib/js/extras_explorerjs.js
\ No newline at end of file
/srv/gargantext_lib/libs
\ No newline at end of file
/srv/gargantext_lib/js/settings_explorerjs.js
\ No newline at end of file
/srv/gargantext_lib/js/tinawebJS
\ No newline at end of file
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<body> <body>
<!-- Fixed navbar --> <!-- Fixed navbar -->
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div id="dafixedtop" class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container"> <div class="container">
<div class="navbar-inner"> <div class="navbar-inner">
<button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
......
{"directed": false, "graph": [["name", "complete_graph(10)"]], "nodes": [{"id": 0}, {"id": 1}, {"id": 2}, {"id": 3}, {"id": 4}, {"id": 5}, {"id": 6}, {"id": 7}, {"id": 8}, {"id": 9}], "links": [{"source": 0, "target": 1}, {"source": 0, "target": 2}, {"source": 0, "target": 3}, {"source": 0, "target": 4}, {"source": 0, "target": 5}, {"source": 0, "target": 6}, {"source": 0, "target": 7}, {"source": 0, "target": 8}, {"source": 0, "target": 9}, {"source": 1, "target": 2}, {"source": 1, "target": 3}, {"source": 1, "target": 4}, {"source": 1, "target": 5}, {"source": 1, "target": 6}, {"source": 1, "target": 7}, {"source": 1, "target": 8}, {"source": 1, "target": 9}, {"source": 2, "target": 3}, {"source": 2, "target": 4}, {"source": 2, "target": 5}, {"source": 2, "target": 6}, {"source": 2, "target": 7}, {"source": 2, "target": 8}, {"source": 2, "target": 9}, {"source": 3, "target": 4}, {"source": 3, "target": 5}, {"source": 3, "target": 6}, {"source": 3, "target": 7}, {"source": 3, "target": 8}, {"source": 3, "target": 9}, {"source": 4, "target": 5}, {"source": 4, "target": 6}, {"source": 4, "target": 7}, {"source": 4, "target": 8}, {"source": 4, "target": 9}, {"source": 5, "target": 6}, {"source": 5, "target": 7}, {"source": 5, "target": 8}, {"source": 5, "target": 9}, {"source": 6, "target": 7}, {"source": 6, "target": 8}, {"source": 6, "target": 9}, {"source": 7, "target": 8}, {"source": 7, "target": 9}, {"source": 8, "target": 9}], "multigraph": false}
\ No newline at end of file
import networkx as nx
from networkx.readwrite import json_graph
print "hola"
G = nx.complete_graph(10)
f = open("testgraph.json","w")
f.write ( json_graph.dumps(G) )
f.close()
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