morphy 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +5 -5
  2. data/lib/morphy.rb +17 -13
  3. data/lib/word.rb +8 -2
  4. data/morphy.gemspec +3 -3
  5. metadata +5 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2043e06b2bcf5167e7168174d8901f94c0edff70
4
- data.tar.gz: d680e08f1f1f6f970368061a683b3f1b8376ffd4
2
+ SHA256:
3
+ metadata.gz: 2650e009cfec7a8911236c1f2f51fca35227f8072ff91e9d5a1016711a646e8c
4
+ data.tar.gz: be9fb576f23147cf08cb8469d9adc2fac227efbd2dcdd640a8ee617b20684337
5
5
  SHA512:
6
- metadata.gz: af2e12c15abd7df227e96aa4b39d5a37a1c24cb7d975449c33c9abd0e1261bd872464d576877d886925828e826cc462b448403018bd9843b60a06b098915c97b
7
- data.tar.gz: f485634c9341574dbc93bfa5cfdd95485bf09c69bd2e4fad67c96e61edcbaaa8aab89455e4fdbf4a7902aa392378f32feb6e9bbde7ffedf4ebc5bc160c778abc
6
+ metadata.gz: c6d20ea776139c510fc3924872a4733e7335ed5e72dc03db22e994324462049d467bc56dc8469799495ddc0d3138ac7dacfd7798795d9a2bdcd5c5a7fd1fa27f
7
+ data.tar.gz: df76cade4ab06729bbed47462a54727236d93f5fe6c92ca42f2fe6b73711bb831dd272c2420a566c48a200b16d8f493d61ce55dda45f215df745758871dcb5a4
data/lib/morphy.rb CHANGED
@@ -1,26 +1,27 @@
1
- require "dawg"
2
- require_relative "word"
1
+ # frozen_string_literal: true
3
2
 
4
- module Morphy
3
+ require 'dawg'
4
+ require_relative 'word'
5
5
 
6
+ module Morphy
6
7
  class Morphy
7
-
8
8
  def initialize
9
9
  @dawg = Dawg.load("#{::Morphy.path}/dawg.bin")
10
10
  end
11
11
 
12
12
  def query(word)
13
- results = @dawg.query(word)
14
- results = results.map do |result|
15
- result = result.to_s
16
- word, para_id, index = result.split(' ')
13
+ entries = @dawg.query(word)
14
+
15
+ entries.lazy.map do |row|
16
+ next if row.empty?
17
+
18
+ word, para_id, index = row.to_s.split(' ')
17
19
  Word.new(word, para_id, index)
18
20
  end
19
- results
20
21
  end
21
22
 
22
23
  def to_s
23
- "Morphy"
24
+ 'Morphy'
24
25
  end
25
26
  end
26
27
 
@@ -31,7 +32,7 @@ module Morphy
31
32
  end
32
33
 
33
34
  def path
34
- File.dirname(__FILE__)+"/dictionary"
35
+ File.dirname(__FILE__) + '/dictionary'
35
36
  end
36
37
 
37
38
  def paradigms
@@ -47,7 +48,10 @@ module Morphy
47
48
  end
48
49
 
49
50
  def grammemes
50
- @@grammemes ||= File.open("#{path}/grammemes.txt", 'r').read.split("\n").map{|g| g.split(",")}
51
+ @@grammemes ||=
52
+ File
53
+ .open("#{path}/grammemes.txt", 'r')
54
+ .read
55
+ .split('\n').map { |g| g.split(',') }
51
56
  end
52
-
53
57
  end
data/lib/word.rb CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Morphy
2
4
  class Word
3
5
  attr_accessor :para_id
4
6
 
5
- def initialize(word,para_id,index)
7
+ def initialize(word, para_id, index)
6
8
  @word = word
7
9
  @para_id = para_id.to_i
8
10
  @index = index.to_i
@@ -25,7 +27,7 @@ module Morphy
25
27
  ::Morphy.grammemes[@grammeme_id]
26
28
  end
27
29
 
28
- def stem
30
+ def stem
29
31
  word = @word.dup
30
32
  word.sub!(::Morphy.prefixes[@prefix_id], '')
31
33
  word = word.reverse.sub(::Morphy.suffixes[@suffix_id].reverse, '').reverse
@@ -56,5 +58,9 @@ module Morphy
56
58
  end
57
59
  nil
58
60
  end
61
+
62
+ def inspect
63
+ @word
64
+ end
59
65
  end
60
66
  end
data/morphy.gemspec CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "morphy"
5
- spec.version = "0.0.5"
6
- spec.date = '2017-03-19'
5
+ spec.version = "0.0.6"
6
+ spec.date = '2020-02-04'
7
7
  spec.authors = ["Maksatbek Mansurov"]
8
8
  spec.email = ["maksat.mansurov@gmail.com"]
9
9
  spec.description = %q{Morphological analyzer (POS tagger + inflection engine) for Russian language in ruby. Inspired by pymorphy2}
@@ -15,5 +15,5 @@ Gem::Specification.new do |spec|
15
15
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
- spec.add_runtime_dependency 'dawg', '~> 0.0', '>= 0.0.4'
18
+ spec.add_runtime_dependency 'dawg', '~> 0.0', '>= 0.0.6'
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morphy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maksatbek Mansurov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-19 00:00:00.000000000 Z
11
+ date: 2020-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dawg
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '0.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.0.4
22
+ version: 0.0.6
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '0.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.0.4
32
+ version: 0.0.6
33
33
  description: Morphological analyzer (POS tagger + inflection engine) for Russian language
34
34
  in ruby. Inspired by pymorphy2
35
35
  email:
@@ -69,8 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubyforge_project:
73
- rubygems_version: 2.4.5.1
72
+ rubygems_version: 3.0.3
74
73
  signing_key:
75
74
  specification_version: 4
76
75
  summary: Morphological analyzer for Russian language in ruby. Inspired by pymorphy2