acromine 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.md +9 -0
- data/LICENSE +22 -0
- data/Manifest.txt +10 -0
- data/README.md +175 -0
- data/acromine.gemspec +84 -0
- data/lib/acromine.rb +1 -0
- data/lib/acromine/core.rb +163 -0
- data/lib/acromine/longform.rb +24 -0
- data/lib/acromine/longform_variant.rb +18 -0
- data/lib/acromine/version.rb +5 -0
- metadata +319 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 19f95d8952d06808f527b8ecec225f6fd6e9e2c3
|
4
|
+
data.tar.gz: 9588da41fd15151191c1161bd4060f46537a0bf3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bb0a8adc9c9139131d18b9f423dc27a910c5bd55eb57068ac35156e66f8fe7edf0a24e81bdb8d38368341646b56f09cb6872f942ff07a9ad97a38f25960be52
|
7
|
+
data.tar.gz: c388cb4ff3fcde48728988410c4ef18cc823900663dcd4414b2f62ebc88a3feaabe2296761755175cc656a5818108b1d0f298517ea41a738a3de0728a9e0cf09
|
data/History.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2015, James FitzGibbon
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
6
|
+
copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included
|
14
|
+
in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
17
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
# Acromine Client
|
2
|
+
|
3
|
+
* home :: https://github.com/jf647/acromine
|
4
|
+
* license :: [MIT](http://opensource.org/licenses/MIT)
|
5
|
+
* gem version :: [![Gem Version](https://badge.fury.io/rb/acromine.png)](http://badge.fury.io/rb/acromine)
|
6
|
+
* build status :: [![Circle CI](https://circleci.com/gh/jf647/acromine.svg?style=svg)](https://circleci.com/gh/jf647/acromine)
|
7
|
+
* code climate :: [![Code Climate](https://codeclimate.com/github/jf647/acromine/badges/gpa.svg)](https://codeclimate.com/github/jf647/acromine)
|
8
|
+
* docs :: [![Inline docs](http://inch-ci.org/github/jf647/acromine.svg?branch=master)](http://inch-ci.org/github/jf647/acromine)
|
9
|
+
|
10
|
+
## DESCRIPTION
|
11
|
+
|
12
|
+
acromine is a client for the [Acromine REST
|
13
|
+
Service](http://www.nactem.ac.uk/software/acromine/rest.html) provided
|
14
|
+
by the National Centre for Text Mining.
|
15
|
+
|
16
|
+
This gem provides a library to easily find the long form of an acronym.
|
17
|
+
|
18
|
+
A CLI is also provided to use the library from the command line.
|
19
|
+
|
20
|
+
## SYNOPSIS
|
21
|
+
|
22
|
+
require 'acromine'
|
23
|
+
|
24
|
+
acro = Acromine.new
|
25
|
+
puts "HMM may refer to:"
|
26
|
+
acro.longforms('HMM').variants.each do |lf|
|
27
|
+
puts " #{lf.longform}"
|
28
|
+
end
|
29
|
+
|
30
|
+
## INSTALLATION
|
31
|
+
|
32
|
+
gem install acromine
|
33
|
+
|
34
|
+
## REQUIREMENTS
|
35
|
+
|
36
|
+
* ruby 2.x or higher
|
37
|
+
* tested with MRI 2.2.2
|
38
|
+
|
39
|
+
## LIBRARY USAGE
|
40
|
+
|
41
|
+
First, construct an Acromine object:
|
42
|
+
|
43
|
+
require 'acromine'
|
44
|
+
acro = Acromine.new
|
45
|
+
|
46
|
+
The object has one method `#longforms`, which takes a single acronym as
|
47
|
+
an argument and returns a list of Acromine::Longform objects. If the
|
48
|
+
acronym is not found, the list will be empty.
|
49
|
+
|
50
|
+
Each Longform object has four getter methods:
|
51
|
+
|
52
|
+
* `#longform` which returns the long form of the acronym
|
53
|
+
* `#frequency` which returns the number of occurences of the acronym
|
54
|
+
* `#since` which returns the year the definition first appears in the Acromine corpus
|
55
|
+
* `#variants`, which returns a list of Acromine::LongformVariant objects.
|
56
|
+
|
57
|
+
Each Longform will always have at least one LongformVariant.
|
58
|
+
|
59
|
+
To limit the number of variants returned, pass a limit in an options
|
60
|
+
hash:
|
61
|
+
|
62
|
+
acro.longforms('HMM').variants(limit: 5)
|
63
|
+
|
64
|
+
Variants will be sorted by descending frequency count then by ascending
|
65
|
+
variant year and finally by ascending long form.
|
66
|
+
|
67
|
+
This order can be changed using the 'sort_spec' option. The spec is one
|
68
|
+
or two two-character pairs joined by a comma. The first character of
|
69
|
+
the pair is what to sort - f for the frequency and y for the year. The
|
70
|
+
second character of the pair is how to sort - a for ascending and d for
|
71
|
+
descending:
|
72
|
+
|
73
|
+
acro.longforms('HMM').variants(sort_spec: 'fa,yd')
|
74
|
+
|
75
|
+
A LongformVariant object has three getter methods:
|
76
|
+
|
77
|
+
* `#longform` which returns the long form of the acronym
|
78
|
+
* `#freq` which returns the number of occurences of the acronym
|
79
|
+
* `#since` which returns the year the definition first appears in the Acromine corpus
|
80
|
+
|
81
|
+
To view the full documentation, refer to the DEVELOPMENT section below.
|
82
|
+
|
83
|
+
## CLI USAGE
|
84
|
+
|
85
|
+
acromine lf [--limit N] [--sort SPEC] ACRONYM
|
86
|
+
|
87
|
+
Help can be displayed for global options:
|
88
|
+
|
89
|
+
acromine help
|
90
|
+
|
91
|
+
Or for a individual command:
|
92
|
+
|
93
|
+
acromine help lf
|
94
|
+
|
95
|
+
### CONFIG FILE
|
96
|
+
|
97
|
+
The CLI options can have their defaults set via a config file. To
|
98
|
+
create it, run:
|
99
|
+
|
100
|
+
acromine initconfig
|
101
|
+
|
102
|
+
which will create the file `~/.acromine.conf`. The defaults will be
|
103
|
+
written to this file, which can be edited as desired. For example, the
|
104
|
+
following file sets the sort order to oldest then by most used and sets
|
105
|
+
a limit of 5:
|
106
|
+
|
107
|
+
```
|
108
|
+
---
|
109
|
+
commands:
|
110
|
+
:longform:
|
111
|
+
:sort: yd,fd
|
112
|
+
:limit: 5
|
113
|
+
```
|
114
|
+
|
115
|
+
## DEVELOPMENT
|
116
|
+
|
117
|
+
To set up for development, run
|
118
|
+
|
119
|
+
bundle
|
120
|
+
|
121
|
+
To run tests, run
|
122
|
+
|
123
|
+
bundle exec rake spec # unit tests
|
124
|
+
bundle exec rake features # feature tests
|
125
|
+
bundle exec rake test # all tests
|
126
|
+
|
127
|
+
Unit tests use a mocked source, while feature tests require internet
|
128
|
+
access to the Acromine service.
|
129
|
+
|
130
|
+
To run tests automatically when the source changes, start guard:
|
131
|
+
|
132
|
+
bundle exec guard
|
133
|
+
|
134
|
+
To generate a code coverage report, run
|
135
|
+
|
136
|
+
bundle exec rake coverage
|
137
|
+
|
138
|
+
The report will be generated in the `coverage` subdirectory. Open
|
139
|
+
`index.html` in this directory to start browsing
|
140
|
+
|
141
|
+
To generate library documentation, run
|
142
|
+
|
143
|
+
bundle exec rake doc
|
144
|
+
|
145
|
+
The rdoc will be generated in the `doc` subdirectory. Open `index.html`
|
146
|
+
in this directory to start browsing the documentation.
|
147
|
+
|
148
|
+
## LICENSE
|
149
|
+
|
150
|
+
(The MIT License)
|
151
|
+
|
152
|
+
Copyright (c) 2015, James FitzGibbon
|
153
|
+
|
154
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
155
|
+
copy of this software and associated documentation files (the
|
156
|
+
'Software'), to deal in the Software without restriction, including
|
157
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
158
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
159
|
+
permit persons to whom the Software is furnished to do so, subject to
|
160
|
+
the following conditions:
|
161
|
+
|
162
|
+
The above copyright notice and this permission notice shall be included
|
163
|
+
in all copies or substantial portions of the Software.
|
164
|
+
|
165
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
166
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
167
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
168
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
169
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
170
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
171
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
172
|
+
|
173
|
+
## AUTHOR
|
174
|
+
|
175
|
+
James FitzGibbon <james@nadt.net>
|
data/acromine.gemspec
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: acromine 0.1.1.20150806174941 ruby lib
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "acromine"
|
6
|
+
s.version = "0.1.1.20150806174941"
|
7
|
+
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib"]
|
10
|
+
s.authors = ["James FitzGibbon"]
|
11
|
+
s.date = "2015-08-07"
|
12
|
+
s.description = "acromine is a client for the [Acromine REST\nService](http://www.nactem.ac.uk/software/acromine/rest.html) provided\nby the National Centre for Text Mining.\n\nThis gem provides a library to easily find the long form of an acronym.\n\nA CLI is also provided to use the library from the command line."
|
13
|
+
s.email = ["james@nadt.net"]
|
14
|
+
s.extra_rdoc_files = ["History.md", "Manifest.txt", "README.md"]
|
15
|
+
s.files = ["History.md", "LICENSE", "Manifest.txt", "README.md", "acromine.gemspec", "lib/acromine.rb", "lib/acromine/core.rb", "lib/acromine/longform.rb", "lib/acromine/longform_variant.rb", "lib/acromine/version.rb"]
|
16
|
+
s.homepage = "https://github.com/jf647/acromine"
|
17
|
+
s.licenses = ["MIT"]
|
18
|
+
s.rdoc_options = ["--main", "README.md"]
|
19
|
+
s.rubygems_version = "2.4.4"
|
20
|
+
s.summary = "acromine is a client for the [Acromine REST Service](http://www.nactem.ac.uk/software/acromine/rest.html) provided by the National Centre for Text Mining"
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
s.specification_version = 4
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<gli>, ["~> 2.13"])
|
27
|
+
s.add_runtime_dependency(%q<httparty>, ["~> 0.13"])
|
28
|
+
s.add_runtime_dependency(%q<valuable>, ["~> 0.9"])
|
29
|
+
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
30
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.13"])
|
31
|
+
s.add_development_dependency(%q<hoe-gemspec>, ["~> 1.0"])
|
32
|
+
s.add_development_dependency(%q<rake>, ["~> 10.3"])
|
33
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.1"])
|
34
|
+
s.add_development_dependency(%q<guard>, ["~> 2.12"])
|
35
|
+
s.add_development_dependency(%q<guard-rspec>, ["~> 4.5"])
|
36
|
+
s.add_development_dependency(%q<guard-rake>, ["~> 0.0"])
|
37
|
+
s.add_development_dependency(%q<guard-rubocop>, ["~> 1.2"])
|
38
|
+
s.add_development_dependency(%q<guard-cucumber>, ["~> 1.6"])
|
39
|
+
s.add_development_dependency(%q<simplecov>, ["~> 0.9"])
|
40
|
+
s.add_development_dependency(%q<simplecov-console>, ["~> 0.2"])
|
41
|
+
s.add_development_dependency(%q<yard>, ["~> 0.8"])
|
42
|
+
s.add_development_dependency(%q<rspec_junit_formatter>, ["~> 0.2"])
|
43
|
+
s.add_development_dependency(%q<aruba>, ["~> 0.8"])
|
44
|
+
else
|
45
|
+
s.add_dependency(%q<gli>, ["~> 2.13"])
|
46
|
+
s.add_dependency(%q<httparty>, ["~> 0.13"])
|
47
|
+
s.add_dependency(%q<valuable>, ["~> 0.9"])
|
48
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
49
|
+
s.add_dependency(%q<hoe>, ["~> 3.13"])
|
50
|
+
s.add_dependency(%q<hoe-gemspec>, ["~> 1.0"])
|
51
|
+
s.add_dependency(%q<rake>, ["~> 10.3"])
|
52
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
53
|
+
s.add_dependency(%q<guard>, ["~> 2.12"])
|
54
|
+
s.add_dependency(%q<guard-rspec>, ["~> 4.5"])
|
55
|
+
s.add_dependency(%q<guard-rake>, ["~> 0.0"])
|
56
|
+
s.add_dependency(%q<guard-rubocop>, ["~> 1.2"])
|
57
|
+
s.add_dependency(%q<guard-cucumber>, ["~> 1.6"])
|
58
|
+
s.add_dependency(%q<simplecov>, ["~> 0.9"])
|
59
|
+
s.add_dependency(%q<simplecov-console>, ["~> 0.2"])
|
60
|
+
s.add_dependency(%q<yard>, ["~> 0.8"])
|
61
|
+
s.add_dependency(%q<rspec_junit_formatter>, ["~> 0.2"])
|
62
|
+
s.add_dependency(%q<aruba>, ["~> 0.8"])
|
63
|
+
end
|
64
|
+
else
|
65
|
+
s.add_dependency(%q<gli>, ["~> 2.13"])
|
66
|
+
s.add_dependency(%q<httparty>, ["~> 0.13"])
|
67
|
+
s.add_dependency(%q<valuable>, ["~> 0.9"])
|
68
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
69
|
+
s.add_dependency(%q<hoe>, ["~> 3.13"])
|
70
|
+
s.add_dependency(%q<hoe-gemspec>, ["~> 1.0"])
|
71
|
+
s.add_dependency(%q<rake>, ["~> 10.3"])
|
72
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
73
|
+
s.add_dependency(%q<guard>, ["~> 2.12"])
|
74
|
+
s.add_dependency(%q<guard-rspec>, ["~> 4.5"])
|
75
|
+
s.add_dependency(%q<guard-rake>, ["~> 0.0"])
|
76
|
+
s.add_dependency(%q<guard-rubocop>, ["~> 1.2"])
|
77
|
+
s.add_dependency(%q<guard-cucumber>, ["~> 1.6"])
|
78
|
+
s.add_dependency(%q<simplecov>, ["~> 0.9"])
|
79
|
+
s.add_dependency(%q<simplecov-console>, ["~> 0.2"])
|
80
|
+
s.add_dependency(%q<yard>, ["~> 0.8"])
|
81
|
+
s.add_dependency(%q<rspec_junit_formatter>, ["~> 0.2"])
|
82
|
+
s.add_dependency(%q<aruba>, ["~> 0.8"])
|
83
|
+
end
|
84
|
+
end
|
data/lib/acromine.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'acromine/core'
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
require 'acromine/longform'
|
4
|
+
require 'acromine/longform_variant'
|
5
|
+
|
6
|
+
# a client for the Acromine REST service
|
7
|
+
class Acromine
|
8
|
+
include HTTParty
|
9
|
+
|
10
|
+
# the URL to the Acromine REST service
|
11
|
+
DEFAULT_URI = 'http://www.nactem.ac.uk/software/acromine/dictionary.py'
|
12
|
+
|
13
|
+
# constructs an Acromine object
|
14
|
+
# @param uri [String] the URI to the Acromine REST service
|
15
|
+
def initialize(uri = DEFAULT_URI)
|
16
|
+
self.class.base_uri uri
|
17
|
+
self.class.format :json
|
18
|
+
end
|
19
|
+
|
20
|
+
# finds the long form(s) of an acronym
|
21
|
+
# @param acronym [String] the acronym to expand
|
22
|
+
# @param opts [Hash] sort and limit options
|
23
|
+
# @return [Array<Acromine::Longform>, []] a list of long forms for the
|
24
|
+
# acronym, or an empty array if the acronym was not found
|
25
|
+
def longforms(acronym, opts = {})
|
26
|
+
# validate our options
|
27
|
+
validate_opts(opts)
|
28
|
+
# get the acronyms from the webservice
|
29
|
+
ret = self.class.get('', query: { sf: acronym })
|
30
|
+
# an empty JSON array means the acronym was not found
|
31
|
+
return [] if ret.body == "[]\n"
|
32
|
+
build_lfs(ret, opts)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
# validates filter and sort options
|
38
|
+
# @param limit [Fixnum] how many long forms to return
|
39
|
+
# @param sort_spec [String] how to sort the long forms on frequency and year
|
40
|
+
# @raise RuntimeError if parameters are invalid
|
41
|
+
def validate_opts(limit: nil, sort_spec: nil)
|
42
|
+
# validate that the limit is a positive integer
|
43
|
+
if limit
|
44
|
+
begin
|
45
|
+
!Float(limit).nil?
|
46
|
+
rescue
|
47
|
+
raise "invalid limit '#{limit}'"
|
48
|
+
end
|
49
|
+
fail "invalid limit '#{limit}'" if limit.to_i < 1
|
50
|
+
end
|
51
|
+
# validate the sort spec(s)
|
52
|
+
return unless sort_spec
|
53
|
+
specs = sort_spec.split(/,/)
|
54
|
+
fail 'too many sort specs (max 2)' if specs.size > 2
|
55
|
+
specs.each do|spec|
|
56
|
+
fail "invalid sort spec '#{sort_spec}'" unless spec.match(/^[fy][ad]$/)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# builds LongForm objects from the JSON returned by the REST service
|
61
|
+
# @param json [Array] a list of long forms as described by
|
62
|
+
# http://www.nactem.ac.uk/software/acromine/rest.html
|
63
|
+
# @param opts [Hash] sort and limit options
|
64
|
+
# @return [Array<Acromine::Longform>] a list of long form objects
|
65
|
+
# @api private
|
66
|
+
def build_lfs(json, opts = {})
|
67
|
+
ret = []
|
68
|
+
massage_data(json[0]['lfs'], opts).each do |lf|
|
69
|
+
lfobj = build_lf(lf)
|
70
|
+
ret << lfobj
|
71
|
+
end
|
72
|
+
ret
|
73
|
+
end
|
74
|
+
|
75
|
+
# sorts and limits the JSON data returned from the REST service
|
76
|
+
# @param json [Array] the 'lfs' data from the web service
|
77
|
+
# @param limit [Fixnum] how many long forms to return
|
78
|
+
# @param sort_spec [String] how to sort on frequency and year
|
79
|
+
# @api private
|
80
|
+
def massage_data(json, limit: nil, sort_spec: 'fd,ya')
|
81
|
+
xforms = build_sort_xforms(sort_spec + ',la')
|
82
|
+
sorted = json.sort_by do |e|
|
83
|
+
xforms.map { |x| x.call(e) }
|
84
|
+
end
|
85
|
+
# only return the top x if a limit was specified
|
86
|
+
limit.nil? ? sorted : sorted.take(limit.to_i)
|
87
|
+
end
|
88
|
+
|
89
|
+
# returns a set of lambdas that will extract the correct transformed
|
90
|
+
# elements of a long form based on a sort spec
|
91
|
+
# @param sort_spec [String] how to sort the long forms on frequency
|
92
|
+
# and year. The spec is one or two two-character pairs joined by
|
93
|
+
# a comma. The first character of the pair is what to sort - f for
|
94
|
+
# the frequency and y for the year. The second character of the pair
|
95
|
+
# is how to sort - a for ascending and d for descending
|
96
|
+
# @example sort by frequency descending then year ascending
|
97
|
+
# build_sort_xforms('fd,ya')
|
98
|
+
# @example sort by year descending then frequency descending
|
99
|
+
# build_sort_xforms('yd,fd')
|
100
|
+
# @example sort just by year ascending (i.e. oldest first)
|
101
|
+
# build_sort_xforms('ya')
|
102
|
+
# @return [Array<#call>] a set of transforms from longform JSON data
|
103
|
+
# into a sortable tuple
|
104
|
+
# @api private
|
105
|
+
def build_sort_xforms(sort_spec)
|
106
|
+
xforms = []
|
107
|
+
sort_spec.split(',').each do |spec|
|
108
|
+
what, how = spec.chars
|
109
|
+
xforms << case what
|
110
|
+
when 'f'
|
111
|
+
case how
|
112
|
+
when 'a'
|
113
|
+
->(x) { x['freq'] }
|
114
|
+
when 'd'
|
115
|
+
->(x) { -x['freq'] }
|
116
|
+
end
|
117
|
+
when 'y'
|
118
|
+
case how
|
119
|
+
when 'a'
|
120
|
+
->(x) { x['since'] }
|
121
|
+
when 'd'
|
122
|
+
->(x) { -x['since'] }
|
123
|
+
end
|
124
|
+
when 'l'
|
125
|
+
case how
|
126
|
+
when 'a'
|
127
|
+
->(x) { x['lf'] }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
xforms
|
132
|
+
end
|
133
|
+
|
134
|
+
# builds a single Acromine::Longform object
|
135
|
+
# @param lf [Hash] a single 'lf' entry from the JSON returned by
|
136
|
+
# the webservice
|
137
|
+
# @return [Acromine::Longform]
|
138
|
+
# @api private
|
139
|
+
def build_lf(lf)
|
140
|
+
lfobj = Acromine::Longform.new(
|
141
|
+
longform: lf['lf'],
|
142
|
+
frequency: lf['freq'],
|
143
|
+
since: lf['since']
|
144
|
+
)
|
145
|
+
lf['vars'].each do |var|
|
146
|
+
lfobj.variants << build_lfv(var)
|
147
|
+
end
|
148
|
+
lfobj
|
149
|
+
end
|
150
|
+
|
151
|
+
# builds a single Acromine::LongformVariant object
|
152
|
+
# @param var [Hash] a single 'lf' variant entry from the JSON returned
|
153
|
+
# by the webservice
|
154
|
+
# @return [Acromine::LongformVariant]
|
155
|
+
# @api private
|
156
|
+
def build_lfv(var)
|
157
|
+
Acromine::LongformVariant.new(
|
158
|
+
longform: var['lf'],
|
159
|
+
frequency: var['freq'],
|
160
|
+
since: var['since']
|
161
|
+
)
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'valuable'
|
2
|
+
|
3
|
+
require 'acromine/longform_variant'
|
4
|
+
|
5
|
+
class Acromine
|
6
|
+
# a summary of the long form of an acronym
|
7
|
+
class Longform < Valuable
|
8
|
+
# @!attribute [rw] longform
|
9
|
+
# @return [String] the long form of the acronym
|
10
|
+
has_value :longform
|
11
|
+
|
12
|
+
# @!attribute [rw] frequency
|
13
|
+
# @return [Fixnum] how often the long form has been seen
|
14
|
+
has_value :frequency, klass: :integer
|
15
|
+
|
16
|
+
# @!attribute [rw] since
|
17
|
+
# @return [Fixnum] the earliest year the longform was seen
|
18
|
+
has_value :since, klass: :integer
|
19
|
+
|
20
|
+
# @!attribute [rw] variants
|
21
|
+
# @return [Array<Acromine::LongformVariant>] variants of the long form
|
22
|
+
has_collection :variants, klass: Acromine::LongformVariant
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'valuable'
|
2
|
+
|
3
|
+
class Acromine
|
4
|
+
# a specific variant of a long form of an acronym
|
5
|
+
class LongformVariant < Valuable
|
6
|
+
# @!attribute [rw] longform
|
7
|
+
# @return [String] the long form of the acronym
|
8
|
+
has_value :longform
|
9
|
+
|
10
|
+
# @!attribute [rw] frequency
|
11
|
+
# @return [Fixnum] how often the long form has been seen
|
12
|
+
has_value :frequency, klass: :integer
|
13
|
+
|
14
|
+
# @!attribute [rw] since
|
15
|
+
# @return [Fixnum] the earliest year the longform was seen
|
16
|
+
has_value :since, klass: :integer
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,319 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acromine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James FitzGibbon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.13'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: valuable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: hoe
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.13'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.13'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: hoe-gemspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.3'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.1'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.1'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.12'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.12'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: guard-rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '4.5'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '4.5'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: guard-rake
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: guard-rubocop
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '1.2'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '1.2'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: guard-cucumber
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '1.6'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '1.6'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: simplecov
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0.9'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0.9'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: simplecov-console
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0.2'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0.2'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: yard
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - "~>"
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0.8'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0.8'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: rspec_junit_formatter
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - "~>"
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0.2'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - "~>"
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0.2'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: aruba
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0.8'
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0.8'
|
265
|
+
description: |-
|
266
|
+
acromine is a client for the [Acromine REST
|
267
|
+
Service](http://www.nactem.ac.uk/software/acromine/rest.html) provided
|
268
|
+
by the National Centre for Text Mining.
|
269
|
+
|
270
|
+
This gem provides a library to easily find the long form of an acronym.
|
271
|
+
|
272
|
+
A CLI is also provided to use the library from the command line.
|
273
|
+
email:
|
274
|
+
- james@nadt.net
|
275
|
+
executables: []
|
276
|
+
extensions: []
|
277
|
+
extra_rdoc_files:
|
278
|
+
- History.md
|
279
|
+
- Manifest.txt
|
280
|
+
- README.md
|
281
|
+
files:
|
282
|
+
- History.md
|
283
|
+
- LICENSE
|
284
|
+
- Manifest.txt
|
285
|
+
- README.md
|
286
|
+
- acromine.gemspec
|
287
|
+
- lib/acromine.rb
|
288
|
+
- lib/acromine/core.rb
|
289
|
+
- lib/acromine/longform.rb
|
290
|
+
- lib/acromine/longform_variant.rb
|
291
|
+
- lib/acromine/version.rb
|
292
|
+
homepage: https://github.com/jf647/acromine
|
293
|
+
licenses:
|
294
|
+
- MIT
|
295
|
+
metadata: {}
|
296
|
+
post_install_message:
|
297
|
+
rdoc_options:
|
298
|
+
- "--main"
|
299
|
+
- README.md
|
300
|
+
require_paths:
|
301
|
+
- lib
|
302
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - ">="
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: '0'
|
307
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
308
|
+
requirements:
|
309
|
+
- - ">="
|
310
|
+
- !ruby/object:Gem::Version
|
311
|
+
version: '0'
|
312
|
+
requirements: []
|
313
|
+
rubyforge_project:
|
314
|
+
rubygems_version: 2.4.4
|
315
|
+
signing_key:
|
316
|
+
specification_version: 4
|
317
|
+
summary: acromine is a client for the [Acromine REST Service](http://www.nactem.ac.uk/software/acromine/rest.html)
|
318
|
+
provided by the National Centre for Text Mining
|
319
|
+
test_files: []
|