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
2f5962e3
Commit
2f5962e3
authored
Nov 12, 2015
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'samuel' into unstable
parents
d7d5a122
d573a2ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
35 deletions
+47
-35
cooccurrences.py
analysis/cooccurrences.py
+2
-1
ngrams.py
rest_v1_0/ngrams.py
+2
-18
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+43
-16
No files found.
analysis/cooccurrences.py
View file @
2f5962e3
...
...
@@ -91,6 +91,7 @@ def do_cooc(corpus=None
.
filter
(
Node
.
parent_id
==
corpus
.
id
,
Node
.
type_id
==
doc_id
)
.
filter
(
Hyperdata
.
name
==
field1
)
)
print
(
cooc_query
)
# Size of the ngrams between n_min and n_max
if
n_min
is
not
None
or
n_max
is
not
None
:
...
...
@@ -174,7 +175,7 @@ def do_cooc(corpus=None
if
isMonopartite
:
if
miam_id
is
not
None
:
miam_list
=
UnweightedList
(
miam_id
)
if
stop_id
is
not
None
:
stop_list
=
UnweightedList
(
stop_id
)
...
...
rest_v1_0/ngrams.py
View file @
2f5962e3
...
...
@@ -471,30 +471,13 @@ class Keep(APIView):
authentication_classes
=
(
SessionAuthentication
,
BasicAuthentication
)
def
get
(
self
,
request
,
corpus_id
):
print
(
""
)
print
(
""
)
print
(
""
)
print
(
"in HTTP/GET Keep():"
)
print
(
""
)
# list_id = session.query(Node).filter(Node.id==list_id).first()
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
first
()
print
(
"corpus:"
,
corpus
)
node_mapList
=
get_or_create_node
(
nodetype
=
'MapList'
,
corpus
=
corpus
)
print
(
"node_mapList:"
,
node_mapList
)
nodes_in_map
=
session
.
query
(
NodeNgram
)
.
filter
(
NodeNgram
.
node_id
==
node_mapList
.
id
)
.
all
()
results
=
{}
for
node
in
nodes_in_map
:
print
(
node
)
results
[
node
.
ngram_id
]
=
True
# ngram_2del = [int(i) for i in ngram_ids.split('+')]
# ngram_2del = session.query(NodeNgram).filter(NodeNgram.node_id==node_mapList.id , NodeNgram.ngram_id.in_(ngram_2del) ).all()
# for map_node in ngram_2del:
# session.delete(map_node)
# session.commit()
print
(
""
)
print
(
""
)
print
(
""
)
return
JsonHttpResponse
(
results
)
def
put
(
self
,
request
,
corpus_id
):
...
...
@@ -523,9 +506,10 @@ class Keep(APIView):
for
map_node
in
ngram_2del
:
try
:
session
.
delete
(
map_node
)
session
.
commit
()
except
:
pass
session
.
commit
()
return
JsonHttpResponse
(
True
,
201
)
...
...
static/js/NGrams_dyna_chart_and_table.js
View file @
2f5962e3
...
...
@@ -493,29 +493,43 @@ $("#Save_All").click(function(){
if
(
ngrams_map
[
AjaxRecords
[
id
][
"id"
]
]
)
{
if
(
AjaxRecords
[
id
][
"state"
]
==
0
||
AjaxRecords
[
id
][
"state"
]
==
2
)
{
FlagsBuffer
[
"outmap"
][
AjaxRecords
[
id
].
id
]
=
true
if
(
AjaxRecords
[
id
][
"state"
]
==
2
)
{
FlagsBuffer
[
"delete"
][
AjaxRecords
[
id
].
id
]
=
true
}
}
if
(
FlagsBuffer
[
"group"
][
AjaxRecords
[
id
].
id
]
&&
AjaxRecords
[
id
][
"state"
]
==
1
)
{
FlagsBuffer
[
"inmap"
][
AjaxRecords
[
id
].
id
]
=
true
}
}
else
{
if
(
AjaxRecords
[
id
][
"state"
]
==
1
)
{
FlagsBuffer
[
"inmap"
][
AjaxRecords
[
id
].
id
]
=
true
}
}
if
(
AjaxRecords
[
id
][
"state"
]
>
0
)
{
FlagsBuffer
[
System
[
0
].
states
[
AjaxRecords
[
id
].
state
]
]
[
AjaxRecords
[
id
].
id
]
=
true
if
(
AjaxRecords
[
id
][
"state"
]
==
2
)
{
FlagsBuffer
[
"delete"
][
AjaxRecords
[
id
].
id
]
=
true
}
}
}
// [ = = = = For deleting subforms = = = = ]
for
(
var
i
in
FlagsBuffer
[
"group"
]
)
{
for
(
var
i
in
ngrams_groups
.
links
)
{
if
(
FlagsBuffer
[
"delete"
][
i
])
{
for
(
var
j
in
ngrams_groups
.
links
[
i
]
)
{
FlagsBuffer
[
"delete"
][
ngrams_groups
.
links
[
i
][
j
]]
=
true
}
for
(
var
j
in
FlagsBuffer
[
"delete"
][
i
]
)
{
FlagsBuffer
[
"delete"
][
FlagsBuffer
[
"delete"
][
i
][
j
]]
=
true
}
}
if
(
FlagsBuffer
[
"inmap"
][
i
])
{
for
(
var
j
in
FlagsBuffer
[
"group"
][
i
]
)
{
FlagsBuffer
[
"
delete
"
][
FlagsBuffer
[
"group"
][
i
][
j
]]
=
true
FlagsBuffer
[
"
outmap
"
][
FlagsBuffer
[
"group"
][
i
][
j
]]
=
true
}
}
}
// [ = = = = / For deleting subforms = = = = ]
console
.
log
(
" = = = = = = = = = == "
)
console
.
log
(
"FlagsBuffer:"
)
console
.
log
(
FlagsBuffer
)
//
console.log(" = = = = = = = = = == ")
//
console.log("FlagsBuffer:")
//
console.log(FlagsBuffer)
var
nodes_2del
=
Object
.
keys
(
FlagsBuffer
[
"delete"
]).
map
(
Number
)
...
...
@@ -524,6 +538,21 @@ $("#Save_All").click(function(){
var
nodes_2inmap
=
$
.
extend
({},
FlagsBuffer
[
"inmap"
])
var
nodes_2outmap
=
$
.
extend
({},
FlagsBuffer
[
"outmap"
])
// console.log("")
// console.log("")
// console.log(" nodes_2del: ")
// console.log(nodes_2del)
// console.log(" nodes_2keep: ")
// console.log(nodes_2keep)
// console.log(" nodes_2group: ")
// console.log(nodes_2group)
// console.log(" nodes_2inmap: ")
// console.log(nodes_2inmap)
// console.log(" nodes_2outmap: ")
// console.log(nodes_2outmap)
// console.log("")
// console.log("")
var
list_id
=
$
(
"#list_id"
).
val
()
var
corpus_id
=
getIDFromURL
(
"corpus"
)
// not used
...
...
@@ -532,13 +561,14 @@ $("#Save_All").click(function(){
// // window.location.reload()
// });
CRUD
(
list_id
,
""
,
nodes_2del
,
[]
,
"DELETE"
),
$
(
"#Save_All"
).
append
(
'<img width="8%" src="/static/img/ajax-loader.gif"></img>'
)
CRUD
(
corpus_id
,
"/group"
,
[]
,
nodes_2group
,
"PUT"
)
$
.
doTimeout
(
1000
,
function
(){
CRUD
(
corpus_id
,
"/keep"
,
[]
,
nodes_2
outmap
,
"DELETE
"
)
CRUD
(
corpus_id
,
"/keep"
,
[]
,
nodes_2
inmap
,
"PUT
"
)
$
.
doTimeout
(
1000
,
function
(){
CRUD
(
corpus_id
,
"/keep"
,
[]
,
nodes_2
inmap
,
"PUT
"
)
CRUD
(
corpus_id
,
"/keep"
,
[]
,
nodes_2
outmap
,
"DELETE
"
)
$
.
doTimeout
(
1000
,
function
(){
CRUD
(
corpus_id
,
"/group"
,
[]
,
nodes_2group
,
"PUT"
)
CRUD
(
list_id
,
""
,
nodes_2del
,
[]
,
"DELETE"
),
$
.
doTimeout
(
1000
,
function
(){
window
.
location
.
reload
()
});
...
...
@@ -549,11 +579,8 @@ $("#Save_All").click(function(){
});
function
CRUD
(
parent_id
,
action
,
nodes
,
args
,
http_method
)
{
console
.
log
(
http_method
+
" : "
+
action
)
var
the_url
=
window
.
location
.
origin
+
"/api/node/"
+
parent_id
+
"/ngrams"
+
action
+
"/"
+
nodes
.
join
(
"+"
);
the_url
=
the_url
.
replace
(
/
\/
$/
,
""
);
//remove trailing slash
console
.
log
(
the_url
)
console
.
log
(
args
)
if
(
nodes
.
length
>
0
||
Object
.
keys
(
args
).
length
>
0
)
{
$
.
ajax
({
method
:
http_method
,
...
...
@@ -630,7 +657,7 @@ function Main_test( data , initial) {
var
node_info
=
{
"id"
:
le_ngram
.
id
,
"name"
:
le_ngram
.
name
,
"name"
:
le_ngram
.
id
+
"_"
+
le_ngram
.
name
,
"score"
:
le_ngram
.
scores
[
FirstScore
],
//le_ngram.scores.tfidf_sum / le_ngram.scores.occ_uniq,
"flag"
:
false
,
"group_plus"
:
true
,
...
...
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