arx 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +330 -1
- data/lib/arx/categories.rb +10 -0
- data/lib/arx/entities/category.rb +1 -1
- data/lib/arx/entities/paper.rb +4 -0
- data/lib/arx/query/query.rb +1 -1
- data/lib/arx/version.rb +1 -1
- data/lib/arx.rb +14 -12
- 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: 060171d105d65f9380f65232ebc4ba838c88c0ea83a1019f07b7ee54c5156cd6
|
4
|
+
data.tar.gz: e8253d7a61f2954f1b5522b7ed98cabd1103973bb85d29bf7f4ace357e2739ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c7ca66790bd3688556174120132e6eae5618202a32d05fe4b9c10c07892ca5e92f9bf71da3adf8f17cbc9a94a05550ed194c85a4dda69217920f2eda230daff
|
7
|
+
data.tar.gz: 8cf1b676f6f18494a1b8b91678b2668ef110114b9987204e92a0ddc6d38001c9bcaa8ae3c065562329c806069a25cfd4ff2ce1ffba28838b27e6e46708f87c55
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# 0.3.0
|
2
|
+
|
3
|
+
#### Major changes
|
4
|
+
|
5
|
+
- Add documentation, images, installation and usage instructions to `README.md`. ([#22](https://github.com/eonu/arx/pull/22), [#17](https://github.com/eonu/arx/pull/17))
|
6
|
+
- Allow prior construction of a search query in `Arx.search`. ([#18](https://github.com/eonu/arx/pull/18))
|
7
|
+
- Fix `Arx.search` query object yielding. ([#20](https://github.com/eonu/arx/pull/20))
|
8
|
+
|
9
|
+
#### Minor changes
|
10
|
+
|
11
|
+
- Remove conditional with `block_given?` in `Arx()` method. ([#16](https://github.com/eonu/arx/pull/16))
|
12
|
+
- Remove leading ampersand (&) from search query string. ([#19](https://github.com/eonu/arx/pull/19))
|
13
|
+
- Add base paper categories and more aliases. ([#21](https://github.com/eonu/arx/pull/21))
|
14
|
+
|
1
15
|
# 0.2.0
|
2
16
|
|
3
17
|
#### Major changes
|
data/README.md
CHANGED
@@ -10,4 +10,333 @@
|
|
10
10
|
[![Documentation](https://img.shields.io/badge/docs-rubydoc.info-blue.svg)](https://www.rubydoc.info/gems/arx/toplevel)
|
11
11
|
[![Build Status](https://travis-ci.com/eonu/arx.svg?branch=master)](https://travis-ci.com/eonu/arx)
|
12
12
|
|
13
|
-
A Ruby interface for querying academic papers on the arXiv search API
|
13
|
+
**A Ruby interface for querying academic papers on the arXiv search API.**
|
14
|
+
|
15
|
+
<img src="https://i.ibb.co/19Djpzk/arxiv.png" width="25%" align="left"></img>
|
16
|
+
|
17
|
+
> arXiv is an e-print service in the fields of physics, mathematics, non-linear science, computer science, quantitative biology, quantitative finance and statistics.
|
18
|
+
|
19
|
+
---
|
20
|
+
|
21
|
+
[arXiv](https://arxiv.org/) provides an advanced search utility (shown left) on their website, as well as an extensive [search API](https://arxiv.org/help/api) that allows for the external querying of academic papers hosted on their website.
|
22
|
+
|
23
|
+
Although [Scholastica](https://github.com/scholastica) offer a great [Ruby gem](https://github.com/scholastica/arxiv) for retrieving papers from arXiv through the search API, this gem is only intended for retrieving one paper at a time, and only supports searching for paper by ID.
|
24
|
+
|
25
|
+
*Arx is a gem that allows for quick and easy querying of the arXiv search API, without having to worry about manually writing your own search query strings or parse the resulting XML query response to find the data you need.*
|
26
|
+
|
27
|
+
## Features
|
28
|
+
|
29
|
+
- Ruby classes `Arx::Paper`, `Arx::Author` and `Arx::Category` that wrap the resulting Atom XML query result from the search API.
|
30
|
+
- Supports querying by a paper's ID, title, author(s), abstract, subject category, comment, journal reference, or report number.
|
31
|
+
- Provides a small embedded DSL for writing queries.
|
32
|
+
- Supports searching fields by exact match.
|
33
|
+
|
34
|
+
## Installation
|
35
|
+
|
36
|
+
To install Arx, run the following in your terminal:
|
37
|
+
|
38
|
+
```bash
|
39
|
+
$ gem install arx
|
40
|
+
```
|
41
|
+
|
42
|
+
## Documentation
|
43
|
+
|
44
|
+
The documentation for Arx is hosted on [![rubydoc.info](https://img.shields.io/badge/docs-rubydoc.info-blue.svg)](https://www.rubydoc.info/gems/arx/toplevel).
|
45
|
+
|
46
|
+
## Usage
|
47
|
+
|
48
|
+
Before you start using Arx, you'll have to ensure that the gem is required (either in your current working file, or shell such as [IRB](https://en.wikipedia.org/wiki/Interactive_Ruby_Shell)):
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
require 'arx'
|
52
|
+
```
|
53
|
+
|
54
|
+
### Building search queries
|
55
|
+
|
56
|
+
Query requests submitted to the arXiv search API are typically of the following form (where the query string is indicated in bold):
|
57
|
+
|
58
|
+
[http://export.arxiv.org/api/query?**search_query=ti:%22Buchi+Automata%22+AND+cat:%22cs.FL%22**](http://export.arxiv.org/api/query?search_query=ti:%22Buchi+Automata%22+AND+cat:%22cs.FL%22)
|
59
|
+
|
60
|
+
> This particular query searches for papers whose title includes the string `Buchi Automata`, and are in the *Formal Languages and Automata Theory* (`cs.FL`) category.
|
61
|
+
|
62
|
+
Obviously writing out queries like this can quickly become time-consuming and tedious.
|
63
|
+
|
64
|
+
---
|
65
|
+
|
66
|
+
The `Arx::Query` class provides a small embedded DSL for writing these query strings.
|
67
|
+
|
68
|
+
#### Sorting criteria and order
|
69
|
+
|
70
|
+
The order in which search results are returned can be modified through the `sort_by` and `sort_order` keyword arguments (in the `Arx::Query` initializer):
|
71
|
+
|
72
|
+
- `sort_by` accepts the symbols: `:relevance`, `:last_updated` or `:date_submitted`
|
73
|
+
|
74
|
+
- `sort_order` accepts the symbols: `:ascending` or `:descending`
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
# Sort by submission date in ascending order (earliest first)
|
78
|
+
Arx::Query.new(sort_by: :date_submitted, sort_order: :ascending)
|
79
|
+
#=> sortBy=submittedDate&sortOrder=ascending
|
80
|
+
```
|
81
|
+
|
82
|
+
**Note**: The default setting is to sort by `:relevance` in `:descending` order:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
Arx::Query.new #=> sortBy=relevance&sortOrder=descending
|
86
|
+
```
|
87
|
+
|
88
|
+
#### Searching by ID
|
89
|
+
|
90
|
+
The arXiv search API doesn't only support searching for papers by metadata fields, but also by ID. When searching by ID, a different URL query string parameter `id_list` is used (instead of `search_query` as seen before).
|
91
|
+
|
92
|
+
Although the `id_list` can be used to *"search by ID"*, it is better to **think of it as restricting the search space to the papers with the provided IDs**:
|
93
|
+
|
94
|
+
| `search_query` present? | `id_list` present? | Returns |
|
95
|
+
| ----------------------- | ------------------ | ---------------------------------------------------- |
|
96
|
+
| Yes | No | Articles that match `search_query` |
|
97
|
+
| No | Yes | Articles that are in `id_list` |
|
98
|
+
| Yes | Yes | Articles in `id_list` that also match `search_query` |
|
99
|
+
|
100
|
+
To search by ID, simply pass the arXiv paper identifiers (ID) or URLs into the `Arx::Query` initializer method:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
Arx::Query.new('https://arxiv.org/abs/1711.05738', '1809.09415')
|
104
|
+
#=> sortBy=relevance&sortOrder=descending&id_list=1711.05738,1809.09415
|
105
|
+
```
|
106
|
+
|
107
|
+
#### Searching by metadata fields
|
108
|
+
|
109
|
+
The arXiv search API supports searches for the following paper metadata fields:
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
FIELDS = {
|
113
|
+
title: 'ti', # Title
|
114
|
+
author: 'au', # Author
|
115
|
+
abstract: 'abs', # Abstract
|
116
|
+
comment: 'co', # Comment
|
117
|
+
journal: 'jr', # Journal reference
|
118
|
+
category: 'cat', # Subject category
|
119
|
+
report: 'rn', # Report number
|
120
|
+
all: 'all' # All (of the above)
|
121
|
+
}
|
122
|
+
```
|
123
|
+
|
124
|
+
Each of these fields has an instance method defined under the `Arx::Query` class. For example:
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
# Papers whose title contains the string "Buchi Automata".
|
128
|
+
q = Arx::Query.new
|
129
|
+
q.title('Buchi Automata')
|
130
|
+
#=> sortBy=relevance&sortOrder=descending&search_query=ti:%22Buchi+Automata%22
|
131
|
+
```
|
132
|
+
|
133
|
+
##### Exact matches
|
134
|
+
|
135
|
+
By default, this searches for exact matches of the provided string (by adding double quotes around the string - in the query string, this is represented by the `%22`s). To disable this, you can use the `exact` keyword argument (which defaults to `true`):
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
# Papers whose title contains either the words "Buchi" or "Automata".
|
139
|
+
q = Arx::Query.new
|
140
|
+
q.title('Buchi Automata', exact: false)
|
141
|
+
#=> sortBy=relevance&sortOrder=descending&search_query=ti:Buchi+Automata
|
142
|
+
```
|
143
|
+
|
144
|
+
##### Multiple values for one field
|
145
|
+
|
146
|
+
Sometimes you might want to provide multiple field values to search for a paper by. This can simply be done by adding them as another argument (or providing an `Array`):
|
147
|
+
|
148
|
+
**Note**: The default logical connective used when there are multiple values for one field is `and`.
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
# Papers authored by both "Eleonora Andreotti" and "Dominik Edelmann".
|
152
|
+
q = Arx::Query.new
|
153
|
+
q.author('Eleonora Andreotti', 'Dominik Edelmann')
|
154
|
+
```
|
155
|
+
|
156
|
+
To change the logical connective to `or` or `not` (and not), use the `connective` keyword argument:
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
# Papers authored by either "Eleonora Andreotti" or "Dominik Edelmann".
|
160
|
+
q = Arx::Query.new
|
161
|
+
q.author('Eleonora Andreotti', 'Dominik Edelmann', connective: :or)
|
162
|
+
```
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
# Papers authored by "Eleonora Andreotti" and not "Dominik Edelmann".
|
166
|
+
q = Arx::Query.new
|
167
|
+
q.author('Eleonora Andreotti', 'Dominik Edelmann', connective: :and_not)
|
168
|
+
```
|
169
|
+
|
170
|
+
#### Chaining subqueries (logical connectives)
|
171
|
+
|
172
|
+
**Note**: By default, subqueries (successive instance method calls) are chained with a logical `and` connective.
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
# Papers authored by "Dominik Edelmann" in the "Numerical Analysis" (math.NA) category.
|
176
|
+
q = Arx::Query.new
|
177
|
+
q.author('Dominik Edelmann')
|
178
|
+
q.category('math.NA')
|
179
|
+
```
|
180
|
+
|
181
|
+
To change the logical connective used to chain subqueries, use the `&()` (and), `|()` (or) and `!()` (and not) instance methods between the subquery calls:
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
# Papers authored by "Eleonora Andreotti" in neither the "Numerical Analysis" (math.NA) or "Combinatorics (math.CO)" categories.
|
185
|
+
q = Arx::Query.new
|
186
|
+
q.author('Eleonora Andreotti')
|
187
|
+
q.!()
|
188
|
+
q.category('math.NA', 'math.CO', connective: :or)
|
189
|
+
```
|
190
|
+
|
191
|
+
### Running search queries
|
192
|
+
|
193
|
+
Search queries can be executed with the `Arx()` method (alias of `Arx.search`). This method contains the same parameters as the `Arx::Query` initializer - including the list of IDs.
|
194
|
+
|
195
|
+
#### Without a predefined query
|
196
|
+
|
197
|
+
Calling the `Arx()` method with a block allows for the construction and execution of a new query.
|
198
|
+
|
199
|
+
**Note**: If running a search query this way, then the `sort_by` and `sort_order` parameters can be added as additional keyword arguments.
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
# Papers in the cs.FL category whose title contains "Buchi Automata", not authored by Tomáš Babiak
|
203
|
+
results = Arx(sort_by: :date_submitted) do |query|
|
204
|
+
query.category('cs.FL')
|
205
|
+
query.title('Buchi Automata')
|
206
|
+
query.!()
|
207
|
+
query.author('Tomáš Babiak')
|
208
|
+
end
|
209
|
+
|
210
|
+
results.size #=> 18
|
211
|
+
```
|
212
|
+
|
213
|
+
#### With a predefined query
|
214
|
+
|
215
|
+
The `Arx()` method accepts a predefined `Arx::Query` object through the `query` keyword parameter.
|
216
|
+
|
217
|
+
**Note**: If using the `query` parameter, the `sort_by` and `sort_order` criteria should be defined in the `Arx::Query` object initializer rather than as arguments in `Arx()`.
|
218
|
+
|
219
|
+
```ruby
|
220
|
+
# Papers in the cs.FL category whose title contains "Buchi Automata", not authored by Tomáš Babiak
|
221
|
+
q = Arx::Query.new(sort_by: :date_submitted)
|
222
|
+
q.category('cs.FL')
|
223
|
+
q.title('Buchi Automata')
|
224
|
+
q.!()
|
225
|
+
q.author('Tomáš Babiak')
|
226
|
+
|
227
|
+
results = Arx(query: q)
|
228
|
+
results.size #=> 18
|
229
|
+
```
|
230
|
+
|
231
|
+
#### With IDs
|
232
|
+
|
233
|
+
The `Arx()` methods accepts a list of IDs as a splat parameter, just like the `Arx::Query` initializer.
|
234
|
+
|
235
|
+
If only one ID is specified, then a single `Arx::Paper` is returned:
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
result = Arx('1809.09415')
|
239
|
+
result.class #=> Arx::Paper
|
240
|
+
```
|
241
|
+
|
242
|
+
Otherwise, an `Array` of `Arx::Paper`s is returned.
|
243
|
+
|
244
|
+
### Query results
|
245
|
+
|
246
|
+
Search results are typically:
|
247
|
+
|
248
|
+
- an `Array`, either empty if no papers matched the supplied query, or containing `Arx::Paper` objects.
|
249
|
+
- a single `Arx::Paper` object (when the search method is only supplied with one ID).
|
250
|
+
|
251
|
+
### Entities
|
252
|
+
|
253
|
+
The `Arx::Paper`, `Arx::Author` and `Arx::Category` classes provide a simple interface for the metadata concerning a single arXiv paper:
|
254
|
+
|
255
|
+
#### `Arx::Paper`
|
256
|
+
|
257
|
+
```ruby
|
258
|
+
paper = Arx('1809.09415')
|
259
|
+
#=> #<Arx::Paper:0x00007fb657b59bd0>
|
260
|
+
|
261
|
+
paper.id
|
262
|
+
#=> "1809.09415v1"
|
263
|
+
paper.url
|
264
|
+
#=> "http://arxiv.org/abs/1809.09415v1"
|
265
|
+
paper.title
|
266
|
+
#=> "On finitely ambiguous Büchi automata"
|
267
|
+
paper.summary
|
268
|
+
#=> "Unambiguous B\\\"uchi automata, i.e. B\\\"uchi automata allowing..."
|
269
|
+
paper.authors
|
270
|
+
#=> [#<Arx::Author:0x00007fb657b63108>, #<Arx::Author:0x00007fb657b62438>]
|
271
|
+
|
272
|
+
# Paper's categories
|
273
|
+
paper.primary_category
|
274
|
+
#=> #<Arx::Category:0x00007fb657b61830>
|
275
|
+
paper.categories
|
276
|
+
#=> [#<Arx::Category:0x00007fb657b60e80>]
|
277
|
+
|
278
|
+
# Dates
|
279
|
+
paper.published_at
|
280
|
+
#=> #<DateTime: 2018-09-25T11:40:39+00:00 ((2458387j,42039s,0n),+0s,2299161j)>
|
281
|
+
paper.updated_at
|
282
|
+
#=> #<DateTime: 2018-09-25T11:40:39+00:00 ((2458387j,42039s,0n),+0s,2299161j)>
|
283
|
+
paper.revision?
|
284
|
+
#=> false
|
285
|
+
|
286
|
+
# Paper's comment
|
287
|
+
paper.comment?
|
288
|
+
#=> false
|
289
|
+
paper.comment
|
290
|
+
#=> Arx::MissingFieldError (This arXiv paper is missing the `comment` field)
|
291
|
+
|
292
|
+
# Paper's journal reference
|
293
|
+
paper.journal?
|
294
|
+
#=> false
|
295
|
+
paper.journal
|
296
|
+
#=> Arx::MissingFieldError (This arXiv paper is missing the `journal` field)
|
297
|
+
|
298
|
+
# Paper's PDF URL
|
299
|
+
paper.pdf?
|
300
|
+
#=> true
|
301
|
+
paper.pdf_url
|
302
|
+
#=> "http://arxiv.org/pdf/1809.09415v1"
|
303
|
+
|
304
|
+
# Paper's DOI (Digital Object Identifier) URL
|
305
|
+
paper.doi?
|
306
|
+
#=> true
|
307
|
+
paper.doi_url
|
308
|
+
#=> "http://dx.doi.org/10.1007/978-3-319-98654-8_41"
|
309
|
+
```
|
310
|
+
|
311
|
+
#### `Arx::Author`
|
312
|
+
|
313
|
+
```ruby
|
314
|
+
paper = Arx('cond-mat/9609089')
|
315
|
+
#=> #<Arx::Paper:0x00007fb657a7b8d0>
|
316
|
+
|
317
|
+
author = paper.authors.first
|
318
|
+
#=> #<Arx::Author:0x00007fb657a735e0>
|
319
|
+
|
320
|
+
author.name
|
321
|
+
#=> "F. Gebhard"
|
322
|
+
|
323
|
+
author.affiliations?
|
324
|
+
#=> true
|
325
|
+
author.affiliations
|
326
|
+
#=> ["ILL Grenoble, France"]
|
327
|
+
```
|
328
|
+
|
329
|
+
#### `Arx::Category`
|
330
|
+
|
331
|
+
```ruby
|
332
|
+
paper = Arx('cond-mat/9609089')
|
333
|
+
#=> #<Arx::Paper:0x00007fb657b59bd0>
|
334
|
+
|
335
|
+
category = paper.primary_category
|
336
|
+
#=> #<Arx::Category:0x00007fb6570609b8>
|
337
|
+
|
338
|
+
category.name
|
339
|
+
#=> "cond-mat"
|
340
|
+
category.full_name
|
341
|
+
#=> "Condensed Matter"
|
342
|
+
```
|
data/lib/arx/categories.rb
CHANGED
@@ -11,6 +11,7 @@ module Arx
|
|
11
11
|
'astro-ph.HE' => 'High Energy Astrophysical Phenomena',
|
12
12
|
'astro-ph.IM' => 'Instrumentation and Methods for Astrophysics',
|
13
13
|
'astro-ph.SR' => 'Solar and Stellar Astrophysics',
|
14
|
+
'cond-mat' => 'Condensed Matter',
|
14
15
|
'cond-mat.dis-nn' => 'Disordered Systems and Neural Networks',
|
15
16
|
'cond-mat.mes-hall' => 'Mesoscale and Nanoscale Physics',
|
16
17
|
'cond-mat.mtrl-sci' => 'Materials Science',
|
@@ -20,6 +21,7 @@ module Arx
|
|
20
21
|
'cond-mat.stat-mech' => 'Statistical Mechanics',
|
21
22
|
'cond-mat.str-el' => 'Strongly Correlated Electrons',
|
22
23
|
'cond-mat.supr-con' => 'Superconductivity',
|
24
|
+
'cs' => 'Computer Science',
|
23
25
|
'cs.AI' => 'Artificial Intelligence',
|
24
26
|
'cs.AR' => 'Hardware Architecture',
|
25
27
|
'cs.CC' => 'Computational Complexity',
|
@@ -60,7 +62,9 @@ module Arx
|
|
60
62
|
'cs.SE' => 'Software Engineering',
|
61
63
|
'cs.SI' => 'Social and Information Networks',
|
62
64
|
'cs.SY' => 'Systems and Control',
|
65
|
+
'econ' => 'Economics',
|
63
66
|
'econ.EM' => 'Econometrics',
|
67
|
+
'eess' => 'Electrical Engineering and Systems Science',
|
64
68
|
'eess.AS' => 'Audio and Speech Processing',
|
65
69
|
'eess.IV' => 'Image and Video Processing',
|
66
70
|
'eess.SP' => 'Signal Processing',
|
@@ -69,6 +73,7 @@ module Arx
|
|
69
73
|
'hep-lat' => 'High Energy Physics - Lattice',
|
70
74
|
'hep-ph' => 'High Energy Physics - Phenomenology',
|
71
75
|
'hep-th' => 'High Energy Physics - Theory',
|
76
|
+
'math' => 'Mathematics',
|
72
77
|
'math.AC' => 'Commutative Algebra',
|
73
78
|
'math.AG' => 'Algebraic Geometry',
|
74
79
|
'math.AP' => 'Analysis of PDEs',
|
@@ -102,6 +107,7 @@ module Arx
|
|
102
107
|
'math.SP' => 'Spectral Theory',
|
103
108
|
'math.ST' => 'Statistics Theory',
|
104
109
|
'math-ph' => 'Mathematical Physics',
|
110
|
+
'nlin' => 'Nonlinear Sciences',
|
105
111
|
'nlin.AO' => 'Adaptation and Self-Organizing Systems',
|
106
112
|
'nlin.CD' => 'Chaotic Dynamics',
|
107
113
|
'nlin.CG' => 'Cellular Automata and Lattice Gases',
|
@@ -109,6 +115,7 @@ module Arx
|
|
109
115
|
'nlin.SI' => 'Exactly Solvable and Integrable Systems',
|
110
116
|
'nucl-ex' => 'Nuclear Experiment',
|
111
117
|
'nucl-th' => 'Nuclear Theory',
|
118
|
+
'physics' => 'Physics',
|
112
119
|
'physics.acc-ph' => 'Accelerator Physics',
|
113
120
|
'physics.ao-ph' => 'Atmospheric and Oceanic Physics',
|
114
121
|
'physics.app-ph' => 'Applied Physics',
|
@@ -131,6 +138,7 @@ module Arx
|
|
131
138
|
'physics.pop-ph' => 'Popular Physics',
|
132
139
|
'physics.soc-ph' => 'Physics and Society',
|
133
140
|
'physics.space-ph' => 'Space Physics',
|
141
|
+
'q-bio' => 'Quantitative Biology',
|
134
142
|
'q-bio.BM' => 'Biomolecules',
|
135
143
|
'q-bio.CB' => 'Cell Behavior',
|
136
144
|
'q-bio.GN' => 'Genomics',
|
@@ -141,6 +149,7 @@ module Arx
|
|
141
149
|
'q-bio.QM' => 'Quantitative Methods',
|
142
150
|
'q-bio.SC' => 'Subcellular Processes',
|
143
151
|
'q-bio.TO' => 'Tissues and Organs',
|
152
|
+
'q-fin' => 'Quantitative Finance',
|
144
153
|
'q-fin.CP' => 'Computational Finance',
|
145
154
|
'q-fin.EC' => 'Economics',
|
146
155
|
'q-fin.GN' => 'General Finance',
|
@@ -151,6 +160,7 @@ module Arx
|
|
151
160
|
'q-fin.ST' => 'Statistical Finance',
|
152
161
|
'q-fin.TR' => 'Trading and Market Microstructure',
|
153
162
|
'quant-ph' => 'Quantum Physics',
|
163
|
+
'stat' => 'Statistics',
|
154
164
|
'stat.AP' => 'Applications',
|
155
165
|
'stat.CO' => 'Computation',
|
156
166
|
'stat.ME' => 'Methodology',
|
data/lib/arx/entities/paper.rb
CHANGED
@@ -37,11 +37,13 @@ module Arx
|
|
37
37
|
# The date that the paper was last updated.
|
38
38
|
# @return [DateTime]
|
39
39
|
element :last_updated, DateTime, tag: 'updated'
|
40
|
+
alias_method :updated_at, :last_updated
|
40
41
|
|
41
42
|
# @!method publish_date
|
42
43
|
# The original publish/submission date of the paper.
|
43
44
|
# @return [DateTime]
|
44
45
|
element :publish_date, DateTime, tag: 'published'
|
46
|
+
alias_method :published_at, :publish_date
|
45
47
|
|
46
48
|
# @!method title
|
47
49
|
# The title of the paper.
|
@@ -57,11 +59,13 @@ module Arx
|
|
57
59
|
# The primary category of the paper.
|
58
60
|
# @return [Category]
|
59
61
|
element :primary_category, Category, tag: 'primary_category'
|
62
|
+
alias_method :primary_subject, :primary_category
|
60
63
|
|
61
64
|
# @!method categories
|
62
65
|
# The categories of the paper.
|
63
66
|
# @return [Array<Category>]
|
64
67
|
has_many :categories, Category, tag: 'category'
|
68
|
+
alias_method :subjects, :categories
|
65
69
|
|
66
70
|
# Whether the paper is a revision or not.
|
67
71
|
# @note A paper is a revision if {last_updated} differs from {publish_date}.
|
data/lib/arx/query/query.rb
CHANGED
@@ -69,7 +69,7 @@ module Arx
|
|
69
69
|
@query = String.new
|
70
70
|
|
71
71
|
Validate.sort_by sort_by, permitted: SORT_BY.keys
|
72
|
-
@query << "
|
72
|
+
@query << "#{PARAMS[:sort_by]}=#{SORT_BY[sort_by]}"
|
73
73
|
|
74
74
|
Validate.sort_order sort_order, permitted: SORT_ORDER.keys
|
75
75
|
@query << "&#{PARAMS[:sort_order]}=#{SORT_ORDER[sort_order]}"
|
data/lib/arx/version.rb
CHANGED
data/lib/arx.rb
CHANGED
@@ -20,17 +20,21 @@ module Arx
|
|
20
20
|
|
21
21
|
# Performs a search query for papers on the arXiv search API.
|
22
22
|
#
|
23
|
+
# @note The +sort_by+ and +sort_order+ arguments are ignored if passing in your own +query+.
|
23
24
|
# @param ids [Array<String>] The IDs of the arXiv papers to restrict the query to.
|
25
|
+
# @param query [Query, NilClass] Predefined search query object.
|
24
26
|
# @param sort_by [Symbol] The sorting criteria for the returned results (see {Query::SORT_BY}).
|
25
27
|
# @param sort_order [Symbol] The sorting order for the returned results (see {Query::SORT_ORDER}).
|
26
28
|
# @return [Array<Paper>, Paper] The {Paper}(s) found by the search query.
|
27
|
-
def search(*ids, sort_by: :relevance, sort_order: :descending)
|
28
|
-
query
|
29
|
+
def search(*ids, query: nil, sort_by: :relevance, sort_order: :descending)
|
30
|
+
if query.nil?
|
31
|
+
query = Query.new(*ids, sort_by: sort_by, sort_order: sort_order)
|
32
|
+
yield query if block_given?
|
33
|
+
else
|
34
|
+
raise TypeError.new("Expected `query` to be an Arx::Query, got: #{query.class}") unless query.is_a? Query
|
35
|
+
end
|
29
36
|
|
30
|
-
|
31
|
-
|
32
|
-
document = Nokogiri::XML open(ENDPOINT + query.to_s + '&max_results=10000')
|
33
|
-
document.remove_namespaces!
|
37
|
+
document = Nokogiri::XML(open ENDPOINT + query.to_s + '&max_results=10000').remove_namespaces!
|
34
38
|
|
35
39
|
results = Paper.parse(document, single: false).reject {|paper| paper.id.empty?}
|
36
40
|
raise MissingPaper.new(ids.first) if results.empty? && ids.size == 1
|
@@ -45,15 +49,13 @@ end
|
|
45
49
|
# Performs a search query for papers on the arXiv search API.
|
46
50
|
#
|
47
51
|
# @note This is an alias of the {Arx.search} method.
|
52
|
+
# @note The +sort_by+ and +sort_order+ arguments are ignored if passing in your own +query+.
|
48
53
|
# @see Arx.search
|
49
54
|
# @param ids [Array<String>] The IDs of the arXiv papers to restrict the query to.
|
55
|
+
# @param query [Query, NilClass] Predefined search query object.
|
50
56
|
# @param sort_by [Symbol] The sorting criteria for the returned results (see {Arx::Query::SORT_BY}).
|
51
57
|
# @param sort_order [Symbol] The sorting order for the returned results (see {Arx::Query::SORT_ORDER}).
|
52
58
|
# @return [Array<Paper>, Paper] The {Arx::Paper}(s) found by the search query.
|
53
|
-
def Arx(*ids, sort_by: :relevance, sort_order: :descending, &block)
|
54
|
-
|
55
|
-
Arx.search *ids, sort_by: sort_by, sort_order: sort_order, &block
|
56
|
-
else
|
57
|
-
Arx.search *ids, sort_by: sort_by, sort_order: sort_order
|
58
|
-
end
|
59
|
+
def Arx(*ids, query: nil, sort_by: :relevance, sort_order: :descending, &block)
|
60
|
+
Arx.search *ids, query: query, sort_by: sort_by, sort_order: sort_order, &block
|
59
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edwin Onuonga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|