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
fc33b3c8
Commit
fc33b3c8
authored
Aug 11, 2017
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trailing spaces
parent
d75224b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
gargantext_notebook.py
install/notebook/gargantext_notebook.py
+10
-10
No files found.
install/notebook/gargantext_notebook.py
View file @
fc33b3c8
...
...
@@ -58,9 +58,9 @@ def scan_gargantext(corpus_id, lang, request):
connection
=
get_engine
()
.
connect
()
# TODO add some sugar the request (ideally request should be the same for hal and garg)
query
=
"""select count(n.id) from nodes n
where to_tsvector('
%
s', hyperdata ->> 'abstract' || 'title')
where to_tsvector('
%
s', hyperdata ->> 'abstract' || 'title')
@@ to_tsquery('
%
s')
AND n.parent_id =
%
s;"""
%
(
lang
,
request
,
corpus_id
)
AND n.parent_id =
%
s;"""
%
(
lang
,
request
,
corpus_id
)
return
[
i
for
i
in
connection
.
execute
(
query
)][
0
][
0
]
connection
.
close
()
...
...
@@ -76,28 +76,28 @@ def myProject_fromUrl(url):
def
newCorpus
(
project
,
resourceName
=
11
,
name
=
"Machine learning"
,
query
=
"LSTM"
):
print
(
"Corpus
\"
%
s
\"
in project
\"
%
s
\"
created"
%
(
name
,
project
.
name
))
corpus
=
project
.
add_child
(
name
=
"Corpus name"
,
typename
=
'CORPUS'
)
corpus
.
hyperdata
[
"resources"
]
=
[{
"extracted"
:
"true"
,
"type"
:
11
}]
corpus
.
hyperdata
[
"statuses"
]
=
[{
"action"
:
"notebook"
,
"complete"
:
"true"
}]
# [TODO] Add informations needed to get buttons on the Project view.
session
.
add
(
corpus
)
session
.
commit
()
hal
=
HalCrawler
()
max_result
=
hal
.
scan_results
(
query
)
paging
=
100
paging
=
100
for
page
in
range
(
0
,
max_result
,
paging
):
print
(
"
%
s documents downloaded /
%
s."
%
(
str
(
paging
*
(
page
+
1
)),
str
(
max_result
)
))
docs
=
(
hal
.
_get
(
query
,
fromPage
=
page
,
count
=
paging
)
.
get
(
"response"
,
{})
.
get
(
"docs"
,
[])
)
from
gargantext.util.parsers.HAL
import
HalParser
# [TODO] fix boilerplate for docs here
new_docs
=
HalParser
(
docs
)
.
_parse
(
docs
)
for
doc
in
new_docs
:
new_doc
=
(
corpus
.
add_child
(
name
=
doc
[
"title"
][:
255
]
,
typename
=
'DOCUMENT'
)
...
...
@@ -105,12 +105,12 @@ def newCorpus(project, resourceName=11, name="Machine learning", query="LSTM"):
new_doc
[
"hyperdata"
]
=
doc
session
.
add
(
new_doc
)
session
.
commit
()
print
(
"Extracting the ngrams"
)
parse_extract_indexhyperdata
(
corpus
)
print
(
"Corpus is ready to explore:"
)
print
(
"http://imt.gargantext.org/projects/
%
s/corpora/
%
s/"
%
(
project
.
id
,
corpus
.
id
))
return
corpus
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