russian_inflect 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/README.md +6 -6
- data/Rakefile +6 -0
- data/lib/russian_inflect.rb +6 -4
- data/lib/russian_inflect/rules.yml +14 -5
- data/lib/russian_inflect/version.rb +1 -1
- data/russian_inflect.gemspec +1 -0
- data/spec/lib/russian_inflect_spec.rb +25 -0
- data/spec/spec_helper.rb +16 -0
- metadata +29 -10
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MDY0MGIxZDA1ODQyOWU0NTI5OTNkODZlMjg1YWE0OThjYWEzMzU1YzFlM2Vl
|
10
|
-
YWZhNzlhZGM3Nzk5OWY3YTRkZGUwNTM3YmRhMzAyZTI5MmFhZjVlNjMxZmZh
|
11
|
-
NDNhZDRlYmU1NTUyMDhjZDQ1MTU3YWUzZGZiMjYyN2U3NTM3YTY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjZjNDUxZjVjZDBjMTM1ZGQ0MWQ3NDk2OWMwYjBmNThjODIzZDFiNmFjNzY3
|
14
|
-
MDk0NjM2YTM5MDdhMDdkMzg1MTQ5MjMwYzAyOGZmNTk5ODkzMTI0YTc1OWFj
|
15
|
-
MjdjYWMyZGM1M2Y5MzE1NTVjZDE3ODkyNGU3ZDNiNWQ2ZDhjODk=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6807e2a1c53c8a39a691d8c231ee73be6a9836b0
|
4
|
+
data.tar.gz: f49d970773a35aa1264946de3f974a81a0f11f3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7db2cdde34346f7180898be93172badbdbc04f5825248002a6df436505eea6f3a6473496a16db08761c200df5b04ee3c9110c6c0fe480916bd8e92a8e1089e44
|
7
|
+
data.tar.gz: 327656d319157ee568a6b73cb1b450ad18feddbba61eddec2c0ee50d6b85e4066dd29ca9782f69d638afed09724c5fc41e28a5783ef9cf1bdafb8ea7d25c3e16
|
data/README.md
CHANGED
@@ -18,12 +18,12 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
RussianInflect.inflect("Хорошая погода", :nominative) # Хорошая погода
|
22
|
+
RussianInflect.inflect("Хорошая погода", :genitive) # Хорошей погоды
|
23
|
+
RussianInflect.inflect("Хорошая погода", :dative) # Хорошей погоде
|
24
|
+
RussianInflect.inflect("Хорошая погода", :accusative) # Хорошую погоду
|
25
|
+
RussianInflect.inflect("Хорошая погода", :instrumental) # Хорошей погодой
|
26
|
+
RussianInflect.inflect("Хорошая погода", :prepositional) # Хорошей погоде
|
27
27
|
|
28
28
|
## Contributing
|
29
29
|
|
data/Rakefile
CHANGED
data/lib/russian_inflect.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'unicode_utils'
|
5
5
|
require 'active_support'
|
6
|
+
require 'active_support/core_ext'
|
6
7
|
require 'russian_inflect/rules'
|
7
8
|
require "russian_inflect/version"
|
8
9
|
|
@@ -17,10 +18,11 @@ class RussianInflect
|
|
17
18
|
INSTRUMENTAL = :instrumental # творительный
|
18
19
|
PREPOSITIONAL = :prepositional # предложный
|
19
20
|
|
20
|
-
attr_accessor :words, :noun, :case_group
|
21
|
+
attr_accessor :source, :words, :noun, :case_group
|
21
22
|
|
22
|
-
def initialize(
|
23
|
-
@
|
23
|
+
def initialize(source, options = {})
|
24
|
+
@source = source
|
25
|
+
@words = source.split
|
24
26
|
@noun = case options[:noun]
|
25
27
|
when String then options[:noun]
|
26
28
|
when Fixnum then @words[options[:noun]]
|
@@ -61,7 +63,7 @@ class RussianInflect
|
|
61
63
|
|
62
64
|
def self.detect_type(word)
|
63
65
|
case word
|
64
|
-
when /(
|
66
|
+
when /(ая|яя|ые|ие|ый|ой|ий|ое|ее)$/i then :adjective
|
65
67
|
else :noun
|
66
68
|
end
|
67
69
|
end
|
@@ -3,6 +3,9 @@ prepositions: [в, без, до, из, к, на, по, о, от, перед, п
|
|
3
3
|
first_group:
|
4
4
|
adjective:
|
5
5
|
suffixes:
|
6
|
+
-
|
7
|
+
test: [шая]
|
8
|
+
mods: [--ей, --ей, --ую, --ей, --ей]
|
6
9
|
-
|
7
10
|
test: [ая]
|
8
11
|
mods: [--ой, --ой, --ую, --ой, --ой]
|
@@ -15,7 +18,7 @@ first_group:
|
|
15
18
|
noun:
|
16
19
|
suffixes:
|
17
20
|
-
|
18
|
-
test: [га, ка, ха,
|
21
|
+
test: [га, ка, ха, ча, ша, ща]
|
19
22
|
mods: [-и, -е, -у, -ой, -е]
|
20
23
|
-
|
21
24
|
test: [ба, ва, да, жа, за, ла, ма, на, па, ра, са, та, фа, ца]
|
@@ -31,16 +34,22 @@ second_group:
|
|
31
34
|
adjective:
|
32
35
|
suffixes:
|
33
36
|
-
|
34
|
-
test: [
|
35
|
-
mods: [
|
37
|
+
test: [шое, шый, шой]
|
38
|
+
mods: [--ого, --ому, ., --им, --ом]
|
39
|
+
-
|
40
|
+
test: [ое, ый, ой]
|
41
|
+
mods: [--ого, --ому, ., --ым, --ом]
|
36
42
|
-
|
37
43
|
test: [ее, ий]
|
38
|
-
mods: [
|
44
|
+
mods: [--его, --ему, ., --им, --ем]
|
39
45
|
noun:
|
40
46
|
suffixes:
|
41
47
|
-
|
42
|
-
test: [б, в, г, д, ж, з, к, л, м, н, п, р, с, т, ф, х, ц,
|
48
|
+
test: [б, в, г, д, ж, з, к, л, м, н, п, р, с, т, ф, х, ц, ч, щ]
|
43
49
|
mods: [а, у, ., ом, е]
|
50
|
+
-
|
51
|
+
test: [ш]
|
52
|
+
mods: [а, у, ., ем, е]
|
44
53
|
-
|
45
54
|
test: [о]
|
46
55
|
mods: [-а, -у, ., м, -е]
|
data/russian_inflect.gemspec
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RussianInflect do
|
6
|
+
it "должен правильно склонять словосочение «Хорошая погода»" do
|
7
|
+
source = RussianInflect.new("Хорошая погода")
|
8
|
+
source.test_each_case "Хорошая погода", "Хорошей погоды", "Хорошей погоде", "Хорошую погоду", "Хорошей погодой", "Хорошей погоде"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "должен правильно склонять словосочение «Большой куш»" do
|
12
|
+
source = RussianInflect.new("Большой куш")
|
13
|
+
source.test_each_case "Большой куш", "Большого куша", "Большому кушу", "Большой куш", "Большим кушем", "Большом куше"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "должен правильно склонять словосочение «Синее море»" do
|
17
|
+
source = RussianInflect.new("Синее море")
|
18
|
+
source.test_each_case "Синее море", "Синего моря", "Синему морю", "Синее море", "Синим морем", "Синем море"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "должен правильно склонять словосочение «Красное вино»" do
|
22
|
+
source = RussianInflect.new("Красное вино")
|
23
|
+
source.test_each_case "Красное вино", "Красного вина", "Красному вину", "Красное вино", "Красным вином", "Красном вине"
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'russian_inflect'
|
2
|
+
|
3
|
+
class RussianInflect
|
4
|
+
def self.each_case(&block)
|
5
|
+
CASES.each_with_index &block
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_each_case(*answers)
|
9
|
+
puts ''
|
10
|
+
RussianInflect.each_case do |c, index|
|
11
|
+
result = self.to_case(c)
|
12
|
+
puts %{RussianInflect.inflect("#{source}", :#{c}) # #{result}}
|
13
|
+
result.should == answers[index]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: russian_inflect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tõnis Simo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -56,14 +56,28 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
description: Склонение по падежам заголовков на русском языке
|
@@ -83,6 +97,8 @@ files:
|
|
83
97
|
- lib/russian_inflect/rules.yml
|
84
98
|
- lib/russian_inflect/version.rb
|
85
99
|
- russian_inflect.gemspec
|
100
|
+
- spec/lib/russian_inflect_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
86
102
|
homepage: https://github.com/estum/russian_inflect
|
87
103
|
licenses:
|
88
104
|
- MIT
|
@@ -93,18 +109,21 @@ require_paths:
|
|
93
109
|
- lib
|
94
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
111
|
requirements:
|
96
|
-
- -
|
112
|
+
- - '>='
|
97
113
|
- !ruby/object:Gem::Version
|
98
114
|
version: '0'
|
99
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
116
|
requirements:
|
101
|
-
- -
|
117
|
+
- - '>='
|
102
118
|
- !ruby/object:Gem::Version
|
103
119
|
version: '0'
|
104
120
|
requirements: []
|
105
121
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.0.
|
122
|
+
rubygems_version: 2.0.5
|
107
123
|
signing_key:
|
108
124
|
specification_version: 4
|
109
125
|
summary: Склоняет заданный заголовок по падежам
|
110
|
-
test_files:
|
126
|
+
test_files:
|
127
|
+
- spec/lib/russian_inflect_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
has_rdoc:
|