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
19fe1edb
Commit
19fe1edb
authored
Dec 14, 2015
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'samuel' into unstable
parents
a95befe6
219f09c1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
26 deletions
+49
-26
NgramsExtractor.py
parsing/NgramsExtractors/NgramsExtractor.py
+2
-1
TurboNgramsExtractor.py
parsing/NgramsExtractors/TurboNgramsExtractor.py
+2
-1
ngrams.py
rest_v1_0/ngrams.py
+19
-6
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+24
-16
menu.html
templates/corpus/menu.html
+1
-1
views.py
tests/ngramstable/views.py
+1
-1
No files found.
parsing/NgramsExtractors/NgramsExtractor.py
View file @
19fe1edb
from
..Taggers
import
TurboTagger
#NltkTagger #,
from
..Taggers
import
TurboTagger
# from ..Taggers import NltkTagger
import
nltk
...
...
parsing/NgramsExtractors/TurboNgramsExtractor.py
View file @
19fe1edb
from
.NgramsExtractor
import
NgramsExtractor
from
..Taggers
import
TurboTagger
#NltkTagger
from
..Taggers
import
TurboTagger
# from ..Taggers import NltkTagger
class
TurboNgramsExtractor
(
NgramsExtractor
):
...
...
rest_v1_0/ngrams.py
View file @
19fe1edb
...
...
@@ -91,17 +91,30 @@ class List(APIView):
"id"
:
node
.
id
,
"name"
:
node
.
terms
,
"scores"
:
{
"tfidf"
:
0
"tfidf"
:
0
,
"occs"
:
0
}
}
# occ_list = get_or_create_node(nodetype='Occurrences', corpus_id=parent_id).id
# print( occ_list )
tfidf_list
=
get_or_create_node
(
nodetype
=
'Tfidf (global)'
,
corpus_id
=
parent_id
)
.
id
ngram_tfidf
=
session
.
query
(
NodeNodeNgram
.
ngram_id
,
NodeNodeNgram
.
score
)
.
filter
(
NodeNodeNgram
.
nodex_id
==
tfidf_list
,
NodeNodeNgram
.
ngram_id
.
in_
(
list
(
ngram_ids
.
keys
())
))
.
all
()
for
n
in
ngram_tfidf
:
if
n
.
ngram_id
in
ngram_ids
:
ngram_ids
[
n
.
ngram_id
][
"scores"
][
"tfidf"
]
+=
n
.
score
try
:
tfidf_list
=
get_or_create_node
(
nodetype
=
'Tfidf (global)'
,
corpus_id
=
parent_id
)
.
id
ngram_tfidf
=
session
.
query
(
NodeNodeNgram
.
ngram_id
,
NodeNodeNgram
.
score
)
.
filter
(
NodeNodeNgram
.
nodex_id
==
tfidf_list
,
NodeNodeNgram
.
ngram_id
.
in_
(
list
(
ngram_ids
.
keys
())
))
.
all
()
for
n
in
ngram_tfidf
:
if
n
.
ngram_id
in
ngram_ids
:
ngram_ids
[
n
.
ngram_id
][
"scores"
][
"tfidf"
]
+=
n
.
score
except
:
pass
try
:
occ_list
=
get_or_create_node
(
nodetype
=
'Occurrences'
,
corpus_id
=
parent_id
)
.
id
ngram_occs
=
session
.
query
(
NodeNodeNgram
.
ngram_id
,
NodeNodeNgram
.
score
)
.
filter
(
NodeNodeNgram
.
nodex_id
==
occ_list
,
NodeNodeNgram
.
ngram_id
.
in_
(
list
(
ngram_ids
.
keys
())
))
.
all
()
for
n
in
ngram_occs
:
if
n
.
ngram_id
in
ngram_ids
:
ngram_ids
[
n
.
ngram_id
][
"scores"
][
"occs"
]
+=
round
(
n
.
score
)
except
:
pass
end_
=
time
.
time
()
...
...
static/js/NGrams_dyna_chart_and_table.js
View file @
19fe1edb
...
...
@@ -97,14 +97,16 @@ var LineChart = dc.lineChart("#monthly-move-chart");
var
volumeChart
=
dc
.
barChart
(
"#monthly-volume-chart"
);
//
Just for Garg
//
Get all projects and corpuses of the user
function
GetUserPortfolio
()
{
//http://localhost:8000/api/corpusintersection/1a50317a50145
var
project_id
=
getIDFromURL
(
"project"
)
var
corpus_id
=
getIDFromURL
(
"corpus"
)
if
(
Object
.
keys
(
corpusesList
).
length
>
0
)
return
true
;
if
(
Object
.
keys
(
corpusesList
).
length
>
0
)
{
$
(
'#corpuses'
).
modal
(
'show'
);
return
true
;
}
var
query_url
=
window
.
location
.
origin
+
'/api/userportfolio/project/'
+
project_id
+
'/corpuses'
$
.
ajax
({
...
...
@@ -158,8 +160,6 @@ function GetUserPortfolio() {
});
$
(
'#corpuses'
).
modal
(
'show'
);
},
error
:
function
(){
pr
(
'Page Not found: TestFunction()'
);
...
...
@@ -167,6 +167,7 @@ function GetUserPortfolio() {
});
}
//Getting a corpusB-list and intersecting it with current corpusA-miamlist.
function
printCorpuses
()
{
console
.
log
(
"!!!!!!!! in printCorpuses() !!!!!!!! "
)
pr
(
corpusesList
)
...
...
@@ -585,6 +586,7 @@ function SaveGlobalChanges_Form( nodes2del) {
$
(
"#pre_savechanges"
).
modal
(
"show"
)
}
// Save changes to all corpusA-lists
function
SaveLocalChanges
()
{
console
.
clear
()
...
...
@@ -713,7 +715,7 @@ $("#Save_All").click(function(){
// }
});
// For lists, all http-requests
function
CRUD
(
parent_id
,
action
,
nodes
,
args
,
http_method
,
callback
)
{
var
the_url
=
window
.
location
.
origin
+
"/api/node/"
+
parent_id
+
"/ngrams"
+
action
+
"/"
+
nodes
.
join
(
"+"
);
the_url
=
the_url
.
replace
(
/
\/
$/
,
""
);
//remove trailing slash
...
...
@@ -1060,6 +1062,7 @@ function getIDFromURL( item ) {
return
pageurl
[
cid
+
1
];
}
// For lists, only GET requests
function
GET_
(
url
,
callback
)
{
$
.
ajax
({
...
...
@@ -1107,18 +1110,23 @@ var url = [
GET_
(
url
[
0
]
,
function
(
result
)
{
// = = = = MIAM = = = = //
if
(
result
!=
false
)
{
NGrams
[
"main"
]
=
{
"ngrams"
:
[],
"scores"
:
{
"initial"
:
"tfidf
"
,
"nb_docs"
:
result
.
length
,
"orig_nb_ngrams"
:
1
,
"nb_ngrams"
:
result
.
length
,
}
}
NGrams
[
"main"
]
=
{
"ngrams"
:
[],
"scores"
:
{
"initial"
:
"occs
"
,
"nb_docs"
:
result
.
length
,
"orig_nb_ngrams"
:
1
,
"nb_ngrams"
:
result
.
length
,
}
}
for
(
var
i
in
result
)
var
occs_sum
=
0
for
(
var
i
in
result
)
{
NGrams
[
"main"
].
ngrams
.
push
(
result
[
i
])
occs_sum
+=
result
[
i
].
scores
.
occs
}
if
(
occs_sum
==
0
)
NGrams
[
"main"
][
"scores"
][
"initial"
]
=
"tfidf"
;
}
// = = = = /MIAM = = = = //
...
...
templates/corpus/menu.html
View file @
19fe1edb
...
...
@@ -49,7 +49,7 @@
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.id }}/"
>
Add documents
</a></p>
{% endif %}
{% if nb_groups != None and nb_groups > 0 %}
<a
style=
"visibility: hidden;"
id=
"share_button"
class=
"btn btn-primary btn-lg"
role=
"button"
>
Share!!!
</a></p>
<a
id=
"share_button"
class=
"btn btn-primary btn-lg"
role=
"button"
>
Share!!!
</a></p>
{% endif %}
</div>
</div>
...
...
tests/ngramstable/views.py
View file @
19fe1edb
...
...
@@ -252,7 +252,7 @@ def graph_share(request, generic=100, specific=100):
def
node_link_share
(
request
):
data
=
{
"hola"
:
"mundo"
}
data
=
{
"request"
:
"error"
}
if
request
.
method
==
'GET'
and
"token"
in
request
.
GET
:
import
json
le_token
=
json
.
loads
(
request
.
GET
[
"token"
])[
0
]
...
...
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