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
15e05ccc
Commit
15e05ccc
authored
Apr 12, 2017
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REPEC/PARSERS] Some fixes (filepath, type corrections in others parsers.
parent
e963d77a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
13 deletions
+87
-13
MULTIVAC.py
gargantext/util/crawlers/MULTIVAC.py
+11
-11
ISTEX.py
gargantext/util/parsers/ISTEX.py
+1
-1
MULTIVAC.py
gargantext/util/parsers/MULTIVAC.py
+74
-0
PUBMED.py
gargantext/util/parsers/PUBMED.py
+1
-1
No files found.
gargantext/util/crawlers/MULTIVAC.py
View file @
15e05ccc
...
@@ -8,8 +8,10 @@
...
@@ -8,8 +8,10 @@
from
._Crawler
import
*
from
._Crawler
import
*
import
json
import
json
from
gargantext.settings
import
API_TOKENS
from
gargantext.settings
import
API_TOKENS
from
gargantext.constants
import
UPLOAD_DIRECTORY
from
math
import
trunc
from
math
import
trunc
from
gargantext.util.files
import
save
class
MultivacCrawler
(
Crawler
):
class
MultivacCrawler
(
Crawler
):
''' Multivac API CLIENT'''
''' Multivac API CLIENT'''
...
@@ -79,8 +81,9 @@ class MultivacCrawler(Crawler):
...
@@ -79,8 +81,9 @@ class MultivacCrawler(Crawler):
return
self
.
results_nb
return
self
.
results_nb
def
download
(
self
,
query
):
def
download
(
self
,
query
):
self
.
path
=
"/tmp/MultivacResults.xml"
downloaded
=
False
downloaded
=
False
self
.
status
.
append
(
"fetching results"
)
self
.
status
.
append
(
"fetching results"
)
corpus
=
[]
corpus
=
[]
...
@@ -92,15 +95,12 @@ class MultivacCrawler(Crawler):
...
@@ -92,15 +95,12 @@ class MultivacCrawler(Crawler):
print
(
"ERROR (scrap: multivac d/l ): "
,
msg
)
print
(
"ERROR (scrap: multivac 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
)
+
1
):
with
open
(
self
.
path
,
'wb'
)
as
f
:
docs
=
self
.
_get
(
query
,
fromPage
=
page
,
count
=
paging
)[
"results"
][
"hits"
]
#for page in range(1, self.query_max, paging):
for
doc
in
docs
:
for
page
in
range
(
1
,
trunc
(
self
.
query_max
/
100
)
+
1
):
corpus
.
append
(
doc
)
docs
=
self
.
_get
(
query
,
fromPage
=
page
,
count
=
paging
)[
"results"
][
"hits"
]
for
doc
in
docs
:
corpus
.
append
(
doc
)
f
.
write
(
json
.
dumps
(
corpus
)
.
encode
(
"utf-8"
)
)
self
.
path
=
save
(
json
.
dumps
(
corpus
)
.
encode
(
"utf-8"
),
name
=
'Multivac'
,
basedir
=
UPLOAD_DIRECTORY
)
downloaded
=
True
downloaded
=
True
return
downloaded
return
downloaded
gargantext/util/parsers/ISTEX.py
View file @
15e05ccc
...
@@ -104,7 +104,7 @@ class ISTexParser(Parser):
...
@@ -104,7 +104,7 @@ class ISTexParser(Parser):
RealDate
=
RealDate
[
0
]
RealDate
=
RealDate
[
0
]
# print( RealDate ," | length:",len(RealDate))
# print( RealDate ," | length:",len(RealDate))
Decision
=
""
Decision
=
True
if
len
(
RealDate
)
>
4
:
if
len
(
RealDate
)
>
4
:
if
len
(
RealDate
)
>
8
:
if
len
(
RealDate
)
>
8
:
try
:
Decision
=
datetime
.
strptime
(
RealDate
,
'
%
Y-
%
b-
%
d'
)
.
date
()
try
:
Decision
=
datetime
.
strptime
(
RealDate
,
'
%
Y-
%
b-
%
d'
)
.
date
()
...
...
gargantext/util/parsers/MULTIVAC.py
0 → 100644
View file @
15e05ccc
from
._Parser
import
Parser
from
datetime
import
datetime
import
json
class
MultivacParser
(
Parser
):
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_path
=
{
"id"
:
"id"
,
"title"
:
"title"
,
"abstract"
:
"abstract"
,
"type"
:
"type"
}
suma
=
0
for
json_doc
in
json_docs
:
hyperdata
=
{}
doc
=
json_doc
[
"_source"
]
for
key
,
path
in
hyperdata_path
.
items
():
hyperdata
[
key
]
=
doc
.
get
(
path
,
""
)
hyperdata
[
"source"
]
=
doc
.
get
(
"serial"
,
{})
\
.
get
(
"journaltitle"
,
"REPEC Database"
)
try
:
hyperdata
[
"url"
]
=
doc
.
get
(
"file"
,
{})
\
.
get
(
"url"
,
""
)
except
:
pass
hyperdata
[
"authors"
]
=
", "
.
join
(
[
p
.
get
(
"person"
,
{})
.
get
(
"name"
,
""
)
for
p
in
doc
.
get
(
"hasauthor"
,
[])
]
)
year
=
doc
.
get
(
"serial"
,
{})
\
.
get
(
"issuedate"
,
None
)
if
year
is
None
:
year
=
datetime
.
now
()
else
:
try
:
date
=
datetime
.
strptime
(
year
,
'
%
Y'
)
except
:
print
(
"FIX DATE MULTIVAC REPEC
%
s"
%
year
)
year
=
datetime
.
now
()
hyperdata
[
"publication_date"
]
=
date
hyperdata
[
"publication_year"
]
=
str
(
date
.
year
)
hyperdata
[
"publication_month"
]
=
str
(
date
.
month
)
hyperdata
[
"publication_day"
]
=
str
(
date
.
day
)
hyperdata_list
.
append
(
hyperdata
)
return
hyperdata_list
gargantext/util/parsers/PUBMED.py
View file @
15e05ccc
...
@@ -78,7 +78,7 @@ class PubmedParser(Parser):
...
@@ -78,7 +78,7 @@ class PubmedParser(Parser):
if
"publication_month"
in
hyperdata
:
PubmedDate
+=
" "
+
hyperdata
[
"publication_month"
]
if
"publication_month"
in
hyperdata
:
PubmedDate
+=
" "
+
hyperdata
[
"publication_month"
]
if
"publication_day"
in
hyperdata
:
PubmedDate
+=
" "
+
hyperdata
[
"publication_day"
]
if
"publication_day"
in
hyperdata
:
PubmedDate
+=
" "
+
hyperdata
[
"publication_day"
]
Decision
=
""
Decision
=
True
if
len
(
RealDate
)
>
4
:
if
len
(
RealDate
)
>
4
:
if
len
(
RealDate
)
>
8
:
if
len
(
RealDate
)
>
8
:
try
:
Decision
=
datetime
.
strptime
(
RealDate
,
'
%
Y
%
b
%
d'
)
.
date
()
try
:
Decision
=
datetime
.
strptime
(
RealDate
,
'
%
Y
%
b
%
d'
)
.
date
()
...
...
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