linguistics 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/ChangeLog +113 -2
- data/History.rdoc +8 -0
- data/README.rdoc +33 -42
- data/Rakefile +2 -0
- data/lib/linguistics.rb +2 -2
- data/lib/linguistics/en/pluralization.rb +1 -0
- data/spec/linguistics/en/articles_spec.rb +41 -0
- data/spec/linguistics/en/pluralization_spec.rb +9 -1
- metadata +28 -10
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/ChangeLog
CHANGED
@@ -1,5 +1,116 @@
|
|
1
|
+
2012-12-18 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* Rakefile:
|
4
|
+
Add missing loggability dependency to the gem (fixes #3).
|
5
|
+
[49fe3002596e] [tip]
|
6
|
+
|
7
|
+
2012-11-26 Michael Granger <ged@FaerieMUD.org>
|
8
|
+
|
9
|
+
* lib/linguistics/en/pluralization.rb,
|
10
|
+
spec/linguistics/en/articles_spec.rb,
|
11
|
+
spec/linguistics/en/pluralization_spec.rb:
|
12
|
+
Adding some monkeypatch specs (refs #1), fixing some edge-case
|
13
|
+
pluralizations.
|
14
|
+
[0b5177d918d9] [github/master]
|
15
|
+
|
16
|
+
2012-10-10 Michael Granger <ged@FaerieMUD.org>
|
17
|
+
|
18
|
+
* README.rdoc:
|
19
|
+
The inevitable post-release documentation fixes.
|
20
|
+
[f251780dff66]
|
21
|
+
|
22
|
+
* .hgtags:
|
23
|
+
Added tag v2.0.0 for changeset 1359338b7128
|
24
|
+
[d49d90d35935]
|
25
|
+
|
26
|
+
* .hgsigs:
|
27
|
+
Added signature for changeset a7cda4b8747c
|
28
|
+
[1359338b7128] [v2.0.0]
|
29
|
+
|
30
|
+
* History.rdoc, Manifest.txt, lib/linguistics.rb,
|
31
|
+
lib/linguistics/en/stemmer.rb, spec/lib/helpers.rb,
|
32
|
+
spec/linguistics/en/articles_spec.rb,
|
33
|
+
spec/linguistics/en/stemmer_spec.rb:
|
34
|
+
Prep for release.
|
35
|
+
[a7cda4b8747c]
|
36
|
+
|
37
|
+
* spec/linguistics/en/stemmer_spec.rb,
|
38
|
+
spec/linguistics/en/stemmer_spec.rb.rb:
|
39
|
+
Fix the name of the stemmer spec
|
40
|
+
[b554ff333b27]
|
41
|
+
|
42
|
+
* .rvm.gems, Rakefile, lib/linguistics/en/stemmer.rb,
|
43
|
+
spec/linguistics/en/stemmer_spec.rb.rb:
|
44
|
+
Adding support for Ruby-Stemmer
|
45
|
+
[5e5e6e77c366]
|
46
|
+
|
47
|
+
* lib/linguistics/en/wordnet.rb, spec/linguistics/en/wordnet_spec.rb:
|
48
|
+
Make wordnet re-use the error it raised when it was required if it
|
49
|
+
couldn't be loaded
|
50
|
+
[39f336798e9e]
|
51
|
+
|
52
|
+
2012-10-01 Michael Granger <ged@FaerieMUD.org>
|
53
|
+
|
54
|
+
* .rvm.gems, Rakefile, spec/lib/helpers.rb:
|
55
|
+
Add coverage task.
|
56
|
+
[3bb236bc49b3]
|
57
|
+
|
58
|
+
2012-08-21 Michael Granger <ged@FaerieMUD.org>
|
59
|
+
|
60
|
+
* Manifest.txt:
|
61
|
+
Fix the manifest
|
62
|
+
[cd25aa994e9a]
|
63
|
+
|
64
|
+
* .pryrc, lib/linguistics.rb, lib/linguistics/en.rb,
|
65
|
+
lib/linguistics/en/conjugation.rb, lib/linguistics/en/numbers.rb,
|
66
|
+
lib/linguistics/en/wordnet.rb, lib/linguistics/inflector.rb,
|
67
|
+
lib/linguistics/mixins.rb, spec/linguistics/mixins_spec.rb,
|
68
|
+
spec/linguistics_spec.rb:
|
69
|
+
Loggability cleanup
|
70
|
+
[8b1c8ec50991]
|
71
|
+
|
72
|
+
2012-08-20 Michael Granger <ged@FaerieMUD.org>
|
73
|
+
|
74
|
+
* lib/linguistics/en/wordnet.rb, spec/lib/helpers.rb,
|
75
|
+
spec/linguistics/en/wordnet_spec.rb:
|
76
|
+
Fix Linguistics::EN::WordNet.synsets.
|
77
|
+
[d9968c65d89c]
|
78
|
+
|
79
|
+
* Manifest.txt:
|
80
|
+
Add the en-language tester to the manifest
|
81
|
+
[be0e25789e59]
|
82
|
+
|
83
|
+
2012-08-18 Michael Granger <ged@FaerieMUD.org>
|
84
|
+
|
85
|
+
* examples/endocs.rb:
|
86
|
+
Added tester script for EN-module docs
|
87
|
+
[04340d1e66bd]
|
88
|
+
|
89
|
+
* .pryrc, README.rdoc, lib/linguistics.rb, lib/linguistics/en.rb,
|
90
|
+
lib/linguistics/en/articles.rb, lib/linguistics/en/conjugation.rb,
|
91
|
+
lib/linguistics/en/conjunctions.rb,
|
92
|
+
lib/linguistics/en/infinitives.rb, lib/linguistics/en/linkparser.rb,
|
93
|
+
lib/linguistics/en/numbers.rb, lib/linguistics/en/participles.rb,
|
94
|
+
lib/linguistics/en/pluralization.rb,
|
95
|
+
lib/linguistics/en/titlecase.rb, lib/linguistics/en/wordnet.rb,
|
96
|
+
lib/linguistics/inflector.rb, lib/linguistics/iso639.rb,
|
97
|
+
spec/linguistics/en/articles_spec.rb,
|
98
|
+
spec/linguistics/en/conjunctions_spec.rb,
|
99
|
+
spec/linguistics/en/participles_spec.rb,
|
100
|
+
spec/linguistics/en/pluralization_spec.rb,
|
101
|
+
spec/linguistics/en/titlecase_spec.rb,
|
102
|
+
spec/linguistics/en/wordnet_spec.rb:
|
103
|
+
Documentation fixes, bugfixes
|
104
|
+
[8103736e8a86]
|
105
|
+
|
1
106
|
2012-08-06 Michael Granger <ged@FaerieMUD.org>
|
2
107
|
|
108
|
+
* lib/linguistics/en/wordnet.rb,
|
109
|
+
spec/linguistics/en/conjugation_spec.rb,
|
110
|
+
spec/linguistics/en/linkparser_spec.rb:
|
111
|
+
LinkParser spec fixes.
|
112
|
+
[6ed3a11ea12b]
|
113
|
+
|
3
114
|
* .rvm.gems, .tm_properties, Manifest.txt, README.rdoc, Rakefile,
|
4
115
|
lib/linguistics.rb, lib/linguistics/en/conjugation.rb,
|
5
116
|
lib/linguistics/en/wordnet.rb, lib/linguistics/utils.rb,
|
@@ -15,7 +126,7 @@
|
|
15
126
|
spec/linguistics/en/wordnet_spec.rb, spec/linguistics/en_spec.rb,
|
16
127
|
spec/linguistics_spec.rb:
|
17
128
|
Prepping for 2.x release
|
18
|
-
[a01e8cf31ac3]
|
129
|
+
[a01e8cf31ac3]
|
19
130
|
|
20
131
|
* History.rdoc, LICENSE, Manifest.txt, lib/linguistics/en.rb,
|
21
132
|
lib/linguistics/en/articles.rb, lib/linguistics/en/conjugation.rb,
|
@@ -152,7 +263,7 @@
|
|
152
263
|
|
153
264
|
* examples/klingon.rb:
|
154
265
|
Better comments for the klingon example
|
155
|
-
[6ba52cffd4f6]
|
266
|
+
[6ba52cffd4f6] [github/redesign_for_2.0]
|
156
267
|
|
157
268
|
* README.md, examples/klingon.rb:
|
158
269
|
Updating the "how to add a language module" section of the README
|
data/History.rdoc
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== v2.0.1 [2013-02-25] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
- Add missing loggability dependency to the gem (fixes #3).
|
4
|
+
- Adding some monkeypatch specs (refs #1), fixing some edge-case
|
5
|
+
pluralizations.
|
6
|
+
- Documentation fixes.
|
7
|
+
|
8
|
+
|
1
9
|
== v2.0.0 [2012-10-10] Michael Granger <ged@FaerieMUD.org>
|
2
10
|
|
3
11
|
Rewritten to be more modular, easier to extend and maintain, and to work under
|
data/README.rdoc
CHANGED
@@ -12,13 +12,6 @@ objects in any language. It includes a generic language-independant
|
|
12
12
|
front end, a module for mapping language codes into language names, and
|
13
13
|
a module which contains various English-language utilities.
|
14
14
|
|
15
|
-
Here are a few whimsical examples:
|
16
|
-
|
17
|
-
Linguistics.use( :en )
|
18
|
-
#
|
19
|
-
|
20
|
-
puts "Head of State".en.quantify( 11 )'
|
21
|
-
|
22
15
|
|
23
16
|
== Usage
|
24
17
|
|
@@ -39,16 +32,16 @@ cluttering up the interface or risking collision between them, albeit at
|
|
39
32
|
the cost of three or four more characters per method invocation. For
|
40
33
|
example:
|
41
34
|
|
42
|
-
|
43
|
-
|
44
|
-
|
35
|
+
Linguistics.use( :en )
|
36
|
+
"goose".en.plural
|
37
|
+
# => "geese"
|
45
38
|
|
46
39
|
If you prefer monkeypatching (around 70) linguistics methods directly onto core
|
47
40
|
classes, you can do that by adding a 'monkeypatch' option to ::use:
|
48
41
|
|
49
42
|
Linguistics.use( :en, monkeypatch: true )
|
50
|
-
|
51
|
-
|
43
|
+
"goose".plural
|
44
|
+
# => "geese"
|
52
45
|
|
53
46
|
=== Controlling Which Classes Get Extended
|
54
47
|
|
@@ -67,28 +60,26 @@ You can also pass an Array of classes to .use:
|
|
67
60
|
Or you can add language methods to classes via mixin:
|
68
61
|
|
69
62
|
class MyClass
|
70
|
-
|
71
|
-
|
63
|
+
include Linguistics::EN
|
64
|
+
end
|
72
65
|
|
73
66
|
All Linguistics methods use Ruby's casting mechanism, so at a minimum,
|
74
67
|
your classes should provide an implementation of #to_s that returns
|
75
68
|
words or phrases.
|
76
69
|
|
77
70
|
|
78
|
-
|
79
|
-
|
80
71
|
=== Adding Language Modules
|
81
72
|
|
82
73
|
To add a new language to the framework, define a module that will act as
|
83
74
|
the top-level namespace for all your linguistic functions, and then
|
84
75
|
register it as being available, like so:
|
85
76
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
77
|
+
module Linguistics::TLH
|
78
|
+
|
79
|
+
# Add Klingon to the list of default languages
|
80
|
+
Linguistics.register_language( :tlh, self )
|
90
81
|
|
91
|
-
|
82
|
+
end
|
92
83
|
|
93
84
|
The first argument is either the two- or three-letter [ISO 639.2]
|
94
85
|
(http://www.loc.gov/standards/iso639-2/php/code_list.php) language code
|
@@ -99,43 +90,43 @@ The second is the container module itself.
|
|
99
90
|
After you register your language, each class that Linguistics is told to
|
100
91
|
extend will have a method for your language code/s:
|
101
92
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
93
|
+
irb> Linguistics.use( :tlh, :classes => Object )
|
94
|
+
# => [Object]
|
95
|
+
irb> Object.new.tlh
|
96
|
+
# => #<(Klingon; tlhIngan-Hol-language inflector) for <Object:0x402d9674> >
|
106
97
|
|
107
98
|
If you use RSpec 2, you can test out any API requirements of the module
|
108
99
|
by requiring 'linguistics/languagebehavior' and adding a shared
|
109
100
|
behavior to your spec:
|
110
101
|
|
111
|
-
|
102
|
+
require 'rspec'
|
112
103
|
require 'linguistics/languagebehavior'
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
104
|
+
|
105
|
+
describe Linguistics::TLH do
|
106
|
+
|
107
|
+
it_should_behave_like "a Linguistics language module"
|
108
|
+
|
109
|
+
# ... any other specs for your module
|
110
|
+
|
111
|
+
end
|
121
112
|
|
122
113
|
If you wish to use the logging subsystem set up by Linguistics, you can
|
123
114
|
do so one of two ways: by logging to the logger directly:
|
124
115
|
|
125
|
-
|
116
|
+
Linguistics.log.debug "Registering Klingon language extension"
|
126
117
|
|
127
118
|
or by mixing the `Linguistics::Loggable' module into your class/module,
|
128
119
|
which will give you a 'log' method that prepends the object class on
|
129
120
|
each log message so it's easy to filter out the ones you want:
|
130
121
|
|
131
|
-
|
132
|
-
|
133
|
-
|
122
|
+
require 'linguistics/mixins'
|
123
|
+
class Linguistics::TLH::Generator
|
124
|
+
include Linguistics::Loggable
|
134
125
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
126
|
+
def generate_it
|
127
|
+
self.log.debug "starting generation..."
|
128
|
+
end
|
129
|
+
end
|
139
130
|
|
140
131
|
|
141
132
|
|
data/Rakefile
CHANGED
@@ -15,6 +15,8 @@ hoespec = Hoe.spec 'linguistics' do
|
|
15
15
|
|
16
16
|
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
17
17
|
|
18
|
+
self.dependency 'loggability', '~> 0.5'
|
19
|
+
|
18
20
|
self.dependency 'hoe-deveiate', '~> 0.1', :development
|
19
21
|
self.dependency 'linkparser', '~> 1.1', :development
|
20
22
|
self.dependency 'wordnet', '~> 0.99', :development
|
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.0.1'
|
16
16
|
|
17
17
|
# VCS version
|
18
|
-
REVISION = %q$Revision:
|
18
|
+
REVISION = %q$Revision: 5240c28c80bd $
|
19
19
|
|
20
20
|
# The list of Classes to add linguistic behaviours to.
|
21
21
|
DEFAULT_EXT_CLASSES = [ String, Numeric, Array ]
|
@@ -658,6 +658,7 @@ module Linguistics::EN::Pluralization
|
|
658
658
|
|
659
659
|
# Handle ...y
|
660
660
|
when /(.*[aeiou])y$/i then return "#{$1}ys"
|
661
|
+
when /(.*)Secretary$/ then return "#{$1}Secretaries"
|
661
662
|
when /([A-Z].*y)$/ then return "#{$1}s"
|
662
663
|
when /(.*)y$/i then return "#{$1}ies"
|
663
664
|
|
@@ -29,6 +29,34 @@ describe Linguistics::EN::Articles do
|
|
29
29
|
reset_logging()
|
30
30
|
end
|
31
31
|
|
32
|
+
it "adds EN::Articles to the list of English language modules" do
|
33
|
+
Linguistics::EN.should have_extension( :articles )
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
describe "in monkeypatch mode" do
|
38
|
+
|
39
|
+
let( :monkeypatched_class ) do
|
40
|
+
Class.new do
|
41
|
+
def to_s; "antelope"; end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
let( :monkeypatched_object ) do
|
45
|
+
Linguistics.use( :en, classes: monkeypatched_class, monkeypatch: true )
|
46
|
+
monkeypatched_class.new
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
it "uses the stringified receiver as the object which should get the article" do
|
51
|
+
monkeypatched_object.a.should == 'an antelope'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "uses correct pluralization to form the negative article" do
|
55
|
+
monkeypatched_object.no.should == 'no antelopes'
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
32
60
|
|
33
61
|
it "uses 'an' as the indefinite article for 'A.B.C'" do
|
34
62
|
"A.B.C".en.a.should == "an A.B.C"
|
@@ -771,6 +799,19 @@ describe Linguistics::EN::Articles do
|
|
771
799
|
end
|
772
800
|
|
773
801
|
|
802
|
+
it "uses correct pluralization to form the negative article" do
|
803
|
+
"mouse".en.no.should == "no mice"
|
804
|
+
end
|
805
|
+
|
806
|
+
it "uses currect pluralization for noun phrases to form the negative article" do
|
807
|
+
"univariate statistic".en.no.should == "no univariate statistics"
|
808
|
+
end
|
809
|
+
|
810
|
+
it "uses the correct pluralization for 'Secretary of State' to form the negative article" do
|
811
|
+
"Secretary of State".en.no.should == "no Secretaries of State"
|
812
|
+
end
|
813
|
+
|
814
|
+
|
774
815
|
context "lprintf formatters" do
|
775
816
|
|
776
817
|
it "registers the :A lprintf formatter" do
|
@@ -1461,7 +1461,7 @@ describe Linguistics::EN::Pluralization do
|
|
1461
1461
|
end
|
1462
1462
|
|
1463
1463
|
|
1464
|
-
it "pluralizes 'ferry
|
1464
|
+
it "pluralizes 'ferry as 'ferries'" do
|
1465
1465
|
'ferry'.en.plural.should == 'ferries' #
|
1466
1466
|
end
|
1467
1467
|
|
@@ -4632,5 +4632,13 @@ describe Linguistics::EN::Pluralization do
|
|
4632
4632
|
|
4633
4633
|
end
|
4634
4634
|
|
4635
|
+
context "workarounds" do
|
4636
|
+
|
4637
|
+
it "correctly pluralizes 'Secretary' when capitalized, despite the proper-noun exception" do
|
4638
|
+
'Secretary'.en.plural.should == 'Secretaries'
|
4639
|
+
end
|
4640
|
+
|
4641
|
+
end
|
4642
|
+
|
4635
4643
|
end
|
4636
4644
|
|
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.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -36,8 +36,24 @@ cert_chain:
|
|
36
36
|
YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
|
37
37
|
Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
|
38
38
|
cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
39
|
-
date:
|
39
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: loggability
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.5'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0.5'
|
41
57
|
- !ruby/object:Gem::Dependency
|
42
58
|
name: hoe-mercurial
|
43
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,7 +173,7 @@ dependencies:
|
|
157
173
|
requirements:
|
158
174
|
- - ~>
|
159
175
|
- !ruby/object:Gem::Version
|
160
|
-
version: '3.
|
176
|
+
version: '3.4'
|
161
177
|
type: :development
|
162
178
|
prerelease: false
|
163
179
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -165,12 +181,14 @@ dependencies:
|
|
165
181
|
requirements:
|
166
182
|
- - ~>
|
167
183
|
- !ruby/object:Gem::Version
|
168
|
-
version: '3.
|
169
|
-
description: !
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
184
|
+
version: '3.4'
|
185
|
+
description: ! 'Linguistics is a framework for building linguistic utilities for Ruby
|
186
|
+
|
187
|
+
objects in any language. It includes a generic language-independant
|
188
|
+
|
189
|
+
front end, a module for mapping language codes into language names, and
|
190
|
+
|
191
|
+
a module which contains various English-language utilities.'
|
174
192
|
email:
|
175
193
|
- ged@FaerieMUD.org
|
176
194
|
executables: []
|
@@ -255,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
273
|
version: '0'
|
256
274
|
requirements: []
|
257
275
|
rubyforge_project: linguistics
|
258
|
-
rubygems_version: 1.8.
|
276
|
+
rubygems_version: 1.8.25
|
259
277
|
signing_key:
|
260
278
|
specification_version: 3
|
261
279
|
summary: Linguistics is a framework for building linguistic utilities for Ruby objects
|
metadata.gz.sig
CHANGED
Binary file
|