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 +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +1 -0
- data/README.md +3 -2
- data/bin/mystem-osx +0 -0
- data/lib/yandex_mystem.rb +15 -4
- data/lib/yandex_mystem/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/yandex_mystem_spec.rb +41 -38
- data/yandex_mystem.gemspec +3 -2
- metadata +31 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42ebc26d8af331ec4a606c2f7ed69a5a40239f7c
|
4
|
+
data.tar.gz: 4bb5b88a71900b0a1e52c15721aa3c9da910c81a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b03f45bf62644835dc08b2900a96fd803d6988bc7a6ea628db32fca727b366c51c962b732996b4a7d6ad7345b4d160dad2668d856e17d206a56fa57409655682
|
7
|
+
data.tar.gz: e4e5b7739af721a1c5a4d9d9333f8899d875142b4922d81987557de14762c222727d7d1cd2ad5f73adc828a1165679e15e688dae09eb023212bb286c35cd5733
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
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
|
|
data/bin/mystem-osx
ADDED
Binary file
|
data/lib/yandex_mystem.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'open3'
|
4
4
|
require 'yandex_mystem/version'
|
5
5
|
require 'pathname'
|
6
|
-
require '
|
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
|
-
|
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[
|
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
|
-
|
72
|
+
as_json(data)
|
62
73
|
end
|
63
74
|
end
|
64
75
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/yandex_mystem_spec.rb
CHANGED
@@ -3,36 +3,39 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe YandexMystem do
|
5
5
|
context YandexMystem::Simple do
|
6
|
-
it
|
6
|
+
it 'should stem words' do
|
7
7
|
data = YandexMystem::Simple.stem("мальчики мальчиков девочки девочек компьютеров компьютере сов пошли elements")
|
8
|
-
|
9
|
-
data['
|
10
|
-
data['
|
11
|
-
data['
|
12
|
-
data['
|
13
|
-
data['
|
14
|
-
data['
|
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
|
18
|
-
data = YandexMystem::Simple.stem(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
data['
|
31
|
-
data['
|
32
|
-
data['
|
33
|
-
data['
|
34
|
-
data['
|
35
|
-
data['
|
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.
|
44
|
-
response[0][:analysis].
|
45
|
-
response[0][:text].
|
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.
|
54
|
+
expect(response.size).to eq 11
|
55
|
+
|
56
|
+
analysis = response.find { |h| h[:text] == 'девочка' }[:analysis].first
|
52
57
|
|
53
|
-
|
54
|
-
|
55
|
-
|
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.
|
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.
|
67
|
+
expect(response.find { |h| h[:text] == 'Москва' }[:analysis].first[:gr]).to include 'geo'
|
63
68
|
end
|
64
|
-
|
65
|
-
|
66
69
|
end
|
67
70
|
end
|
data/yandex_mystem.gemspec
CHANGED
@@ -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.
|
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.
|
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-
|
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: '
|
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: '
|
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
|
-
-
|
55
|
-
-
|
56
|
-
-
|
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: []
|