Project

acromine

0.0
No commit activity in last 3 years
No release in over 3 years
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. This gem provides a library to easily find the long form of an acronym. A CLI is also provided to use the library from the command line.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.8
~> 2.12
~> 3.13
~> 10.3
~> 4.0
~> 3.1
~> 0.9
~> 0.8

Runtime

~> 2.13
~> 0.13
~> 0.9
 Project Readme

Acromine Client

DESCRIPTION

acromine is a client for the Acromine REST Service provided by the National Centre for Text Mining.

This gem provides a library to easily find the long form of an acronym.

A CLI is also provided to use the library from the command line.

SYNOPSIS

require 'acromine'

acro = Acromine.new
puts "HMM may refer to:"
acro.longforms('HMM').variants.each do |lf|
  puts "  #{lf.longform}"
end

INSTALLATION

gem install acromine

REQUIREMENTS

  • ruby 2.x or higher
    • tested with MRI 2.2.2

LIBRARY USAGE

First, construct an Acromine object:

require 'acromine'
acro = Acromine.new

The object has one method #longforms, which takes a single acronym as an argument and returns a list of Acromine::Longform objects. If the acronym is not found, the list will be empty.

Each Longform object has four getter methods:

  • #longform which returns the long form of the acronym
  • #frequency which returns the number of occurences of the acronym
  • #since which returns the year the definition first appears in the Acromine corpus
  • #variants, which returns a list of Acromine::LongformVariant objects.

Each Longform will always have at least one LongformVariant.

To limit the number of variants returned, pass a limit in an options hash:

acro.longforms('HMM').variants(limit: 5)

Variants will be sorted by descending frequency count then by ascending variant year and finally by ascending long form.

This order can be changed using the 'sort_spec' option. The spec is one or two two-character pairs joined by a comma. The first character of the pair is what to sort - f for the frequency and y for the year. The second character of the pair is how to sort - a for ascending and d for descending:

acro.longforms('HMM').variants(sort_spec: 'fa,yd')

A LongformVariant object has three getter methods:

  • #longform which returns the long form of the acronym
  • #freq which returns the number of occurences of the acronym
  • #since which returns the year the definition first appears in the Acromine corpus

To view the full documentation, refer to the DEVELOPMENT section below.

CLI USAGE

acromine lf [--limit N] [--sort SPEC] ACRONYM

Help can be displayed for global options:

acromine help

Or for a individual command:

acromine help lf

CONFIG FILE

The CLI options can have their defaults set via a config file. To create it, run:

acromine initconfig

which will create the file ~/.acromine.conf. The defaults will be written to this file, which can be edited as desired. For example, the following file sets the sort order to oldest then by most used and sets a limit of 5:

---
commands:
  :longform:
    :sort: yd,fd
    :limit: 5

DEVELOPMENT

To set up for development, run

bundle

To run tests, run

bundle exec rake spec      # unit tests
bundle exec rake features  # feature tests
bundle exec rake test      # all tests

Unit tests use a mocked source, while feature tests require internet access to the Acromine service.

To run tests automatically when the source changes, start guard:

bundle exec guard

To generate a code coverage report, run

bundle exec rake coverage

The report will be generated in the coverage subdirectory. Open index.html in this directory to start browsing

To generate library documentation, run

bundle exec rake doc

The rdoc will be generated in the doc subdirectory. Open index.html in this directory to start browsing the documentation.

LICENSE

(The MIT License)

Copyright (c) 2015, James FitzGibbon

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

AUTHOR

James FitzGibbon james@nadt.net