check_yo_spelling 0.1.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/.rspec +4 -0
- data/CHANGELOG.rdoc +2 -0
- data/Gemfile.lock +35 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/check_yo_spelling.gemspec +24 -0
- data/data/.keep +0 -0
- data/data/alabama_cities.yml +553 -0
- data/data/alaska_cities.yml +246 -0
- data/data/arizona_cities.yml +397 -0
- data/data/arkansas_cities.yml +499 -0
- data/data/california_cities.yml +1417 -0
- data/data/colorado_cities.yml +404 -0
- data/data/connecticut_cities.yml +142 -0
- data/data/delaware_cities.yml +76 -0
- data/data/florida_cities.yml +900 -0
- data/data/georgia_cities.yml +609 -0
- data/data/hawaii_cities.yml +146 -0
- data/data/idaho_cities.yml +206 -0
- data/data/illinois_cities.yml +1315 -0
- data/data/indiana_cities.yml +654 -0
- data/data/iowa_cities.yml +869 -0
- data/data/kansas_cities.yml +554 -0
- data/data/kentucky_cities.yml +510 -0
- data/data/louisiana_cities.yml +469 -0
- data/data/maine_cities.yml +132 -0
- data/data/maryland_cities.yml +483 -0
- data/data/massachusetts_cities.yml +243 -0
- data/data/michigan_cities.yml +683 -0
- data/data/minnesota_cities.yml +805 -0
- data/data/mississippi_cities.yml +357 -0
- data/data/missouri_cities.yml +887 -0
- data/data/montana_cities.yml +307 -0
- data/data/nebraska_cities.yml +452 -0
- data/data/nevada_cities.yml +117 -0
- data/data/new_hampshire_cities.yml +97 -0
- data/data/new_jersey_cities.yml +536 -0
- data/data/new_mexico_cities.yml +381 -0
- data/data/new_york_cities.yml +1173 -0
- data/data/north_carolina_cities.yml +721 -0
- data/data/north_dakota_cities.yml +238 -0
- data/data/ohio_cities.yml +1177 -0
- data/data/oklahoma_cities.yml +639 -0
- data/data/oregon_cities.yml +353 -0
- data/data/pennsylvania_cities.yml +1718 -0
- data/data/rhode_island_cities.yml +35 -0
- data/data/south_carolina_cities.yml +378 -0
- data/data/south_dakota_cities.yml +288 -0
- data/data/states.yml +51 -0
- data/data/tennessee_cities.yml +424 -0
- data/data/texas_cities.yml +1619 -0
- data/data/utah_cities.yml +314 -0
- data/data/vermont_cities.yml +118 -0
- data/data/virginia_cities.yml +579 -0
- data/data/washington_cities.yml +599 -0
- data/data/west_virginia_cities.yml +387 -0
- data/data/wisconsin_cities.yml +748 -0
- data/data/wyoming_cities.yml +156 -0
- data/gemfile +6 -0
- data/lib/check_yo_spelling.rb +4 -0
- data/lib/check_yo_spelling/usa.rb +52 -0
- data/lib/check_yo_spelling/version.rb +3 -0
- data/pkg/spell_checker-0.1.0.gem +0 -0
- data/spec/lib/usa_city_checker_spec.rb +16 -0
- data/spec/lib/usa_state_checker_spec.rb +16 -0
- data/spec/spec_helper.rb +3 -0
- metadata +159 -0
@@ -0,0 +1,156 @@
|
|
1
|
+
---
|
2
|
+
- afton
|
3
|
+
- albin
|
4
|
+
- alpine
|
5
|
+
- alpine northeast
|
6
|
+
- alpine northwest
|
7
|
+
- alta
|
8
|
+
- antelope valley crestview
|
9
|
+
- arapahoe
|
10
|
+
- auburn
|
11
|
+
- baggs
|
12
|
+
- bairoil
|
13
|
+
- bar nunn
|
14
|
+
- basin
|
15
|
+
- bear river
|
16
|
+
- bedford
|
17
|
+
- bessemer bend
|
18
|
+
- big horn
|
19
|
+
- big piney
|
20
|
+
- boulder
|
21
|
+
- boulder flats
|
22
|
+
- brookhurst
|
23
|
+
- buffalo
|
24
|
+
- burlington
|
25
|
+
- burns
|
26
|
+
- byron
|
27
|
+
- casper
|
28
|
+
- casper mountain
|
29
|
+
- centennial
|
30
|
+
- cheyenne
|
31
|
+
- chugcreek
|
32
|
+
- chugwater
|
33
|
+
- clearmont
|
34
|
+
- clearview acres
|
35
|
+
- cody
|
36
|
+
- cokeville
|
37
|
+
- cora
|
38
|
+
- cowley
|
39
|
+
- crowheart
|
40
|
+
- daniel
|
41
|
+
- dayton
|
42
|
+
- deaver
|
43
|
+
- diamondville
|
44
|
+
- douglas
|
45
|
+
- dubois
|
46
|
+
- east thermopolis
|
47
|
+
- eden
|
48
|
+
- edgerton
|
49
|
+
- elk mountain
|
50
|
+
- encampment
|
51
|
+
- ethete
|
52
|
+
- etna
|
53
|
+
- evanston
|
54
|
+
- evansville
|
55
|
+
- fairview
|
56
|
+
- farson
|
57
|
+
- fort bridger
|
58
|
+
- fort laramie
|
59
|
+
- fort washakie
|
60
|
+
- fox farm college
|
61
|
+
- frannie
|
62
|
+
- freedom
|
63
|
+
- garland
|
64
|
+
- gillette
|
65
|
+
- glendo
|
66
|
+
- glenrock
|
67
|
+
- granger
|
68
|
+
- green river
|
69
|
+
- greybull
|
70
|
+
- grover
|
71
|
+
- guernsey
|
72
|
+
- hanna
|
73
|
+
- hartrandt
|
74
|
+
- hill view heights
|
75
|
+
- hoback
|
76
|
+
- homa hills
|
77
|
+
- hudson
|
78
|
+
- hulett
|
79
|
+
- jackson
|
80
|
+
- james town
|
81
|
+
- johnstown
|
82
|
+
- kaycee
|
83
|
+
- kelly
|
84
|
+
- kemmerer
|
85
|
+
- la barge
|
86
|
+
- la grange
|
87
|
+
- lander
|
88
|
+
- laramie
|
89
|
+
- lingle
|
90
|
+
- lovell
|
91
|
+
- lucerne
|
92
|
+
- lusk
|
93
|
+
- lyman
|
94
|
+
- mammoth
|
95
|
+
- manderson
|
96
|
+
- marbleton
|
97
|
+
- meadow acres
|
98
|
+
- medicine bow
|
99
|
+
- meeteetse
|
100
|
+
- midwest
|
101
|
+
- mills
|
102
|
+
- moorcroft
|
103
|
+
- moose wilson road
|
104
|
+
- mountain view
|
105
|
+
- newcastle
|
106
|
+
- nordic
|
107
|
+
- north rock springs
|
108
|
+
- osage
|
109
|
+
- osmond
|
110
|
+
- parkman
|
111
|
+
- pavillion
|
112
|
+
- pine bluffs
|
113
|
+
- pine haven
|
114
|
+
- pinedale
|
115
|
+
- powell
|
116
|
+
- purple sage
|
117
|
+
- rafter j ranch
|
118
|
+
- ralston
|
119
|
+
- ranchester
|
120
|
+
- ranchettes
|
121
|
+
- rawlins
|
122
|
+
- red butte
|
123
|
+
- reliance
|
124
|
+
- riverton
|
125
|
+
- rock river
|
126
|
+
- rock springs
|
127
|
+
- rolling hills
|
128
|
+
- saratoga
|
129
|
+
- sheridan
|
130
|
+
- shoshoni
|
131
|
+
- sinclair
|
132
|
+
- sleepy hollow
|
133
|
+
- smoot
|
134
|
+
- south greeley
|
135
|
+
- south park
|
136
|
+
- star valley ranch
|
137
|
+
- story
|
138
|
+
- sundance
|
139
|
+
- superior
|
140
|
+
- ten sleep
|
141
|
+
- teton village
|
142
|
+
- thayne
|
143
|
+
- thermopolis
|
144
|
+
- torrington
|
145
|
+
- turnerville
|
146
|
+
- upton
|
147
|
+
- urie
|
148
|
+
- vista west
|
149
|
+
- wamsutter
|
150
|
+
- warren afb
|
151
|
+
- wheatland
|
152
|
+
- wilson
|
153
|
+
- worland
|
154
|
+
- wright
|
155
|
+
- y o ranch
|
156
|
+
- yoder
|
data/gemfile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
module CheckYoSpelling
|
2
|
+
class USA
|
3
|
+
# Use the Levenshtein gem to find the closest match
|
4
|
+
# NOTE: the gem treats replacement edits as a distance of 2
|
5
|
+
MIN_DISTANCE = 4
|
6
|
+
class << self
|
7
|
+
# Find the closest existing city in the state
|
8
|
+
def check_city city, state
|
9
|
+
full_state = Geolookup::USA::State.abbreviation_to_name state
|
10
|
+
return nil if full_state.nil?
|
11
|
+
@@city_arrays ||= Hash.new
|
12
|
+
filename = "#{full_state.downcase.gsub(" ", "_")}_cities.yml"
|
13
|
+
@@city_arrays[filename] ||= words(filename)
|
14
|
+
check city, @@city_arrays[filename]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Find the closest existing state
|
18
|
+
def check_state state
|
19
|
+
@@states ||= words("states.yml")
|
20
|
+
check state, @@states
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def check word, nwords
|
25
|
+
word.downcase!
|
26
|
+
best_match = nil # return nil if no match
|
27
|
+
current_distance = MIN_DISTANCE # only accept possible matches that are close enough
|
28
|
+
nwords.each do |proposed|
|
29
|
+
distance = Levenshtein.distance word, proposed.downcase
|
30
|
+
if distance < current_distance
|
31
|
+
best_match = proposed
|
32
|
+
current_distance = distance
|
33
|
+
end
|
34
|
+
break if distance == 0 # Found perfect match
|
35
|
+
end
|
36
|
+
best_match = titleize(best_match) if best_match
|
37
|
+
best_match
|
38
|
+
end
|
39
|
+
|
40
|
+
def words filename
|
41
|
+
YAML.load_file(File.join(File.dirname(__FILE__), "/../../data/", filename))
|
42
|
+
end
|
43
|
+
|
44
|
+
# Basic titleize functionality ex: rhode island => Rhode Island
|
45
|
+
def titleize string
|
46
|
+
string.gsub(/\w+/) do |word|
|
47
|
+
word.capitalize
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
describe "CheckYoSpelling::USA" do
|
2
|
+
it "should check city names" do
|
3
|
+
city = CheckYoSpelling::USA.check_city "Los Angelos", "CA"
|
4
|
+
expect(city).to eq("Los Angeles")
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should return the same city name for a correct city" do
|
8
|
+
city = CheckYoSpelling::USA.check_city "Los Angeles", "CA"
|
9
|
+
expect(city).to eq("Los Angeles")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return nil for city names that are too incorrect" do
|
13
|
+
city = CheckYoSpelling::USA.check_city "Los Angelesaaaaa", "CA"
|
14
|
+
expect(city).to eq(nil)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
describe "CheckYoSpelling::USA" do
|
2
|
+
it "should check state names" do
|
3
|
+
state = CheckYoSpelling::USA.check_state "Californa"
|
4
|
+
expect(state).to eq("California")
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should return the same state name for a correct state" do
|
8
|
+
state = CheckYoSpelling::USA.check_state "California"
|
9
|
+
expect(state).to eq("California")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return nil for state names that are too incorrect" do
|
13
|
+
state = CheckYoSpelling::USA.check_state "Californiaaaaaa"
|
14
|
+
expect(state).to eq(nil)
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: check_yo_spelling
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Austin Fonacier
|
8
|
+
- Eric Kuecks
|
9
|
+
- Emily Lutz
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.5'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.5'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rspec
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 3.0.0.beta1
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 3.0.0.beta1
|
57
|
+
description: Spell checker for U.S. cities and states
|
58
|
+
email:
|
59
|
+
- austin@spokeo.com
|
60
|
+
- ekuecks@ucla.edu
|
61
|
+
- emily.lutz@berkeley.edu
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- ".rspec"
|
67
|
+
- CHANGELOG.rdoc
|
68
|
+
- Gemfile.lock
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- check_yo_spelling.gemspec
|
72
|
+
- data/.keep
|
73
|
+
- data/alabama_cities.yml
|
74
|
+
- data/alaska_cities.yml
|
75
|
+
- data/arizona_cities.yml
|
76
|
+
- data/arkansas_cities.yml
|
77
|
+
- data/california_cities.yml
|
78
|
+
- data/colorado_cities.yml
|
79
|
+
- data/connecticut_cities.yml
|
80
|
+
- data/delaware_cities.yml
|
81
|
+
- data/florida_cities.yml
|
82
|
+
- data/georgia_cities.yml
|
83
|
+
- data/hawaii_cities.yml
|
84
|
+
- data/idaho_cities.yml
|
85
|
+
- data/illinois_cities.yml
|
86
|
+
- data/indiana_cities.yml
|
87
|
+
- data/iowa_cities.yml
|
88
|
+
- data/kansas_cities.yml
|
89
|
+
- data/kentucky_cities.yml
|
90
|
+
- data/louisiana_cities.yml
|
91
|
+
- data/maine_cities.yml
|
92
|
+
- data/maryland_cities.yml
|
93
|
+
- data/massachusetts_cities.yml
|
94
|
+
- data/michigan_cities.yml
|
95
|
+
- data/minnesota_cities.yml
|
96
|
+
- data/mississippi_cities.yml
|
97
|
+
- data/missouri_cities.yml
|
98
|
+
- data/montana_cities.yml
|
99
|
+
- data/nebraska_cities.yml
|
100
|
+
- data/nevada_cities.yml
|
101
|
+
- data/new_hampshire_cities.yml
|
102
|
+
- data/new_jersey_cities.yml
|
103
|
+
- data/new_mexico_cities.yml
|
104
|
+
- data/new_york_cities.yml
|
105
|
+
- data/north_carolina_cities.yml
|
106
|
+
- data/north_dakota_cities.yml
|
107
|
+
- data/ohio_cities.yml
|
108
|
+
- data/oklahoma_cities.yml
|
109
|
+
- data/oregon_cities.yml
|
110
|
+
- data/pennsylvania_cities.yml
|
111
|
+
- data/rhode_island_cities.yml
|
112
|
+
- data/south_carolina_cities.yml
|
113
|
+
- data/south_dakota_cities.yml
|
114
|
+
- data/states.yml
|
115
|
+
- data/tennessee_cities.yml
|
116
|
+
- data/texas_cities.yml
|
117
|
+
- data/utah_cities.yml
|
118
|
+
- data/vermont_cities.yml
|
119
|
+
- data/virginia_cities.yml
|
120
|
+
- data/washington_cities.yml
|
121
|
+
- data/west_virginia_cities.yml
|
122
|
+
- data/wisconsin_cities.yml
|
123
|
+
- data/wyoming_cities.yml
|
124
|
+
- gemfile
|
125
|
+
- lib/check_yo_spelling.rb
|
126
|
+
- lib/check_yo_spelling/usa.rb
|
127
|
+
- lib/check_yo_spelling/version.rb
|
128
|
+
- pkg/spell_checker-0.1.0.gem
|
129
|
+
- spec/lib/usa_city_checker_spec.rb
|
130
|
+
- spec/lib/usa_state_checker_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
homepage: https://github.com/spokeo/CheckYoSpelling
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.4.3
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Spell checker for U.S. cities and states
|
156
|
+
test_files:
|
157
|
+
- spec/lib/usa_city_checker_spec.rb
|
158
|
+
- spec/lib/usa_state_checker_spec.rb
|
159
|
+
- spec/spec_helper.rb
|