Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
d24461b7
Commit
d24461b7
authored
Dec 08, 2014
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into alex
last results
parents
5a180df8
e885cc67
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
17 deletions
+23
-17
functions.py
analysis/functions.py
+6
-3
settings.py
gargantext_web/settings.py
+1
-1
urls.py
gargantext_web/urls.py
+1
-1
views.py
gargantext_web/views.py
+3
-8
models.py
node/models.py
+7
-2
matrix.html
templates/matrix.html
+1
-1
project.html
templates/project.html
+4
-1
No files found.
analysis/functions.py
View file @
d24461b7
...
...
@@ -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
)
...
...
gargantext_web/settings.py
View file @
d24461b7
...
...
@@ -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
'
]
...
...
gargantext_web/urls.py
View file @
d24461b7
...
...
@@ -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
()),
...
...
gargantext_web/views.py
View file @
d24461b7
...
...
@@ -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
)
...
...
node/models.py
View file @
d24461b7
...
...
@@ -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
)
...
...
templates/matrix.html
View file @
d24461b7
...
...
@@ -29,7 +29,7 @@ text.active {
<div
class=
"container theme-showcase"
role=
"main"
>
<div
class=
"jumbotron"
>
<h1>
Adjancy Matrix
</h1>
<h1>
Adja
ce
ncy Matrix
</h1>
</div>
</div>
...
...
templates/project.html
View file @
d24461b7
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment