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
b004fb6f
Commit
b004fb6f
authored
May 28, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BUGFIX] get only personal projects
parent
9c96b527
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
7 deletions
+118
-7
urls.py
gargantext_web/urls.py
+2
-1
views.py
gargantext_web/views.py
+111
-1
hstore2jsonb.sql
init/sql/hstore2jsonb.sql
+5
-5
No files found.
gargantext_web/urls.py
View file @
b004fb6f
...
@@ -77,7 +77,8 @@ urlpatterns = patterns('',
...
@@ -77,7 +77,8 @@ urlpatterns = patterns('',
url
(
r'^tests/project/(\d+)/pubmedquery/go$'
,
pubmedscrapper
.
doTheQuery
),
url
(
r'^tests/project/(\d+)/pubmedquery/go$'
,
pubmedscrapper
.
doTheQuery
),
url
(
r'^tests/project/(\d+)/ISTEXquery/go$'
,
pubmedscrapper
.
testISTEX
),
url
(
r'^tests/project/(\d+)/ISTEXquery/go$'
,
pubmedscrapper
.
testISTEX
),
url
(
r'^tests/paginator/corpus/(\d+)/$'
,
views
.
newpaginatorJSON
),
url
(
r'^tests/paginator/corpus/(\d+)/$'
,
views
.
newpaginatorJSON
),
url
(
r'^tests/move2trash/$'
,
views
.
move_to_trash_multiple
)
url
(
r'^tests/move2trash/$'
,
views
.
move_to_trash_multiple
),
url
(
r'^project/(\d+)/corpus/(\d+)/ngrams$'
,
views
.
test_ngrams
)
)
)
...
...
gargantext_web/views.py
View file @
b004fb6f
...
@@ -255,6 +255,116 @@ def projects(request):
...
@@ -255,6 +255,116 @@ def projects(request):
'projects'
:
projects
'projects'
:
projects
})
})
def
test_ngrams
(
request
,
project_id
,
corpus_id
):
results
=
[
"hola"
,
"mundo"
]
user_id
=
request
.
user
.
id
whitelist_type_id
=
cache
.
NodeType
[
'WhiteList'
]
.
id
document_type_id
=
cache
.
NodeType
[
'Document'
]
.
id
# # 13099 clinical benefits
# # 7492 recent data
# # 14279 brain development
# # 50681 possible cause
# # 47111 psychological symptoms
# # 3944 common form
# ngram_of_interest = 14279
# documents = session.query(Node).filter(Node.user_id == user_id , Node.parent_id==corpus_id , Node.type_id == document_type_id ).all()
# to_print = []
# for doc in documents:
# NgramOccs = session.query(Node_Ngram).filter( Node_Ngram.node_id==doc.id).all()
# # print( len(NgramOccs) )
# for ngram in NgramOccs:
# if ngram.ngram_id == ngram_of_interest:
# to_print.append( [doc.id,doc.name] )
# break
# if len(to_print)>0:
# for doc in to_print:
# doc_id = doc[0]
# doc_name = doc[1]
# print("doc_id:",doc_id)
# NgramOccs = session.query(Node_Ngram).filter( Node_Ngram.node_id==doc_id).all()
# for ngram in NgramOccs:
# if ngram.ngram_id == ngram_of_interest:
# print("\t" , ngram.ngram_id , "\t" , ngram.weight )
# print (" - - - - -- - - - ")
# print("Calculation using the DB:")
# white_list = session.query(Node).filter( Node.parent_id==corpus_id , Node.type_id==whitelist_type_id).first()
# NgramOccs = session.query(Node_Ngram).filter( Node_Ngram.node_id==white_list.id).all()
# for ngram in NgramOccs:
# if ngram.ngram_id == ngram_of_interest:
# print( ngram.weight, "\t" , ngram.ngram_id)
# print( "= = = = = = = = == = = ")
# NgramTFIDF = session.query(NodeNodeNgram).filter( NodeNodeNgram.nodex_id==corpus_id ).all()
# for ngram in NgramTFIDF:
# print( "docid:", ngram.nodey_id , ngram.ngram_id , ngram.score)
Ngrams_Scores
=
{}
## < Getting the Effective nro de OCCS ##
documents
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user_id
,
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
document_type_id
)
.
all
()
for
doc
in
documents
:
NgramOccs
=
session
.
query
(
Node_Ngram
)
.
filter
(
Node_Ngram
.
node_id
==
doc
.
id
)
.
all
()
for
ngram
in
NgramOccs
:
if
ngram
.
ngram_id
not
in
Ngrams_Scores
:
Ngrams_Scores
[
ngram
.
ngram_id
]
=
{
"occ_sum"
:
0.0
,
"occ_uniq"
:
0.0
,
"tfidf_sum"
:
0.0
}
Ngrams_Scores
[
ngram
.
ngram_id
][
"occ_sum"
]
+=
ngram
.
weight
Ngrams_Scores
[
ngram
.
ngram_id
][
"occ_uniq"
]
+=
1
# print("\t" , ngram.ngram_id , "\t" , ngram.weight )
## Getting the Effective nro de OCCS / >##
# # CA MARCHE PAS POUR TOUT LES NGRAMS!!
# ## < Getting the unique number of OCCS ##
# summ1 = len(Ngrams_Scores.keys())
# white_list = session.query(Node).filter( Node.parent_id==corpus_id , Node.type_id==whitelist_type_id).first()# get whitelist id from corpus
# NgramOccs = session.query(Node_Ngram).filter( Node_Ngram.node_id==white_list.id).all()
# summ2 = 0
# for ngram in NgramOccs:
# Ngrams_Scores[ngram.ngram_id]["occ_uniq"] = ngram.weight
# summ2+=1
# # print("\t" , ngram.ngram_id , "\t" , ngram.weight )
# print (" - - -- - - - - - ")
# print ("Sum numero 01:",summ1)
# print ("Sum numero 02:",summ2)
# ## Getting the unique number of OCCS /> ##
NgramTFIDF
=
session
.
query
(
NodeNodeNgram
)
.
filter
(
NodeNodeNgram
.
nodex_id
==
corpus_id
)
.
all
()
for
ngram
in
NgramTFIDF
:
Ngrams_Scores
[
ngram
.
ngram_id
][
"tfidf_sum"
]
+=
ngram
.
score
# print( "docid:", ngram.nodey_id , ngram.ngram_id , ngram.score)
# import pprint
# pprint.pprint( Ngrams_Scores )
# # select * from node_nodenodengram where ngram_id=14279;
# NodeNodeNgram
# nodex_id = real corpus id
# nodey_id = document id
# ngram_id = duh
# id | nodex_id | nodey_id | ngram_id | score
return
JsonHttpResponse
(
results
)
def
corpus
(
request
,
project_id
,
corpus_id
):
def
corpus
(
request
,
project_id
,
corpus_id
):
...
@@ -482,7 +592,7 @@ def graph(request, project_id, corpus_id):
...
@@ -482,7 +592,7 @@ def graph(request, project_id, corpus_id):
corpus_type_id
=
cache
.
NodeType
[
'Corpus'
]
.
id
corpus_type_id
=
cache
.
NodeType
[
'Corpus'
]
.
id
results
=
{}
results
=
{}
projs
=
session
.
query
(
Node
)
.
filter
(
Node
.
type_id
==
project_type_id
)
.
all
()
projs
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user_id
,
Node
.
type_id
==
project_type_id
)
.
all
()
for
i
in
projs
:
for
i
in
projs
:
# print(i.id , i.name)
# print(i.id , i.name)
if
i
.
id
not
in
results
:
results
[
i
.
id
]
=
{}
if
i
.
id
not
in
results
:
results
[
i
.
id
]
=
{}
...
...
init/sql/hstore2jsonb.sql
View file @
b004fb6f
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
date
SET
DEFAULT
CURRENT_DATE
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
date
SET
DEFAULT
CURRENT_DATE
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
meta
data
DROP
NOT
NULL
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
hyper
data
DROP
NOT
NULL
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
meta
data
DROP
DEFAULT
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
hyper
data
DROP
DEFAULT
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
metadata
TYPE
JSONB
USING
hstore_to_json
(
meta
data
)::
jsonb
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
hyperdata
TYPE
JSONB
USING
hstore_to_json
(
hyper
data
)::
jsonb
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
meta
data
SET
DEFAULT
'{}'
::
jsonb
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
hyper
data
SET
DEFAULT
'{}'
::
jsonb
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
meta
data
SET
NOT
NULL
;
ALTER
TABLE
ONLY
node_node
ALTER
COLUMN
hyper
data
SET
NOT
NULL
;
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