Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Get Rankings
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dacosta
Get Rankings
Commits
bc5b0bf5
Commit
bc5b0bf5
authored
2 years ago
by
nicolas.ollinger
Browse files
Options
Downloads
Patches
Plain Diff
fetch by Title
parent
25226511
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
get_rankings/jranker.py
+23
-9
23 additions, 9 deletions
get_rankings/jranker.py
with
23 additions
and
9 deletions
get_rankings/jranker.py
+
23
−
9
View file @
bc5b0bf5
...
@@ -7,6 +7,17 @@ from tqdm import tqdm
...
@@ -7,6 +7,17 @@ from tqdm import tqdm
SCIMAGOURL
=
"
https://www.scimagojr.com/journalrank.php?year={}&type=j&out=xls
"
SCIMAGOURL
=
"
https://www.scimagojr.com/journalrank.php?year={}&type=j&out=xls
"
def
fetchifneeded
(
f
):
def
wrapper
(
self
,
year
,
*
args
):
res
=
f
(
self
,
year
,
*
args
)
if
res
is
None
and
not
self
.
fetched
(
year
):
self
.
fetch_scimago_year
(
year
)
res
=
f
(
self
,
year
,
*
args
)
return
res
return
wrapper
class
SJR
:
class
SJR
:
def
__init__
(
self
,
database
):
def
__init__
(
self
,
database
):
self
.
con
=
sqlite3
.
connect
(
database
)
self
.
con
=
sqlite3
.
connect
(
database
)
...
@@ -33,18 +44,19 @@ class SJR:
...
@@ -33,18 +44,19 @@ class SJR:
(
title
,
issn
,
year
,
quartiles
),
(
title
,
issn
,
year
,
quartiles
),
)
)
def
raw_by_ISSN
(
self
,
issn
,
year
):
@fetchifneeded
def
by_ISSN
(
self
,
year
,
issn
):
self
.
cursor
.
execute
(
self
.
cursor
.
execute
(
"
SELECT * FROM sjr_journals WHERE ISSN=? AND Year=?
"
,
(
issn
,
year
)
"
SELECT * FROM sjr_journals WHERE ISSN=? AND Year=?
"
,
(
issn
,
year
)
)
)
return
self
.
cursor
.
fetchone
()
return
self
.
cursor
.
fetchone
()
def
by_ISSN
(
self
,
issn
,
year
):
@fetchifneeded
res
=
self
.
raw_by_ISSN
(
issn
,
year
)
def
by_Title
(
self
,
year
,
title
):
if
res
is
None
and
not
self
.
fetched
(
year
):
self
.
cursor
.
execute
(
self
.
fetch_scimago_year
(
year
)
"
SELECT * FROM sjr_journals WHERE Title=? AND Year=?
"
,
(
title
,
year
)
res
=
self
.
raw_by_ISSN
(
issn
,
year
)
)
return
res
return
self
.
cursor
.
fetchone
()
def
fetched
(
self
,
year
):
def
fetched
(
self
,
year
):
self
.
cursor
.
execute
(
"
SELECT Year FROM fetched WHERE Year=?
"
,
(
year
,))
self
.
cursor
.
execute
(
"
SELECT Year FROM fetched WHERE Year=?
"
,
(
year
,))
...
@@ -84,13 +96,15 @@ class SJR:
...
@@ -84,13 +96,15 @@ class SJR:
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
sjr
=
SJR
(
"
/tmp/lapin.db
"
)
sjr
=
SJR
(
"
/tmp/lapin.db
"
)
print
(
"
** A few rankings
\n
"
)
print
(
"
** A few rankings
\n
"
)
for
pair
in
[(
"
25206508
"
,
2020
)
,
(
"
00045411
"
,
2018
)]:
for
pair
in
[(
2020
,
"
25206508
"
)
,
(
2018
,
"
00045411
"
)]:
print
(
"
"
,
"
;
"
.
join
(
map
(
str
,
sjr
.
by_ISSN
(
*
pair
))))
print
(
"
"
,
"
;
"
.
join
(
map
(
str
,
sjr
.
by_ISSN
(
*
pair
))))
for
pair
in
[(
2020
,
"
Journal of the ACM
"
)]:
print
(
"
"
,
"
;
"
.
join
(
map
(
str
,
sjr
.
by_Title
(
*
pair
))))
print
(
"
\n
** Evolution from 2019 to 2021
\n
"
)
print
(
"
\n
** Evolution from 2019 to 2021
\n
"
)
for
issn
in
[
"
10902724
"
,
"
03043975
"
,
"
14627264
"
,
"
22105379
"
,
"
00045411
"
]:
for
issn
in
[
"
10902724
"
,
"
03043975
"
,
"
14627264
"
,
"
22105379
"
,
"
00045411
"
]:
q
=
[]
q
=
[]
for
year
in
[
2019
,
2020
,
2021
]:
for
year
in
[
2019
,
2020
,
2021
]:
res
=
sjr
.
by_ISSN
(
issn
,
year
)
res
=
sjr
.
by_ISSN
(
year
,
issn
)
title
=
res
[
0
]
title
=
res
[
0
]
q
.
append
(
res
[
3
])
q
.
append
(
res
[
3
])
print
(
f
"
{
title
}
:
{
'
,
'
.
join
(
q
)
}
"
)
print
(
f
"
{
title
}
:
{
'
,
'
.
join
(
q
)
}
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment