morpher_inflect 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/CHANGELOG +4 -0
- data/Gemfile +4 -0
- data/LICENSE +2 -2
- data/Rakefile +7 -50
- data/lib/morpher_inflect.rb +3 -4
- data/lib/morpher_inflect/version.rb +1 -7
- data/morpher_inflect.gemspec +27 -0
- data/spec/morpher_inflect_integration_spec.rb +16 -0
- data/spec/morpher_inflect_spec.rb +2 -0
- data/spec/spec_helper.rb +1 -7
- metadata +50 -15
data/.gitignore
ADDED
data/CHANGELOG
ADDED
data/Gemfile
ADDED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2008 Yaroslav Markin
|
1
|
+
Copyright (c) 2008 Alexey Trofimenko, Yaroslav Markin
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,55 +1,12 @@
|
|
1
|
-
require '
|
2
|
-
require 'rake/gempackagetask'
|
3
|
-
require 'spec/rake/spectask'
|
4
|
-
require 'rubygems/specification'
|
5
|
-
require 'date'
|
1
|
+
require 'bundler/gem_tasks'
|
6
2
|
|
7
|
-
|
8
|
-
GEM_VERSION = "0.0.1"
|
9
|
-
AUTHOR = "Alexey Trofimenko"
|
10
|
-
EMAIL = "codesnik@gmail.com"
|
11
|
-
HOMEPAGE = "http://github.com/codesnik/morpher_inflect/"
|
12
|
-
SUMMARY = "Morpher.ru webservice client (Russian language inflection)"
|
13
|
-
|
14
|
-
spec = Gem::Specification.new do |s|
|
15
|
-
s.name = GEM
|
16
|
-
s.version = GEM_VERSION
|
17
|
-
s.platform = Gem::Platform::RUBY
|
18
|
-
s.has_rdoc = true
|
19
|
-
s.extra_rdoc_files = ["README.rdoc", "LICENSE", 'TODO']
|
20
|
-
s.summary = SUMMARY
|
21
|
-
s.description = s.summary
|
22
|
-
s.author = AUTHOR
|
23
|
-
s.email = EMAIL
|
24
|
-
s.homepage = HOMEPAGE
|
25
|
-
|
26
|
-
# Uncomment this to add a dependency
|
27
|
-
s.add_dependency "httparty"
|
28
|
-
|
29
|
-
s.require_path = 'lib'
|
30
|
-
s.autorequire = GEM
|
31
|
-
s.files = %w(LICENSE README.rdoc Rakefile TODO init.rb) + Dir.glob("{lib,spec}/**/*")
|
32
|
-
end
|
33
|
-
|
34
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
35
|
-
pkg.gem_spec = spec
|
36
|
-
end
|
3
|
+
require 'rspec/core/rake_task'
|
37
4
|
|
5
|
+
desc 'Default: run specs.'
|
38
6
|
task :default => :spec
|
39
|
-
desc "Run specs"
|
40
|
-
Spec::Rake::SpecTask.new do |t|
|
41
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
42
|
-
t.spec_opts = %w(-fs --color)
|
43
|
-
end
|
44
|
-
|
45
|
-
desc "install the gem locally"
|
46
|
-
task :install => [:package] do
|
47
|
-
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
48
|
-
end
|
49
7
|
|
50
|
-
desc "
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
8
|
+
desc "Run specs"
|
9
|
+
RSpec::Core::RakeTask.new do |t|
|
10
|
+
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
11
|
+
# Put spec opts in a file named .rspec in root
|
55
12
|
end
|
data/lib/morpher_inflect.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# encoding: utf-8
|
3
2
|
$:.unshift(File.dirname(__FILE__)) unless
|
4
3
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
5
4
|
|
@@ -40,12 +39,12 @@ module MorpherInflect
|
|
40
39
|
|
41
40
|
get = Inflection.new.get(word) rescue nil # если поднято исключение, переходим к третьему варианту и не кешируем
|
42
41
|
case get
|
43
|
-
when Array
|
42
|
+
when Array
|
44
43
|
# Морфер вернул массив склонений
|
45
44
|
inflections = [word] + get
|
46
45
|
# Кладем в кеш
|
47
46
|
cache_store(word, inflections)
|
48
|
-
when String
|
47
|
+
when String
|
49
48
|
# Морфер вернул не массив склонений (слово не найдено в словаре),
|
50
49
|
# а только строку. Скорее всего это ошибка. Забиваем оригинальным словом
|
51
50
|
inflections.fill(word, 0..INFLECTIONS_COUNT-1)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "morpher_inflect/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "morpher_inflect"
|
7
|
+
s.version = MorpherInflect::VERSION
|
8
|
+
s.authors = ["Alexey Trofimenko", "Yaroslav Markin"]
|
9
|
+
s.email = ["codesnik@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/codesnik/morpher_inflect/"
|
11
|
+
s.summary = "Morpher.ru webservice client (Russian language inflection)"
|
12
|
+
s.description = "Morpher.ru inflections for russian proper and common nouns. Code based on yandex_inflect gem by Yaroslav Markin"
|
13
|
+
|
14
|
+
s.rubyforge_project = "morpher_inflect"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.has_rdoc = true
|
22
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE", 'TODO', 'CHANGELOG']
|
23
|
+
|
24
|
+
s.add_dependency "httparty"
|
25
|
+
s.add_development_dependency "rspec", '2.6'
|
26
|
+
s.add_development_dependency "rake"
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
3
|
+
|
4
|
+
describe MorpherInflect, "integration test" do
|
5
|
+
# FIXME should we touch real service in test?
|
6
|
+
if "".respond_to?(:encoding)
|
7
|
+
|
8
|
+
it "should get inflections in correct encoding on ruby1.9" do
|
9
|
+
inflections = MorpherInflect.inflections('тест')
|
10
|
+
# real, not cached
|
11
|
+
inflections.last.should == 'тесте'
|
12
|
+
inflections.last.encoding.to_s.should == 'UTF-8'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
3
|
|
3
4
|
describe MorpherInflect do
|
@@ -75,4 +76,5 @@ describe MorpherInflect::Inflection do
|
|
75
76
|
MorpherInflect::Inflection.should_receive(:get).and_return(@sample_answer)
|
76
77
|
MorpherInflect::Inflection.new.get("рубин").should == @sample_inflection
|
77
78
|
end
|
79
|
+
|
78
80
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morpher_inflect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Alexey Trofimenko
|
8
|
-
|
9
|
+
- Yaroslav Markin
|
10
|
+
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
13
|
|
12
|
-
date:
|
14
|
+
date: 2011-06-22 00:00:00 +04:00
|
13
15
|
default_executable:
|
14
16
|
dependencies:
|
15
17
|
- !ruby/object:Gem::Dependency
|
16
18
|
name: httparty
|
19
|
+
prerelease: false
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: "0"
|
17
26
|
type: :runtime
|
18
|
-
|
19
|
-
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec
|
30
|
+
prerelease: false
|
31
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - "="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: "2.6"
|
37
|
+
type: :development
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: rake
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
20
44
|
requirements:
|
21
45
|
- - ">="
|
22
46
|
- !ruby/object:Gem::Version
|
23
47
|
version: "0"
|
24
|
-
|
25
|
-
|
26
|
-
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id003
|
50
|
+
description: Morpher.ru inflections for russian proper and common nouns. Code based on yandex_inflect gem by Yaroslav Markin
|
51
|
+
email:
|
52
|
+
- codesnik@gmail.com
|
27
53
|
executables: []
|
28
54
|
|
29
55
|
extensions: []
|
@@ -32,14 +58,20 @@ extra_rdoc_files:
|
|
32
58
|
- README.rdoc
|
33
59
|
- LICENSE
|
34
60
|
- TODO
|
61
|
+
- CHANGELOG
|
35
62
|
files:
|
63
|
+
- .gitignore
|
64
|
+
- CHANGELOG
|
65
|
+
- Gemfile
|
36
66
|
- LICENSE
|
37
67
|
- README.rdoc
|
38
68
|
- Rakefile
|
39
69
|
- TODO
|
40
70
|
- init.rb
|
41
|
-
- lib/morpher_inflect/version.rb
|
42
71
|
- lib/morpher_inflect.rb
|
72
|
+
- lib/morpher_inflect/version.rb
|
73
|
+
- morpher_inflect.gemspec
|
74
|
+
- spec/morpher_inflect_integration_spec.rb
|
43
75
|
- spec/morpher_inflect_spec.rb
|
44
76
|
- spec/spec.opts
|
45
77
|
- spec/spec_helper.rb
|
@@ -53,23 +85,26 @@ rdoc_options: []
|
|
53
85
|
require_paths:
|
54
86
|
- lib
|
55
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
56
89
|
requirements:
|
57
90
|
- - ">="
|
58
91
|
- !ruby/object:Gem::Version
|
59
92
|
version: "0"
|
60
|
-
version:
|
61
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
62
95
|
requirements:
|
63
96
|
- - ">="
|
64
97
|
- !ruby/object:Gem::Version
|
65
98
|
version: "0"
|
66
|
-
version:
|
67
99
|
requirements: []
|
68
100
|
|
69
|
-
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
101
|
+
rubyforge_project: morpher_inflect
|
102
|
+
rubygems_version: 1.6.1
|
71
103
|
signing_key:
|
72
104
|
specification_version: 3
|
73
105
|
summary: Morpher.ru webservice client (Russian language inflection)
|
74
|
-
test_files:
|
75
|
-
|
106
|
+
test_files:
|
107
|
+
- spec/morpher_inflect_integration_spec.rb
|
108
|
+
- spec/morpher_inflect_spec.rb
|
109
|
+
- spec/spec.opts
|
110
|
+
- spec/spec_helper.rb
|