russian_metaphone 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RussianMetaphone
2
2
 
3
- This gem provides an implementation of 'Metaphone' phonetic algorithm adapted for Russian language. Check [this Wikipedia article](http://rubydoc.info/gems/carrierwave/frames) for Metaphone intro.
3
+ This gem provides an implementation of 'Metaphone' phonetic algorithm adapted for Russian language. Check [this Wikipedia article](http://en.wikipedia.org/wiki/Metaphone) for Metaphone intro.
4
4
 
5
5
  ## Installation
6
6
 
@@ -64,11 +64,16 @@ RussianMetaphone имеет готовый набор фильтров для р
64
64
 
65
65
  Заменяет символы следующим образом:
66
66
 
67
- * ТС, ДС - заменяются на Ц
68
- * ЙО, ИО, ЙЕ, ИЕ - заменяются на И
69
- * О, Ы, А, Я - заменяются на А
70
- * Ю, У - заменяются на У
71
- * Е, Ё, Э - заменяются на И
67
+ Символы | Заменяются на
68
+ :-------------|:------------:
69
+ ТС, ДС
70
+ І, Ї| И
71
+ Є|Е
72
+ ЙО, ИО, ЙЕ, ИЕ|И
73
+ О, Ы, А, Я|A
74
+ Ю, У|У
75
+ Е, Ё, Э, И|И
76
+
72
77
 
73
78
  #### RussianMetaphone::Filter::BreathConsonants
74
79
 
@@ -82,3 +87,26 @@ RussianMetaphone имеет готовый набор фильтров для р
82
87
  3. Commit your changes (`git commit -am 'Add some feature'`)
83
88
  4. Push to the branch (`git push origin my-new-feature`)
84
89
  5. Create new Pull Request
90
+
91
+ ## License
92
+
93
+ The MIT License (MIT)
94
+
95
+ Copyright (c) 2013 CleverUA
96
+
97
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
98
+ this software and associated documentation files (the "Software"), to deal in
99
+ the Software without restriction, including without limitation the rights to
100
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
101
+ the Software, and to permit persons to whom the Software is furnished to do so,
102
+ subject to the following conditions:
103
+
104
+ The above copyright notice and this permission notice shall be included in all
105
+ copies or substantial portions of the Software.
106
+
107
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
108
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
109
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
110
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
111
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
112
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -4,8 +4,9 @@ require "russian_metaphone/version"
4
4
  require "russian_metaphone/filter"
5
5
 
6
6
  module RussianMetaphone
7
- def process(source)
8
- filters = [
7
+
8
+ # fits well if you search for similar sounded last names / names
9
+ DEFAULT_FILTERS = [
9
10
  RussianMetaphone::Filter::Normalization,
10
11
  RussianMetaphone::Filter::DuplicatesRemoval,
11
12
  RussianMetaphone::Filter::LastnameEnding,
@@ -13,6 +14,9 @@ module RussianMetaphone
13
14
  RussianMetaphone::Filter::BreathConsonants,
14
15
  RussianMetaphone::Filter::DuplicatesRemoval
15
16
  ]
17
+
18
+
19
+ def process(source, filters = DEFAULT_FILTERS)
16
20
  result = String.new(source)
17
21
  filters.each { |f| result = f.send(:filter, result) }
18
22
  result
@@ -1,24 +1,24 @@
1
1
  # encoding: UTF-8
2
2
 
3
- # Исходные символы | Конечный символ
4
- # |
3
+ # ТС, ДС | Ц
4
+ # І, Ї | И
5
+ # Є | Е
6
+ # ЙО, ИО, ЙЕ, ИЕ | И
5
7
  # О, Ы, А, Я | А
6
8
  # Ю, У | У
7
9
  # Е, Ё, Э, И | И
8
- #
9
- # ЙО, ИО, ЙЕ, ИЕ заменяются на И
10
- # ТС, ДС заменяются на Ц
11
- #
12
10
  module RussianMetaphone
13
11
  module Filter
14
12
  module Replacement
15
13
 
16
14
  REPLACEMENTS = {
17
- /тс|дс/ => 'ц' ,
15
+ /тс|дс/ => 'ц' ,
16
+ /[їі]/ => 'и' ,
17
+ /[є]/ => 'е' ,
18
18
  /йо|ио|йе|ие/ => 'и',
19
- /[оыя]/ => 'а',
20
- /[ю]/ => 'y',
21
- /[еёэ]/ => 'и'
19
+ /[оыя]/ => 'а',
20
+ /[ю]/ => 'y',
21
+ /[еёэ]/ => 'и'
22
22
  }
23
23
 
24
24
  def filter(string, options = {})
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module RussianMetaphone
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.description = %q{Implements 'Metaphone' phonetic algorithm adapted for Russian language}
12
12
  gem.summary = %q{Implements 'Metaphone' phonetic algorithm adapted for Russian language, allows easy extending and algorithm tuning.}
13
13
  gem.homepage = "https://github.com/cleverua/russian_metaphone"
14
+ gem.license = "MIT"
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -29,5 +29,11 @@ describe "Replacements Filter" do
29
29
  RussianMetaphone::Filter::Replacement.filter('безрассудство').should == 'бизрассуцтва'
30
30
  RussianMetaphone::Filter::Replacement.filter('детсад').should == 'дицад'
31
31
  end
32
+
33
+ it "should replace Ukrainian characters" do
34
+ RussianMetaphone::Filter::Replacement.filter('місто').should == 'миста'
35
+ RussianMetaphone::Filter::Replacement.filter('переїзд').should == 'пириизд'
36
+ RussianMetaphone::Filter::Replacement.filter('підприємство').should == 'пидпримства'
37
+ end
32
38
  end
33
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: russian_metaphone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-27 00:00:00.000000000 Z
12
+ date: 2013-07-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: unicode
@@ -71,7 +71,8 @@ files:
71
71
  - spec/replacement_filter_spec.rb
72
72
  - spec/spec_helper.rb
73
73
  homepage: https://github.com/cleverua/russian_metaphone
74
- licenses: []
74
+ licenses:
75
+ - MIT
75
76
  post_install_message:
76
77
  rdoc_options: []
77
78
  require_paths: