Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
a54c3941
Commit
a54c3941
authored
Jan 07, 2021
by
LE GAC Renaud
Browse files
Update store_tools/base.py to add is_conference and friends to new inspirehep API
parent
397a56c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
25 deletions
+30
-25
modules/store_tools/base.py
modules/store_tools/base.py
+30
-25
No files found.
modules/store_tools/base.py
View file @
a54c3941
...
...
@@ -43,6 +43,10 @@ THESIS_DIR = "dir."
def
is_conference
(
recjson
):
"""True when the record describes a publication related to a conference.
Note:
This tools works for JSON record coming from cds.cern.ch,
old.inspirehep.net as well as inspirehep.net
Args:
recjson (dict):
record associated to a publication or to and institute.
...
...
@@ -53,8 +57,13 @@ def is_conference(recjson):
to a conference.
"""
# ConferencePaper in collection
# find proceeding in both stores
# proceeding in inspirehep
if
recjson
.
get
(
"$schema"
,
""
).
endswith
(
"hep.json"
):
for
elt
in
recjson
.
get
(
"document_type"
,
[]):
if
elt
==
"conference paper"
:
return
True
# proceeding in cds
if
"collection"
in
recjson
:
data
=
recjson
[
"collection"
]
data
=
(
data
if
isinstance
(
data
,
list
)
else
[
data
])
...
...
@@ -65,7 +74,7 @@ def is_conference(recjson):
if
len
(
li
)
>
0
:
return
True
#
try to identify
talk in cds
# talk in cds
# look for a conference key or for a subject equal to Talk
found
=
\
(
"aleph_linking_page"
in
recjson
)
or
\
...
...
@@ -76,21 +85,16 @@ def is_conference(recjson):
if
found
:
return
True
# try to identify talk in inspirehep
# look for a conference key
found
=
\
(
"publication_info"
in
recjson
and
"cnum"
in
recjson
[
"publication_info"
])
if
found
:
return
True
return
False
def
is_institute
(
recjson
):
"""True when the record describes an institute.
Note:
This tools works for JSON record coming from cds.cern.ch,
old.inspirehep.net as well as inspirehep.net
Args:
recjson (dict):
record associated to a publication or to and institute.
...
...
@@ -100,23 +104,16 @@ def is_institute(recjson):
``True`` when the record describes an institute.
"""
# INSTITUTION in collection
if
"collection"
in
recjson
:
data
=
recjson
[
"collection"
]
data
=
(
data
if
isinstance
(
data
,
list
)
else
[
data
])
value
=
"INSTITUTION"
li
=
[
di
for
di
in
data
if
"primary"
in
di
and
di
[
"primary"
]
==
value
]
if
len
(
li
)
>
0
:
return
True
return
False
return
recjson
.
get
(
"$schema"
,
""
).
endswith
(
"institutions.json"
)
def
is_thesis
(
recjson
):
"""True when the record describes a thesis.
Note:
This tools works for JSON record coming from cds.cern.ch,
old.inspirehep.net as well as inspirehep.net
Args:
recjson (dict):
record associated to a publication or to and institute.
...
...
@@ -125,7 +122,13 @@ def is_thesis(recjson):
bool: ``True`` when the record describes a thesis.
"""
# THESIS in collection
# Thesis in inspirehep
if
recjson
.
get
(
"$schema"
,
""
).
endswith
(
"hep.json"
):
for
elt
in
recjson
.
get
(
"document_type"
,
[]):
if
elt
==
"thesis"
:
return
True
# Thesis in cds
if
"collection"
in
recjson
:
data
=
recjson
[
"collection"
]
data
=
(
data
if
isinstance
(
data
,
list
)
else
[
data
])
...
...
@@ -135,3 +138,5 @@ def is_thesis(recjson):
if
len
(
li
)
>
0
:
return
True
return
False
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