gemantic_scholar 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/gemantic_scholar.rb +70 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '083f4ea133b7cc306442281f05d90e1f7d9938ae90f1b3dce9036892d822c486'
4
+ data.tar.gz: 50b6e474a749095a2dabd61451b9149f04c7aeed6b6487e5880ae7fdd8c99c12
5
+ SHA512:
6
+ metadata.gz: 1c0a8cf863e554018306d635511b071c9a14c39fb9ee279e3b6a7cc349124c0568ae3a03820a6fff782592f63277e17025d1a8acc1cd224edc885e489c63bc6a
7
+ data.tar.gz: 14c633404914bb7d2c74a264c69818688930e6ccbe327a34c3b1d2785a4db3a5a4759f28e4d5709871e4a94612a6d53ecce35c7b375d79eb0c586a92e05376f4
@@ -0,0 +1,70 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ class GemanticScholar
5
+ end
6
+
7
+ class GemanticScholar::Paper
8
+ attr_accessor :paper_data
9
+ def initialize(arxiv_id)
10
+ @paper_data = JSON.parse(fetch_paper(arxiv_id))
11
+ end
12
+
13
+ def abstract
14
+ paper_data['abstract']
15
+ end
16
+
17
+ def arxiv_id
18
+ paper_data['arxivId']
19
+ end
20
+
21
+ def authors
22
+ paper_data['authors']
23
+ end
24
+
25
+ def citations
26
+ paper_data['citations']
27
+ end
28
+
29
+ def doi
30
+ paper_data['doi']
31
+ end
32
+
33
+ def references
34
+ paper_data['references']
35
+ end
36
+
37
+ def works_cited
38
+ self.references
39
+ end
40
+
41
+ def title
42
+ paper_data['title']
43
+ end
44
+
45
+ def topics
46
+ paper_data['topis']
47
+ end
48
+
49
+ def year
50
+ paper_data['year']
51
+ end
52
+
53
+ def publisher
54
+ paper_data['venue']
55
+ end
56
+
57
+ def venue
58
+ self.publisher
59
+ end
60
+
61
+ def fetch_paper(arxiv_id)
62
+ uri = URI("https://api.semanticscholar.org/v1/paper/arXiv:#{arxiv_id}?include_unknown_references=true")
63
+ rsp = Net::HTTP.get_response(uri)
64
+ if rsp.code == '404'
65
+ return '["404: No paper found"]'
66
+ else
67
+ return rsp.body
68
+ end
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gemantic_scholar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Compton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Utility to pull and parse Semantic Scholar api data
14
+ email: jecompton@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/gemantic_scholar.rb
20
+ homepage: https://rubygems.org/gems/gemantic_scholar
21
+ licenses:
22
+ - GPL-3.0-only
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.1.2
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Semantic Scholar utility
43
+ test_files: []