pluralizr 0.2.0
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/pluralizr.rb +146 -0
- data/lib/pluralizr/exceptions.rb +29 -0
- data/lib/pluralizr/lists.rb +111 -0
- data/lib/pluralizr/rules.rb +45 -0
- data/lib/pluralizr/version.rb +5 -0
- data/pluralizr.gemspec +29 -0
- metadata +105 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 17c077ed1850b4d0fe7b41ab7f065069a8280f1a
|
|
4
|
+
data.tar.gz: 362d60c7ffc856b170182712236b7bb3364ade51
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 61d3f86e66377b7983533059fc88843cd238a159113972d4050ad9f36376df2b2de154836b6ffc885410418908357bea244f2c1aefe44e6fc031946a210899f0
|
|
7
|
+
data.tar.gz: bd68975f2d1f7612b140384c7c31106714c8c6411800701c84d2e0b09174c4bb2898c6fb693dc54e3f2b58d2e38444d12d0b714b9af4ef2afe544b6eff9771bf
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Johnny Hu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Pluralizr
|
|
2
|
+
|
|
3
|
+
Pluralizr is a gem that takes a single word and returns the pluralized version of that word. It attempts to take into account various rules—like, handling words that end in 'y' where the 'y' is preceded by a vowel or consonant (i.e., `day` -> `days` versus `baby` -> `babies`)—as well as words of French, Greek and Latin origins.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'pluralizr'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install pluralizr
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
Require Pluralizr in your application (or in `irb`).
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
require 'pluralizr'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Then, simply use the `Pluralizr.pluralize()` method to get pluralizing!
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
$ Pluralizr.pluralize('day')
|
|
33
|
+
=> "days"
|
|
34
|
+
|
|
35
|
+
$ Pluralizr.pluralize('baby')
|
|
36
|
+
=> "babies"
|
|
37
|
+
|
|
38
|
+
$ Pluralizr.pluralize('foot')
|
|
39
|
+
=> "feet"
|
|
40
|
+
|
|
41
|
+
$ Pluralizr.pluralize('child')
|
|
42
|
+
=> "children"
|
|
43
|
+
|
|
44
|
+
$ Pluralizr.pluralize('pundit')
|
|
45
|
+
=> "pundits"
|
|
46
|
+
|
|
47
|
+
$ Pluralizr.pluralize('alumnus')
|
|
48
|
+
=> "alumni"
|
|
49
|
+
|
|
50
|
+
$ Pluralizr.pluralize('criterion')
|
|
51
|
+
=> "criteria"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Contributing
|
|
55
|
+
|
|
56
|
+
Making a contribution is easy and happily welcomed. Simply submit a pull request on GitHub at https://github.com/srndptylabs/pluralizr/pulls. Here are a few examples of things worth submitting a pull request for:
|
|
57
|
+
|
|
58
|
+
* a word that's not pluralizing as expected
|
|
59
|
+
* a word that should be added to the exception list
|
|
60
|
+
* any bugs you encounter
|
|
61
|
+
* improvements to the README file
|
|
62
|
+
* and whatever else you can think of!
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
67
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "pluralizr"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/pluralizr.rb
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
require "pluralizr/version"
|
|
2
|
+
require "pluralizr/rules"
|
|
3
|
+
require "pluralizr/lists"
|
|
4
|
+
require "pluralizr/exceptions"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# A module that takes a single word and returns the pluralized version
|
|
8
|
+
# of that word. It attempts to take into account various rules—like,
|
|
9
|
+
# handling words that end in 'y' where the 'y' is preceded by a vowel
|
|
10
|
+
# or consonant (i.e., +day+ -> +days+ versus +baby+ -> +babies+)—as well as
|
|
11
|
+
# words of French, Greek and Latin origins.
|
|
12
|
+
|
|
13
|
+
module Pluralizr
|
|
14
|
+
|
|
15
|
+
# Pluralizes the object passed in or returns an error if an exception is raised.
|
|
16
|
+
#
|
|
17
|
+
# ==== Parameters:
|
|
18
|
+
# word::
|
|
19
|
+
# The object passed in.
|
|
20
|
+
# ==== Returns:
|
|
21
|
+
# Either an error message, if any exceptions are raised via
|
|
22
|
+
# Pluralizr.check_for_errors method, or the appropriate plural
|
|
23
|
+
# version of the word passed into the method.
|
|
24
|
+
|
|
25
|
+
def self.pluralize(word)
|
|
26
|
+
|
|
27
|
+
check_for_errors(word)
|
|
28
|
+
|
|
29
|
+
case
|
|
30
|
+
when word.is_irregular? then return IRREGULAR_WORDS[word]
|
|
31
|
+
when word.has_same_singular_and_plural_form? || word.only_has_plural_form?
|
|
32
|
+
return word
|
|
33
|
+
when word.ends_with_vowel_and_y_or_o? || word.ends_with_double_vowel_and_f?
|
|
34
|
+
return word.insert(-1, 's')
|
|
35
|
+
else
|
|
36
|
+
RULES.each do |rule, props|
|
|
37
|
+
return find_plural_of(word, props) if word.end_with?(rule)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
return find_plural_of(word, RULES['default'])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Returns +true+ if the word (the caller) ends in a vowel plus
|
|
44
|
+
# either a 'y' or an 'o'. For example, +day+ and +valley+ or
|
|
45
|
+
# +stereo+ and +tattoo+.
|
|
46
|
+
|
|
47
|
+
def ends_with_vowel_and_y_or_o?
|
|
48
|
+
self.match(/[aeiouy][oy]$/i)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Returns +true+ if the word (the caller) ends in a double vowel
|
|
52
|
+
# plus 'f'. For example, +proof+ or +handkerchief+.
|
|
53
|
+
|
|
54
|
+
def ends_with_double_vowel_and_f?
|
|
55
|
+
self.match(/[aeiouy]+[f]$/i)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns +true+ if the word (the caller) is found in
|
|
59
|
+
# the IRREGULAR_WORDS hash.
|
|
60
|
+
|
|
61
|
+
def is_irregular?
|
|
62
|
+
IRREGULAR_WORDS.include?(self)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Returns +true+ if the word (the caller) is found in
|
|
66
|
+
# the PLURAL_ONLY_WORDS hash.
|
|
67
|
+
|
|
68
|
+
def only_has_plural_form?
|
|
69
|
+
PLURAL_ONLY_WORDS.include?(self)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Returns +true+ if the word (the caller) is found in
|
|
73
|
+
# the SINGULAR_AND_PLURAL_FORMS_ARE_THE_SAME hash.
|
|
74
|
+
|
|
75
|
+
def has_same_singular_and_plural_form?
|
|
76
|
+
SINGULAR_AND_PLURAL_FORMS_ARE_THE_SAME.include?(self)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
protected
|
|
80
|
+
|
|
81
|
+
# Determines which implementation method to use based on
|
|
82
|
+
# several factors: whether or not the rule from the RULES
|
|
83
|
+
# hash matching the word being passed in has an exceptions list
|
|
84
|
+
# and, if so, whether the word is on that list or not.
|
|
85
|
+
# ==== Parameters:
|
|
86
|
+
# word::
|
|
87
|
+
# A String representing the original word passed in.
|
|
88
|
+
# props::
|
|
89
|
+
# A hash value representing the properties of the rule,
|
|
90
|
+
# from the RULES hash, matching the word passed in.
|
|
91
|
+
# ==== Returns:
|
|
92
|
+
# The pluralized form of the original word passed in.
|
|
93
|
+
|
|
94
|
+
def self.find_plural_of(word, props)
|
|
95
|
+
if !props[:has_exception_list]
|
|
96
|
+
convert_ending_of(word, props[:with_ending], props[:offset])
|
|
97
|
+
elsif EXCEPTIONS_LIST.include?(word)
|
|
98
|
+
EXCEPTIONS_LIST[word]
|
|
99
|
+
else
|
|
100
|
+
convert_ending_of(word, props[:with_ending], props[:offset])
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Checks if word passed into the Pluralizr.pluralize method
|
|
105
|
+
# raises any errors. Currently, the following errors are checked:
|
|
106
|
+
# Pluralizr::InvalidTypeError, Pluralizr::InvalidStringError,
|
|
107
|
+
# and Pluralizr::TooManyWordsError.
|
|
108
|
+
#
|
|
109
|
+
# ==== Parameters:
|
|
110
|
+
# word::
|
|
111
|
+
# A String representing the original word passed in.
|
|
112
|
+
# ==== Returns:
|
|
113
|
+
# An error message and backtrace if an error is raised.
|
|
114
|
+
|
|
115
|
+
def self.check_for_errors(word)
|
|
116
|
+
raise InvalidTypeError if !word.is_a? String
|
|
117
|
+
raise InvalidStringError if word.match(/^[\d\W_]/)
|
|
118
|
+
raise TooManyWordsError if !word.match(/^[a-z]+$/i)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Converts the word passed into the Pluralizr.pluralize method
|
|
122
|
+
# into its plural form.
|
|
123
|
+
#
|
|
124
|
+
# ==== Parameters:
|
|
125
|
+
# word::
|
|
126
|
+
# A String representing the original word passed in.
|
|
127
|
+
# with_ending::
|
|
128
|
+
# A String representing the word's plural form ending.
|
|
129
|
+
# offset::
|
|
130
|
+
# An Integer representing the number of letters to remove from the
|
|
131
|
+
# end of the original word, before appending the plural form ending.
|
|
132
|
+
#
|
|
133
|
+
# ==== Returns:
|
|
134
|
+
# A string representing the pluralized form of the original word passed in.
|
|
135
|
+
|
|
136
|
+
def self.convert_ending_of(word, with_ending, offset)
|
|
137
|
+
word[0..offset].insert(-1, with_ending)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Includes Pluralizr in String class.
|
|
143
|
+
|
|
144
|
+
class String
|
|
145
|
+
include Pluralizr
|
|
146
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Pluralizr
|
|
2
|
+
|
|
3
|
+
# A TypeError meant to inform users when the object passed into the Pluralizr.pluralize method isn't a String.
|
|
4
|
+
# For example, integers, boolean values, arrays, etc.
|
|
5
|
+
|
|
6
|
+
class InvalidTypeError < TypeError
|
|
7
|
+
def initialize(msg="argument must be a String")
|
|
8
|
+
super
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# A TypeError meant to inform users when the object passed into the Pluralizr.pluralize method doesn't begin with a letter.
|
|
13
|
+
# For example, words like +32numbersfirst+ and +.specialcharactersfirst+
|
|
14
|
+
|
|
15
|
+
class InvalidStringError < TypeError
|
|
16
|
+
def initialize(msg="string must begin with a letter")
|
|
17
|
+
super
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# An ArgumentError meant to inform users when the object passed into the Pluralizr.pluralize method is a String, but contains more than one word.
|
|
22
|
+
# For example, strings like <tt>"More than one word"</tt>.
|
|
23
|
+
|
|
24
|
+
class TooManyWordsError < ArgumentError
|
|
25
|
+
def initialize(msg="argument contains too many words")
|
|
26
|
+
super
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
module Pluralizr
|
|
2
|
+
|
|
3
|
+
# List of words that are exceptions to the rules in the RULES constant variable hash.
|
|
4
|
+
|
|
5
|
+
EXCEPTIONS_LIST = {
|
|
6
|
+
# SXZCHSH_EXCEPTIONS
|
|
7
|
+
'quiz' => 'quizzes',
|
|
8
|
+
'stomach' => 'stomachs',
|
|
9
|
+
'epoch' => 'epochs',
|
|
10
|
+
|
|
11
|
+
# FE_F_EXCEPTIONS
|
|
12
|
+
'chef' => 'chefs',
|
|
13
|
+
'dwarf' => 'dwarfs',
|
|
14
|
+
'gulf' => 'gulfs',
|
|
15
|
+
'hoof' => 'hooves',
|
|
16
|
+
'safe' => 'safes',
|
|
17
|
+
'surf' => 'surfs',
|
|
18
|
+
'turf' => 'turfs',
|
|
19
|
+
|
|
20
|
+
# EX_EXCEPTIONS
|
|
21
|
+
'annex' => 'annexes',
|
|
22
|
+
'complex' => 'complexes',
|
|
23
|
+
'duplex' => 'duplexes',
|
|
24
|
+
'hex' => 'hexes',
|
|
25
|
+
'index' => 'indexes',
|
|
26
|
+
'sex' => 'sexes',
|
|
27
|
+
|
|
28
|
+
# O_EXCEPTIONS
|
|
29
|
+
'albino' => 'albinos',
|
|
30
|
+
'armadillo' => 'armadillos',
|
|
31
|
+
'auto' => 'autos',
|
|
32
|
+
'cello' => 'cellos',
|
|
33
|
+
'combo' => 'combos',
|
|
34
|
+
'ego' => 'egos',
|
|
35
|
+
'halo' => 'halos',
|
|
36
|
+
'inferno' => 'infernos',
|
|
37
|
+
'lasso' => 'lassos',
|
|
38
|
+
'memento' => 'mementos',
|
|
39
|
+
'memo' => 'memos',
|
|
40
|
+
'piano' => 'pianos',
|
|
41
|
+
'photo' => 'photos',
|
|
42
|
+
'pro' => 'pros',
|
|
43
|
+
'silo' => 'silos',
|
|
44
|
+
'solo' => 'solos',
|
|
45
|
+
'taco' => 'tacos',
|
|
46
|
+
'tuxedo' => 'tuxedos',
|
|
47
|
+
'typo' => 'typos',
|
|
48
|
+
|
|
49
|
+
# UM_EXCEPTIONS
|
|
50
|
+
'album' => 'albums',
|
|
51
|
+
'stadium' => 'stadiums',
|
|
52
|
+
'minimum' => 'minimums',
|
|
53
|
+
'maximum' => 'maximums',
|
|
54
|
+
'premium' => 'premiums',
|
|
55
|
+
'vacuum' => 'vacuums',
|
|
56
|
+
|
|
57
|
+
# STRICT_LATIN_ORIGINS
|
|
58
|
+
'radius' => 'radii',
|
|
59
|
+
'alumnus' => 'alumni',
|
|
60
|
+
'cactus' => 'cacti',
|
|
61
|
+
'fungus' => 'fungi',
|
|
62
|
+
'nucleus' => 'nuclei',
|
|
63
|
+
'genus' => 'genera',
|
|
64
|
+
'syllabus' => 'syllabi',
|
|
65
|
+
'alga' => 'algae',
|
|
66
|
+
'vertebra' => 'vertebrae',
|
|
67
|
+
'larva' => 'larvae',
|
|
68
|
+
|
|
69
|
+
# STRICT_GREEK_ORIGINS
|
|
70
|
+
'automaton' => 'automata',
|
|
71
|
+
'criterion' => 'criteria',
|
|
72
|
+
'phenomenon' => 'phenomena',
|
|
73
|
+
|
|
74
|
+
# ITALIAN_ORIGINS
|
|
75
|
+
'espresso' => 'espressos',
|
|
76
|
+
'pizza' => 'pizzas',
|
|
77
|
+
'risotto' => 'risottos',
|
|
78
|
+
'paparazzo' => 'paparazzi',
|
|
79
|
+
'spaghetto' => 'spaghetti'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
# List of words whose plural form doesn't adhere to a rule in the RULES hash, but instead, often mutates the original word.
|
|
83
|
+
# For example, +mouse+ => +mice+. Or, +foot+ => +feet+.
|
|
84
|
+
|
|
85
|
+
IRREGULAR_WORDS = {
|
|
86
|
+
'child' => 'children',
|
|
87
|
+
'die' => 'dice',
|
|
88
|
+
'foot' => 'feet',
|
|
89
|
+
'goose' => 'geese',
|
|
90
|
+
'louse' => 'lice',
|
|
91
|
+
'man' => 'men',
|
|
92
|
+
'mouse' => 'mice',
|
|
93
|
+
'ox' => 'oxen',
|
|
94
|
+
'person' => 'people',
|
|
95
|
+
'that' => 'those',
|
|
96
|
+
'this' => 'these',
|
|
97
|
+
'tooth' => 'teeth',
|
|
98
|
+
'woman' => 'women'
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# List of words whose plural form is the same as its singular form.
|
|
102
|
+
# For example, +deer+ is used in both singular and plural contexts.
|
|
103
|
+
|
|
104
|
+
SINGULAR_AND_PLURAL_FORMS_ARE_THE_SAME = %w(advice aircraft bison corn deer equipment evidence gold information jewelry kin legislation luck luggage moose music offspring sheep silver swine trousers trout wheat)
|
|
105
|
+
|
|
106
|
+
# List of words that only have a plural form. There is no singular form of the word.
|
|
107
|
+
# For example, the word +tweezers+ has no singular form. The word tweezer is actually a verb and not a noun.
|
|
108
|
+
|
|
109
|
+
PLURAL_ONLY_WORDS = %w(barracks bellows cattle deer dregs eyeglasses gallows headquarters mathematics means measles mumps news oats pants pliers pajamas scissors series shears shorts species tongs tweezers vespers)
|
|
110
|
+
|
|
111
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Pluralizr
|
|
2
|
+
|
|
3
|
+
# Hash containing the various rules for specific word endings
|
|
4
|
+
# in the English language.
|
|
5
|
+
#--
|
|
6
|
+
# These endings are stored in the hash as keys. Each key has a set
|
|
7
|
+
# of properties as its value. These properties specify the word's
|
|
8
|
+
# plural form ending, how the plural form should be applied to the
|
|
9
|
+
# original word, and if there are any words considered exceptions
|
|
10
|
+
# to the particular rule.
|
|
11
|
+
#
|
|
12
|
+
# For example, given a word that ends in 'a', the pluralize() method
|
|
13
|
+
# will check for errors (see exceptions.rb) and special cases (see lists.rb),
|
|
14
|
+
# and then iterate through the RULES hash below. Since the word ends in
|
|
15
|
+
# 'a', it matches with the RULES['a'] key, and since this list contains an
|
|
16
|
+
# exceptions list, it checks if the word is on the list. If so, it returns
|
|
17
|
+
# the plural version of that word from the exceptions list. If not, it adds
|
|
18
|
+
# an 's' to the end of the original word and returns it.
|
|
19
|
+
|
|
20
|
+
RULES = {
|
|
21
|
+
'ia' => { with_ending: 's', offset: -1 },
|
|
22
|
+
'a' => { with_ending: 's', offset: -1, has_exception_list: true },
|
|
23
|
+
'ffe' => { with_ending: 's', offset: -1 },
|
|
24
|
+
'fe' => { with_ending: 'ves', offset: -3, has_exception_list: true },
|
|
25
|
+
'ff' => { with_ending: 's', offset: -1 },
|
|
26
|
+
'f' => { with_ending: 'ves', offset: -2, has_exception_list: true },
|
|
27
|
+
'ch' => { with_ending: 'es', offset: -1, has_exception_list: true },
|
|
28
|
+
'sh' => { with_ending: 'es', offset: -1, has_exception_list: true },
|
|
29
|
+
'um' => { with_ending: 'a', offset: -3, has_exception_list: true },
|
|
30
|
+
'tion' => { with_ending: 's', offset: -1 },
|
|
31
|
+
'on' => { with_ending: 's', offset: -1, has_exception_list: true },
|
|
32
|
+
'o' => { with_ending: 'es', offset: -1, has_exception_list: true },
|
|
33
|
+
'is' => { with_ending: 'es', offset: -3 },
|
|
34
|
+
'us' => { with_ending: 'es', offset: -1, has_exception_list: true },
|
|
35
|
+
's' => { with_ending: 'es', offset: -1, has_exception_list: true },
|
|
36
|
+
'eau' => { with_ending: 's', offset: -1 },
|
|
37
|
+
'ex' => { with_ending: 'ices', offset: -3, has_exception_list: true },
|
|
38
|
+
'x' => { with_ending: 'es', offset: -1, has_exception_list: true },
|
|
39
|
+
'y' => { with_ending: 'ies', offset: -2 },
|
|
40
|
+
'z' => { with_ending: 'es', offset: -1, has_exception_list: true },
|
|
41
|
+
'irregular' => { offset: -1, has_exception_list: true },
|
|
42
|
+
'default' => { with_ending: 's', offset: -1 }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
end
|
data/pluralizr.gemspec
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'pluralizr/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'pluralizr'
|
|
8
|
+
spec.version = Pluralizr::VERSION
|
|
9
|
+
spec.license = 'MIT'
|
|
10
|
+
spec.summary = 'A gem that pluralizes the singular form of a word passed in.'
|
|
11
|
+
spec.description = <<-EOF
|
|
12
|
+
Pluralizr is a gem that takes a single word and returns the pluralized version of that word. It takes into account various rules including words that end with the letter 'y'—where 'y' is preceded by a vowel or consonant—and words of French, Greek and Latin origins.
|
|
13
|
+
EOF
|
|
14
|
+
spec.homepage = 'https://github.com/srndptylabs/pluralizr'
|
|
15
|
+
|
|
16
|
+
spec.authors = ['Johnny Hu']
|
|
17
|
+
spec.email = ['jgeehen.hu@gmail.com']
|
|
18
|
+
|
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
|
21
|
+
end
|
|
22
|
+
spec.bindir = 'exe'
|
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
|
+
spec.require_paths = ['lib']
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
29
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pluralizr
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Johnny Hu
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.13'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.13'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description: " Pluralizr is a gem that takes a single word and returns the pluralized
|
|
56
|
+
version of that word. It takes into account various rules including words that end
|
|
57
|
+
with the letter 'y'—where 'y' is preceded by a vowel or consonant—and words of French,
|
|
58
|
+
Greek and Latin origins.\n"
|
|
59
|
+
email:
|
|
60
|
+
- jgeehen.hu@gmail.com
|
|
61
|
+
executables: []
|
|
62
|
+
extensions: []
|
|
63
|
+
extra_rdoc_files: []
|
|
64
|
+
files:
|
|
65
|
+
- ".gitignore"
|
|
66
|
+
- ".rspec"
|
|
67
|
+
- ".travis.yml"
|
|
68
|
+
- CHANGELOG.md
|
|
69
|
+
- Gemfile
|
|
70
|
+
- LICENSE.txt
|
|
71
|
+
- README.md
|
|
72
|
+
- Rakefile
|
|
73
|
+
- bin/console
|
|
74
|
+
- bin/setup
|
|
75
|
+
- lib/pluralizr.rb
|
|
76
|
+
- lib/pluralizr/exceptions.rb
|
|
77
|
+
- lib/pluralizr/lists.rb
|
|
78
|
+
- lib/pluralizr/rules.rb
|
|
79
|
+
- lib/pluralizr/version.rb
|
|
80
|
+
- pluralizr.gemspec
|
|
81
|
+
homepage: https://github.com/srndptylabs/pluralizr
|
|
82
|
+
licenses:
|
|
83
|
+
- MIT
|
|
84
|
+
metadata: {}
|
|
85
|
+
post_install_message:
|
|
86
|
+
rdoc_options: []
|
|
87
|
+
require_paths:
|
|
88
|
+
- lib
|
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">="
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
- - ">="
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0'
|
|
99
|
+
requirements: []
|
|
100
|
+
rubyforge_project:
|
|
101
|
+
rubygems_version: 2.6.8
|
|
102
|
+
signing_key:
|
|
103
|
+
specification_version: 4
|
|
104
|
+
summary: A gem that pluralizes the singular form of a word passed in.
|
|
105
|
+
test_files: []
|