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
f5027062
Commit
f5027062
authored
Mar 23, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] fix merge with Rom push.
parent
539e2d21
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
3 deletions
+81
-3
nodes.py
gargantext/views/api/nodes.py
+43
-0
urls.py
gargantext/views/api/urls.py
+4
-2
corpora.py
gargantext/views/pages/corpora.py
+29
-0
urls.py
gargantext/views/pages/urls.py
+5
-1
No files found.
gargantext/views/api/nodes.py
View file @
f5027062
...
@@ -177,3 +177,46 @@ class CorpusFacet(APIView):
...
@@ -177,3 +177,46 @@ class CorpusFacet(APIView):
# // if subfield not in corpus.aggs:
# // if subfield not in corpus.aggs:
# // corpus.aggs[subfield] = xcounts
# // corpus.aggs[subfield] = xcounts
return
(
xcounts
,
total
)
return
(
xcounts
,
total
)
class
CorpusGraph
(
APIView
):
'''
Generate a graph
'''
def
get
(
self
,
request
,
node_id
):
# check that the node is a corpus
# ? faster from cache than: corpus = session.query(Node)...
corpus
=
cache
.
Node
[
node_id
]
if
corpus
.
typename
!=
'CORPUS'
:
raise
ValidationException
(
"Only nodes of type CORPUS can accept facet queries"
+
" (but this node has type
%
s)..."
%
corpus
.
typename
)
else
:
self
.
corpus
=
corpus
# check that the hyperfield parameter makes sense
_facet_available_subfields
=
[
'journal'
,
'publication_year'
,
'rubrique'
,
'language_iso2'
,
'language_iso3'
,
'language_name'
]
parameters
=
get_parameters
(
request
)
# validate() triggers an info message if subfield not in range
parameters
=
validate
(
parameters
,
{
'type'
:
dict
,
'items'
:
{
'hyperfield'
:
{
'type'
:
str
,
'range'
:
_facet_available_subfields
}
}})
subfield
=
parameters
[
'hyperfield'
]
# do_cooc
# do_distance
# response
return
JsonHttpResponse
({
'doc_count'
:
total
,
'by'
:
{
subfield
:
xcounts
}
})
gargantext/views/api/urls.py
View file @
f5027062
...
@@ -5,8 +5,8 @@ from . import ngramlists
...
@@ -5,8 +5,8 @@ from . import ngramlists
urlpatterns
=
[
urlpatterns
=
[
url
(
r'^nodes$'
,
nodes
.
NodeListResource
.
as_view
()),
url
(
r'^nodes$'
,
nodes
.
NodeListResource
.
as_view
()),
url
(
r'^nodes/(\d+)$'
,
nodes
.
NodeResource
.
as_view
()),
url
(
r'^nodes/(\d+)$'
,
nodes
.
NodeResource
.
as_view
()),
url
(
r'^nodes/(\d+)/facets$'
,
nodes
.
CorpusFacet
.
as_view
()),
url
(
r'^nodes/(\d+)/facets$'
,
nodes
.
CorpusFacet
.
as_view
()),
...
@@ -22,4 +22,6 @@ urlpatterns = [
...
@@ -22,4 +22,6 @@ urlpatterns = [
# - an optional grouplist
# - an optional grouplist
# aka lexical model
# aka lexical model
url
(
r'^ngramlists/family$'
,
ngramlists
.
ListFamily
.
as_view
()),
url
(
r'^ngramlists/family$'
,
ngramlists
.
ListFamily
.
as_view
()),
url
(
r'^nodes/(\d+)/graph$'
,
nodes
.
CorpusGraph
.
as_view
()),
]
]
gargantext/views/pages/corpora.py
View file @
f5027062
...
@@ -74,3 +74,32 @@ def docs_by_journals(request, project_id, corpus_id):
...
@@ -74,3 +74,32 @@ def docs_by_journals(request, project_id, corpus_id):
'view'
:
'journals'
'view'
:
'journals'
},
},
)
)
@
requires_auth
def
graph
(
request
,
project_id
,
corpus_id
):
'''
Graph
'''
# we pass our corpus
corpus
=
cache
.
Node
[
corpus_id
]
# and the project just for project.id in corpusBannerTop
project
=
cache
.
Node
[
project_id
]
# rendered page : journals.html
return
render
(
template_name
=
'pages/corpora/journals.html'
,
request
=
request
,
context
=
{
'debug'
:
settings
.
DEBUG
,
'date'
:
datetime
.
now
(),
'project'
:
project
,
'corpus'
:
corpus
,
'view'
:
'journals'
},
)
gargantext/views/pages/urls.py
View file @
f5027062
from
django.conf.urls
import
url
from
django.conf.urls
import
url
from
.
import
main
,
auth
from
.
import
main
,
auth
from
.
import
projects
,
corpora
,
terms
from
.
import
projects
,
corpora
,
terms
,
explorer
urlpatterns
=
[
urlpatterns
=
[
...
@@ -28,4 +28,8 @@ urlpatterns = [
...
@@ -28,4 +28,8 @@ urlpatterns = [
# terms table for the corpus
# terms table for the corpus
url
(
r'^projects/(\d+)/corpora/(\d+)/terms/?$'
,
terms
.
ngramtable
),
url
(
r'^projects/(\d+)/corpora/(\d+)/terms/?$'
,
terms
.
ngramtable
),
# graph explorer
url
(
r'^projects/(\d+)/corpora/(\d+)/graph/?$'
,
explorer
.
graph
),
]
]
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