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
70fa1a13
Commit
70fa1a13
authored
Aug 07, 2017
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] need to fix the crawler.
parent
0ae8c136
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
779 deletions
+64
-779
AdvancedTutorial.ipynb
AdvancedTutorial.ipynb
+0
-764
HAL.py
gargantext/util/crawlers/HAL.py
+1
-1
HAL.py
gargantext/util/parsers/HAL.py
+11
-10
notebook.run
install/notebook.run
+1
-1
gargantext_notebook.py
install/notebook/gargantext_notebook.py
+51
-3
No files found.
AdvancedTutorial.ipynb
deleted
100644 → 0
View file @
0ae8c136
This diff is collapsed.
Click to expand it.
gargantext/util/crawlers/HAL.py
View file @
70fa1a13
...
@@ -113,7 +113,7 @@ class HalCrawler(Crawler):
...
@@ -113,7 +113,7 @@ class HalCrawler(Crawler):
msg
=
"Invalid sample size N =
%
i (max =
%
i)"
%
(
self
.
query_max
msg
=
"Invalid sample size N =
%
i (max =
%
i)"
%
(
self
.
query_max
,
QUERY_SIZE_N_MAX
,
QUERY_SIZE_N_MAX
)
)
print
(
"ERROR (scrap:
Multivac
d/l ): "
,
msg
)
print
(
"ERROR (scrap:
HAL
d/l ): "
,
msg
)
self
.
query_max
=
QUERY_SIZE_N_MAX
self
.
query_max
=
QUERY_SIZE_N_MAX
#for page in range(1, trunc(self.query_max / 100) + 2):
#for page in range(1, trunc(self.query_max / 100) + 2):
...
...
gargantext/util/parsers/HAL.py
View file @
70fa1a13
...
@@ -11,17 +11,8 @@ from datetime import datetime
...
@@ -11,17 +11,8 @@ from datetime import datetime
import
json
import
json
class
HalParser
(
Parser
):
class
HalParser
(
Parser
):
def
_parse
(
self
,
json_docs
):
def
parse
(
self
,
filebuf
):
'''
parse :: FileBuff -> [Hyperdata]
'''
contents
=
filebuf
.
read
()
.
decode
(
"UTF-8"
)
data
=
json
.
loads
(
contents
)
filebuf
.
close
()
json_docs
=
data
hyperdata_list
=
[]
hyperdata_list
=
[]
hyperdata_path
=
{
"id"
:
"isbn_s"
hyperdata_path
=
{
"id"
:
"isbn_s"
...
@@ -73,3 +64,13 @@ class HalParser(Parser):
...
@@ -73,3 +64,13 @@ class HalParser(Parser):
hyperdata_list
.
append
(
hyperdata
)
hyperdata_list
.
append
(
hyperdata
)
return
hyperdata_list
return
hyperdata_list
def
parse
(
self
,
filebuf
):
'''
parse :: FileBuff -> [Hyperdata]
'''
contents
=
filebuf
.
read
()
.
decode
(
"UTF-8"
)
data
=
json
.
loads
(
contents
)
return
self
.
_parse
(
data
)
install/notebook.run
View file @
70fa1a13
...
@@ -16,7 +16,7 @@ sudo docker run \
...
@@ -16,7 +16,7 @@ sudo docker run \
--env
POSTGRES_HOST
=
localhost
\
--env
POSTGRES_HOST
=
localhost
\
-v
/srv/gargantext:/srv/gargantext
\
-v
/srv/gargantext:/srv/gargantext
\
-it
garg-notebook:latest
\
-it
garg-notebook:latest
\
/bin/bash
-c
"/bin/su notebooks -c 'source /env_3-5/bin/activate && cd /
srv/gargantext/
&& jupyter notebook --port=8899 --ip=0.0.0.0 --no-browser'"
/bin/bash
-c
"/bin/su notebooks -c 'source /env_3-5/bin/activate && cd /
home/notebooks
&& jupyter notebook --port=8899 --ip=0.0.0.0 --no-browser'"
# #&& jupyter nbextension enable --py widgetsnbextension --sys-prefix
# #&& jupyter nbextension enable --py widgetsnbextension --sys-prefix
#/bin/bash -c "/bin/su notebooks -c 'source /env_3-5/bin/activate && cd /srv/gargantext/ && jupyter notebook --port=8899 --ip=0.0.0.0 --no-browser --notebook-dir=/home/notebooks/'"
#/bin/bash -c "/bin/su notebooks -c 'source /env_3-5/bin/activate && cd /srv/gargantext/ && jupyter notebook --port=8899 --ip=0.0.0.0 --no-browser --notebook-dir=/home/notebooks/'"
...
...
install/notebook/gargantext_notebook.py
View file @
70fa1a13
...
@@ -22,7 +22,7 @@ application = get_wsgi_application()
...
@@ -22,7 +22,7 @@ application = get_wsgi_application()
from
gargantext.util.toolchain.main
import
parse_extract_indexhyperdata
from
gargantext.util.toolchain.main
import
parse_extract_indexhyperdata
from
gargantext.util.db
import
*
from
gargantext.util.db
import
*
from
gargantext.models
import
Node
from
gargantext.models
import
Node
from
gargantext.util.toolchain.main
import
parse_extract_indexhyperdata
from
nltk.tokenize
import
wordpunct_tokenize
from
nltk.tokenize
import
wordpunct_tokenize
from
gargantext.models
import
*
from
gargantext.models
import
*
...
@@ -56,9 +56,7 @@ def chart(docs, field):
...
@@ -56,9 +56,7 @@ def chart(docs, field):
frame1
=
pd
.
DataFrame
(
year_publis
,
columns
=
[
'Date'
,
'DateValue'
],
index
=
frame0
.
Date
)
frame1
=
pd
.
DataFrame
(
year_publis
,
columns
=
[
'Date'
,
'DateValue'
],
index
=
frame0
.
Date
)
return
frame1
return
frame1
from
gargantext.util.crawlers.HAL
import
HalCrawler
from
gargantext.util.crawlers.HAL
import
HalCrawler
def
scan_hal
(
request
):
def
scan_hal
(
request
):
hal
=
HalCrawler
()
hal
=
HalCrawler
()
return
hal
.
scan_results
(
request
)
return
hal
.
scan_results
(
request
)
...
@@ -73,3 +71,53 @@ def scan_gargantext(corpus_id, lang, request):
...
@@ -73,3 +71,53 @@ def scan_gargantext(corpus_id, lang, request):
return
[
i
for
i
in
connection
.
execute
(
query
)][
0
][
0
]
return
[
i
for
i
in
connection
.
execute
(
query
)][
0
][
0
]
connection
.
close
()
connection
.
close
()
def
myProject_fromUrl
(
url
):
"""
myProject :: String -> Project
"""
project_id
=
url
.
split
(
"/"
)[
4
]
project
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
project_id
)
.
first
()
return
project
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
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'
)
)
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