gemantic_scholar 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gemantic_scholar.rb +17 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e89a59d23a25108e977f593a9130553bcb118ad4bdd037f2bbc81dd15ed70cd
|
4
|
+
data.tar.gz: 1060bc3d885575d44dd77394e7a3a5315038ab6ab2b207911ac1a84bc06d4902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2970a073e03e04abe579dfac06b86381f593807e10bdede951400165ff4e989dfa5b51164786253be592a6edc0df83209d0059ca183041431d4ed2202d1d0bd
|
7
|
+
data.tar.gz: 2079652feeec289c38b9749edf7165dbb10975a7cd52bed409ed0f2ac596d3705159d0b91303e0c4c6b2796ab168979d430014dc78d161cfb7de07bd7956cd51
|
data/lib/gemantic_scholar.rb
CHANGED
@@ -6,8 +6,8 @@ end
|
|
6
6
|
|
7
7
|
class GemanticScholar::Paper
|
8
8
|
attr_accessor :paper_data
|
9
|
-
def initialize(
|
10
|
-
@paper_data = JSON.parse(fetch_paper(
|
9
|
+
def initialize(paper_id, id_type)
|
10
|
+
@paper_data = JSON.parse(fetch_paper(paper_id, id_type))
|
11
11
|
end
|
12
12
|
|
13
13
|
def abstract
|
@@ -66,8 +66,21 @@ class GemanticScholar::Paper
|
|
66
66
|
self.publisher
|
67
67
|
end
|
68
68
|
|
69
|
-
def fetch_paper(
|
70
|
-
|
69
|
+
def fetch_paper(paper_id, id_type)
|
70
|
+
if id_type == 'arxiv'
|
71
|
+
id_param = "arXiv:#{paper_id}"
|
72
|
+
elsif id_type == 'mag'
|
73
|
+
id_param = "MAG:#{paper_id}"
|
74
|
+
elsif id_type == 'acl'
|
75
|
+
id_param = "ACL:#{paper_id}"
|
76
|
+
elsif id_type == 'pubmed'
|
77
|
+
id_param = "PMID:#{paper_id}"
|
78
|
+
elsif id_type == 'corpus'
|
79
|
+
id_param = "CorpusID:#{paper_id}"
|
80
|
+
else
|
81
|
+
id_param = paper_id
|
82
|
+
end
|
83
|
+
uri = URI("https://api.semanticscholar.org/v1/paper/#{id_param}?include_unknown_references=true")
|
71
84
|
rsp = Net::HTTP.get_response(uri)
|
72
85
|
if rsp.code == '404'
|
73
86
|
return '["404: No paper found"]'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemantic_scholar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Compton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Utility to pull and parse Semantic Scholar api data
|
14
14
|
email: jecompton@gmail.com
|