linguistics 2.0.4 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -1
- data.tar.gz.sig +0 -0
- data/History.rdoc +5 -0
- data/lib/linguistics.rb +2 -2
- data/lib/linguistics/en/conjunctions.rb +13 -2
- data/spec/linguistics/en/conjunctions_spec.rb +14 -0
- metadata +12 -12
- metadata.gz.sig +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d34798efad8371fb583d6594d7e9301f30e0f386
|
4
|
+
data.tar.gz: 7f024ff2fd9d77ae71d1003456037aca606b44de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cddeae6bd28706064a428f6e7531bef96268d9e9579cab8f946e0648392f310b2b9e56d224ae4ec8881a77ece2405ae3ee749cbd9f4825abb2307d98015d57c
|
7
|
+
data.tar.gz: a2fc49f3d995041e10f260377024fad17f54a6abc0e6e915dc7d62094ecc34f22b97221f7987faa959bcd640f35f9563323fbbec9178a1f145b2bf5844b0176d
|
checksums.yaml.gz.sig
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
data/lib/linguistics.rb
CHANGED
@@ -12,10 +12,10 @@ module Linguistics
|
|
12
12
|
|
13
13
|
|
14
14
|
# Release version
|
15
|
-
VERSION = '2.0
|
15
|
+
VERSION = '2.1.0'
|
16
16
|
|
17
17
|
# VCS version
|
18
|
-
REVISION = %q$Revision:
|
18
|
+
REVISION = %q$Revision: c4faf117867f $
|
19
19
|
|
20
20
|
# The list of Classes to add linguistic behaviours to.
|
21
21
|
DEFAULT_EXT_CLASSES = [ String, Numeric, Array ]
|
@@ -21,6 +21,7 @@ module Linguistics::EN::Conjunctions
|
|
21
21
|
:casefold => true,
|
22
22
|
:generalize => false,
|
23
23
|
:quantsort => true,
|
24
|
+
:article => true,
|
24
25
|
}
|
25
26
|
|
26
27
|
|
@@ -83,6 +84,10 @@ module Linguistics::EN::Conjunctions
|
|
83
84
|
### list. This sort is also the fallback for indentical quantities (ie.,
|
84
85
|
### items of the same quantity will be listed in the order they appeared
|
85
86
|
### in the source list).
|
87
|
+
### [<b>:article</b>]
|
88
|
+
### If set to <tt>true</tt> (the default), singular items in the list will be
|
89
|
+
### prefixed with the appropriate indefinite article ("box" -> "a box"). Setting
|
90
|
+
### it to +false+ will omit this.
|
86
91
|
###
|
87
92
|
def conjunction( args={} )
|
88
93
|
config = CONJUNCTION_DEFAULTS.merge( args )
|
@@ -101,7 +106,10 @@ module Linguistics::EN::Conjunctions
|
|
101
106
|
self.log.debug " phrases is: %p" % [ phrases ]
|
102
107
|
|
103
108
|
# No need for a conjunction if there's only one thing
|
104
|
-
|
109
|
+
if phrases.length < 2
|
110
|
+
return phrases[0] unless config[:article]
|
111
|
+
return phrases[0].en.a
|
112
|
+
end
|
105
113
|
|
106
114
|
# Set up a Proc to derive a collector key from a phrase depending on the
|
107
115
|
# configuration
|
@@ -165,8 +173,11 @@ module Linguistics::EN::Conjunctions
|
|
165
173
|
count < 10 ? count.en.numwords : count.to_s,
|
166
174
|
phrase.en.plural( count )
|
167
175
|
]
|
168
|
-
|
176
|
+
elsif config[:article]
|
169
177
|
phrase.en.a
|
178
|
+
else
|
179
|
+
self.log.debug "No article!"
|
180
|
+
phrase
|
170
181
|
end
|
171
182
|
end
|
172
183
|
end
|
@@ -59,6 +59,10 @@ describe Linguistics::EN::Conjunctions do
|
|
59
59
|
expect( array.en.conjunction ).to eq( "a cat" )
|
60
60
|
end
|
61
61
|
|
62
|
+
it "omits the indefinite article if :article is `false`" do
|
63
|
+
expect( array.en.conjunction(article: false) ).to eq( "cat" )
|
64
|
+
end
|
65
|
+
|
62
66
|
end
|
63
67
|
|
64
68
|
|
@@ -78,6 +82,10 @@ describe Linguistics::EN::Conjunctions do
|
|
78
82
|
expect( array.en.conjunction(:conjunctive => '') ).to eq( "a cat a dog" )
|
79
83
|
end
|
80
84
|
|
85
|
+
it "doesn't add indefinite articles if :article is set to `false`" do
|
86
|
+
expect( array.en.conjunction( article: false ) ).to eq( "cat and dog" )
|
87
|
+
end
|
88
|
+
|
81
89
|
end
|
82
90
|
|
83
91
|
|
@@ -120,6 +128,12 @@ describe Linguistics::EN::Conjunctions do
|
|
120
128
|
'chicken, a goose, a Dog, and a goose' )
|
121
129
|
end
|
122
130
|
|
131
|
+
it "omits the indefinite article if :article is `false`" do
|
132
|
+
expect( array.en.conjunction(combine: false, article: false) ).to eq(
|
133
|
+
'cat, dog, fox, dog, chicken, chicken, Fox, '\
|
134
|
+
'chicken, goose, Dog, and goose' )
|
135
|
+
end
|
136
|
+
|
123
137
|
it "doesn't combine the differently-cased ones if :casefold is turned off" do
|
124
138
|
expect( array.en.conjunction(:casefold => false) ).to eq(
|
125
139
|
'three chickens, two dogs, two geese, a cat, a fox, a Fox, '\
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linguistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -12,7 +12,7 @@ cert_chain:
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
|
14
14
|
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
|
15
|
-
|
15
|
+
HhcNMTUwNDAxMjEyNDEzWhcNMTYwMzMxMjEyNDEzWjA+MQwwCgYDVQQDDANnZWQx
|
16
16
|
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
|
17
17
|
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDb92mkyYwuGBg1oRxt2tkH
|
18
18
|
+Uo3LAsaL/APBfSLzy8o3+B3AUHKCjMUaVeBoZdWtMHB75X3VQlvXfZMyBxj59Vo
|
@@ -23,14 +23,14 @@ cert_chain:
|
|
23
23
|
AgMBAAGjdTBzMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBSZ0hCV
|
24
24
|
qoHr122fGKelqffzEQBhszAcBgNVHREEFTATgRFnZWRARmFlcmllTVVELm9yZzAc
|
25
25
|
BgNVHRIEFTATgRFnZWRARmFlcmllTVVELm9yZzANBgkqhkiG9w0BAQUFAAOCAQEA
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
lUKo3NXePpuvN3QGsOLJ6QhNd4+Q9Rz75GipuMrCl296V8QFkd2gg9EG44Pqtk+9
|
27
|
+
Zac8TkKc9bCSR0snakp+cCPplVvZF0/gMzkSTUJkDBHlNV16z73CyWpbQQa+iLJ4
|
28
|
+
uisI6gF2ZXK919MYLn2bFJfb7OsCvVfyTPqq8afPY+rq9vlf9ZPwU49AlD8bPRic
|
29
|
+
0LX0gO5ykvETIOv+WgGcqp96ceNi9XVuJMh20uWuw6pmv/Ub2RqAf82jQSbpz09G
|
30
|
+
G8LHR7EjtPPmqCCunfyecJ6MmCNaiJCBxq2NYzyNmluPyHT8+0fuB5kccUVZm6CD
|
31
|
+
xn3DzOkDE6NYbk8gC9rTsA==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-
|
33
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: loggability
|
@@ -66,14 +66,14 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0.
|
69
|
+
version: '0.7'
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '0.
|
76
|
+
version: '0.7'
|
77
77
|
- !ruby/object:Gem::Dependency
|
78
78
|
name: hoe-highline
|
79
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -271,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
271
|
version: '0'
|
272
272
|
requirements: []
|
273
273
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.4.
|
274
|
+
rubygems_version: 2.4.7
|
275
275
|
signing_key:
|
276
276
|
specification_version: 4
|
277
277
|
summary: Linguistics is a framework for building linguistic utilities for Ruby objects
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
�
|
2
|
-
|
3
|
-
|
1
|
+
��.Ï%�!J�r�u�����}�������+s�UȈ'9�
|
2
|
+
��D���j\U�&�k� '�K���/'�K����3��Ya��JQT���"'HE? ;L�Y& ?�4���_�����ra��'u 5(S!���V����]���x9F�;+�餌o�;l(癭�=
|
3
|
+
��8�߫C琗qY�W�6���1�wW��{�'e�4MRfL�<:�xV>t�w��K�����/��~��vj߳�՞
|