yandex_mystem 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7c1c4fcbbbafd601e0457db5366a8d82639955d
4
- data.tar.gz: 3da18f1e83a23747a51786fcda68b5ccd109dfb2
3
+ metadata.gz: 42ebc26d8af331ec4a606c2f7ed69a5a40239f7c
4
+ data.tar.gz: 4bb5b88a71900b0a1e52c15721aa3c9da910c81a
5
5
  SHA512:
6
- metadata.gz: fdca784ffa0621fc345ffa080e00131c43db0ac86f14012082271ed378a1cfa32ff1145acfecb77ef2d336e8f6a8ed4e976375b81ed3fbedbfd94aaf7213ba97
7
- data.tar.gz: 6fa8de5e45b069137e46165d6da1cd7d0209b297e85de996a30340d1171cf8d85eb1194787f0fa40bae12fbb4ccd92ecef0601462cfdc3e2e6664dbf9ff8f234
6
+ metadata.gz: b03f45bf62644835dc08b2900a96fd803d6988bc7a6ea628db32fca727b366c51c962b732996b4a7d6ad7345b4d160dad2668d856e17d206a56fa57409655682
7
+ data.tar.gz: e4e5b7739af721a1c5a4d9d9333f8899d875142b4922d81987557de14762c222727d7d1cd2ad5f73adc828a1165679e15e688dae09eb023212bb286c35cd5733
data/.gitignore CHANGED
@@ -15,4 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- .idea/
18
+ .idea/
19
+ .DS_Store
@@ -1,3 +1,4 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
+ - 2.1.4
data/README.md CHANGED
@@ -17,6 +17,8 @@ Mystem is a software that provided by the Yandex only for non-commercial project
17
17
 
18
18
  gem install yandex_mystem
19
19
 
20
+ Current version is **3.0.1**
21
+
20
22
  ## License
21
23
 
22
24
  First of all, read license on http://api.yandex.ru/mystem/
@@ -31,8 +33,7 @@ This gem contains executables for there platforms:
31
33
  * Linux 3.5 32-bit
32
34
  * Linux 3.1 64-bit
33
35
  * Freebsd 9.0 64-bit
34
-
35
- Note: Mystem 3.0 not support Mac OS X, sorry.
36
+ * Mac OS X
36
37
 
37
38
  ## Usage
38
39
 
Binary file
@@ -3,7 +3,7 @@
3
3
  require 'open3'
4
4
  require 'yandex_mystem/version'
5
5
  require 'pathname'
6
- require 'json'
6
+ require 'oj'
7
7
 
8
8
  module YandexMystem
9
9
  class Base
@@ -36,13 +36,17 @@ module YandexMystem
36
36
  when /64.+linux$/
37
37
  'linux-64'
38
38
  when /darwin/
39
- raise 'Mystem 3.0 does not support Max OS X.'
39
+ 'osx'
40
40
  when /freebsd/
41
41
  'bsd'
42
42
  else
43
43
  raise 'Unknown OS'
44
44
  end
45
45
  end
46
+
47
+ def self.as_json(data)
48
+ Oj.load("[#{data.split("\n").join(',')}]", symbol_keys: true)
49
+ end
46
50
  end
47
51
 
48
52
  class Simple < Base
@@ -50,7 +54,14 @@ module YandexMystem
50
54
 
51
55
 
52
56
  def self.parse(data)
53
- Hash[ JSON.parse('[' + data.split("\n").join(",") + ']', :symbolize_names => true).inject([]){|s, h| s + [[ h[:text], h[:analysis].map{|a| a[:lex]} ]]} ]
57
+ Hash[
58
+ as_json(data).map do |h|
59
+ [
60
+ h[:text],
61
+ h[:analysis].map { |a| a[:lex] }
62
+ ]
63
+ end
64
+ ]
54
65
  end
55
66
  end
56
67
 
@@ -58,7 +69,7 @@ module YandexMystem
58
69
  ARGUMENTS = '-e utf-8 -ig -n --weight --format json --eng-gr'
59
70
 
60
71
  def self.parse(data)
61
- JSON.parse('[' + data.split("\n").join(",") + ']', :symbolize_names => true)
72
+ as_json(data)
62
73
  end
63
74
  end
64
75
  end
@@ -1,3 +1,3 @@
1
1
  module YandexMystem
2
- VERSION = '3.0.0'
2
+ VERSION = '3.0.1'
3
3
  end
@@ -1,7 +1,6 @@
1
1
  require 'yandex_mystem'
2
2
 
3
3
  RSpec.configure do |config|
4
- config.treat_symbols_as_metadata_keys_with_true_values = true
5
4
  config.run_all_when_everything_filtered = true
6
5
  config.filter_run :focus
7
6
  end
@@ -3,36 +3,39 @@ require 'spec_helper'
3
3
 
4
4
  describe YandexMystem do
5
5
  context YandexMystem::Simple do
6
- it "should stem words" do
6
+ it 'should stem words' do
7
7
  data = YandexMystem::Simple.stem("мальчики мальчиков девочки девочек компьютеров компьютере сов пошли elements")
8
- data['мальчики'].should eq %w(мальчик)
9
- data['мальчиков'].should eq %w(мальчик мальчиков мальчиковый)
10
- data['девочки'].should eq %w(девочка)
11
- data['девочек'].should eq %w(девочка)
12
- data['сов'].should eq %w(сова)
13
- data['пошли'].should eq %w(пойти посылать)
14
- data['elements'].should eq []
8
+
9
+ expect(data['мальчики']).to eq %w(мальчик)
10
+ expect(data['мальчиков']).to eq %w(мальчик мальчиков мальчиковый)
11
+ expect(data['девочки']).to eq %w(девочка)
12
+ expect(data['девочек']).to eq %w(девочка)
13
+ expect(data['сов']).to eq %w(сова)
14
+ expect(data['пошли']).to eq %w(пойти посылать)
15
+ expect(data['elements']).to eq []
15
16
  end
16
17
 
17
- it "should stem words in few lines" do
18
- data = YandexMystem::Simple.stem(%[
19
-
20
-
21
- мальчики
22
- мальчиков
23
- девочки девочек компьютеров компьютере сов пошли
24
- elements
25
-
26
-
27
-
28
- ])
29
- data['мальчики'].should eq %w(мальчик)
30
- data['мальчиков'].should eq %w(мальчик мальчиков мальчиковый)
31
- data['девочки'].should eq %w(девочка)
32
- data['девочек'].should eq %w(девочка)
33
- data['сов'].should eq %w(сова)
34
- data['пошли'].should eq %w(пойти посылать)
35
- data['elements'].should eq []
18
+ it 'should stem words in few lines' do
19
+ data = YandexMystem::Simple.stem('
20
+ мальчики
21
+ мальчиков
22
+ девочки
23
+ девочек
24
+ компьютеров
25
+ компьютере
26
+ сов
27
+ пошли
28
+ elements
29
+ ')
30
+
31
+ expect(data['мальчики']).to eq %w(мальчик)
32
+ expect(data['мальчиков']).to eq %w(мальчик мальчиков мальчиковый)
33
+ expect(data['девочки']).to eq %w(девочка)
34
+ expect(data['девочек']).to eq %w(девочка)
35
+ expect(data['компьютере']).to eq %w(компьютер)
36
+ expect(data['сов']).to eq %w(сова)
37
+ expect(data['пошли']).to eq %w(пойти посылать)
38
+ expect(data['elements']).to eq []
36
39
  end
37
40
  end
38
41
 
@@ -40,28 +43,28 @@ describe YandexMystem do
40
43
  it 'latin words' do
41
44
  response = YandexMystem::Raw.stem('Elements')
42
45
 
43
- response.size.should eq 1
44
- response[0][:analysis].should eq []
45
- response[0][:text].should eq 'Elements'
46
+ expect(response.size).to eq 1
47
+ expect(response[0][:analysis]).to eq []
48
+ expect(response[0][:text]).to eq 'Elements'
46
49
  end
47
50
 
48
51
  it 'multiple definitions' do
49
52
  response = YandexMystem::Raw.stem('девочка мальчиков пошла к комьютерам искать, в прочем, как и всегда')
50
53
 
51
- response.size.should eq 11
54
+ expect(response.size).to eq 11
55
+
56
+ analysis = response.find { |h| h[:text] == 'девочка' }[:analysis].first
52
57
 
53
- response.find_all{|h| h[:text] == 'девочка'}.first[:analysis].first[:lex].should eq 'девочка'
54
- response.find_all{|h| h[:text] == 'девочка'}.first[:analysis].first[:wt].should eq 1
55
- response.find_all{|h| h[:text] == 'девочка'}.first[:analysis].first[:gr].should eq 'S,f,anim=nom,sg'
58
+ expect(analysis[:lex]).to eq 'девочка'
59
+ expect(analysis[:wt]).to eq 1
60
+ expect(analysis[:gr]).to eq 'S,f,anim=nom,sg'
56
61
 
57
- response.find_all{|h| h[:text] == 'мальчиков'}.first[:analysis].size.should eq 3
62
+ expect(response.find { |h| h[:text] == 'мальчиков'}[:analysis].size).to eq 3
58
63
  end
59
64
 
60
65
  it 'get geo name' do
61
66
  response = YandexMystem::Raw.stem('Москва')
62
- response.find_all{|h| h[:text] == 'Москва'}.first[:analysis].first[:gr].should include 'geo'
67
+ expect(response.find { |h| h[:text] == 'Москва' }[:analysis].first[:gr]).to include 'geo'
63
68
  end
64
-
65
-
66
69
  end
67
70
  end
@@ -9,13 +9,14 @@ Gem::Specification.new do |gem|
9
9
  gem.summary = %q{Yandex Mystem makes morphological analysis of a russian text}
10
10
  gem.homepage = ''
11
11
 
12
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
13
13
  gem.files = `git ls-files`.split("\n")
14
14
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
  gem.name = 'yandex_mystem'
16
16
  gem.require_paths = %w(lib)
17
17
  gem.version = YandexMystem::VERSION
18
18
 
19
- gem.add_development_dependency 'rspec', '~> 2.8'
19
+ gem.add_dependency 'oj', '~> 2.11'
20
+ gem.add_development_dependency 'rspec', '~> 3.0'
20
21
  gem.add_development_dependency 'rake', '~> 10.1'
21
22
  end
metadata CHANGED
@@ -1,41 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yandex_mystem
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Polushkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-28 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ prerelease: false
15
+ name: oj
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '2.11'
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.11'
27
+ - !ruby/object:Gem::Dependency
28
+ prerelease: false
14
29
  name: rspec
15
30
  requirement: !ruby/object:Gem::Requirement
16
31
  requirements:
17
- - - "~>"
32
+ - - ~>
18
33
  - !ruby/object:Gem::Version
19
- version: '2.8'
34
+ version: '3.0'
20
35
  type: :development
21
- prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - "~>"
38
+ - - ~>
25
39
  - !ruby/object:Gem::Version
26
- version: '2.8'
40
+ version: '3.0'
27
41
  - !ruby/object:Gem::Dependency
42
+ prerelease: false
28
43
  name: rake
29
44
  requirement: !ruby/object:Gem::Requirement
30
45
  requirements:
31
- - - "~>"
46
+ - - ~>
32
47
  - !ruby/object:Gem::Version
33
48
  version: '10.1'
34
49
  type: :development
35
- prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ~>
39
53
  - !ruby/object:Gem::Version
40
54
  version: '10.1'
41
55
  description: Mystem is a software that provided by the Yandex only for non-commercial
@@ -47,19 +61,21 @@ executables:
47
61
  - mystem-bsd
48
62
  - mystem-linux-32
49
63
  - mystem-linux-64
64
+ - mystem-osx
50
65
  - mystem-win.exe
51
66
  extensions: []
52
67
  extra_rdoc_files: []
53
68
  files:
54
- - ".gitignore"
55
- - ".rspec"
56
- - ".travis.yml"
69
+ - .gitignore
70
+ - .rspec
71
+ - .travis.yml
57
72
  - Gemfile
58
73
  - README.md
59
74
  - Rakefile
60
75
  - bin/mystem-bsd
61
76
  - bin/mystem-linux-32
62
77
  - bin/mystem-linux-64
78
+ - bin/mystem-osx
63
79
  - bin/mystem-win.exe
64
80
  - lib/yandex_mystem.rb
65
81
  - lib/yandex_mystem/version.rb
@@ -75,12 +91,12 @@ require_paths:
75
91
  - lib
76
92
  required_ruby_version: !ruby/object:Gem::Requirement
77
93
  requirements:
78
- - - ">="
94
+ - - '>='
79
95
  - !ruby/object:Gem::Version
80
96
  version: '0'
81
97
  required_rubygems_version: !ruby/object:Gem::Requirement
82
98
  requirements:
83
- - - ">="
99
+ - - '>='
84
100
  - !ruby/object:Gem::Version
85
101
  version: '0'
86
102
  requirements: []