ruby-spacy 0.1.5.1 → 0.1.5.3

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
  SHA256:
3
- metadata.gz: 06dd0ed2027c0d0c2e610141ef375d483734adfe7855a2306b9b23a00a743b73
4
- data.tar.gz: fbe23e5e67a9502d2b6bd439608a6f1d43c82c0b05437386c7f65a69326b2cf0
3
+ metadata.gz: f24b8651e27c45774a7cc3ce945e085b76a4ef8cf62d2c622f049b4e73ca4e6d
4
+ data.tar.gz: 41e019d39764ab082d97af5a097e05f783774c542130bedd39ca1f798ad42477
5
5
  SHA512:
6
- metadata.gz: da5fd99c782737cea2e1fa125b66de561522ac541e7a3c15f6ebbda7c6eae1e55925b043cd3421463d95c8dda450ed6d1c65704b88a92acff4b9c716d38a96d4
7
- data.tar.gz: db33fe51cbe8d6613afaed4e648928b95e4d78481831c0f998cca443d181903af444719d90275035b1b582d4bd281b6dc3e8624e9177506b8ad2ef836b6d82e6
6
+ metadata.gz: 52e32fa278445492c3f5d1464b5bd8c61252bd5bff37c6af96d2ebafbc426ebf10e32640fbd2be274a4a90d165418b02ca31a29f84bfb98bcf662e705e4fabc9
7
+ data.tar.gz: 8d79c94e1715a327c96a4cf1fd55be535fb7b2e7cf1780545bc2ad433f08180e8b177b6f3b0e9d99a4279108b3ffac859d727c1dcfc55fbeaad5f83a9dee6ea1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-spacy (0.1.5.0)
4
+ ruby-spacy (0.1.5.3)
5
5
  numpy (~> 0.4.0)
6
6
  pycall (~> 1.4.0)
7
7
  terminal-table (~> 3.0.1)
@@ -15,34 +15,31 @@ GEM
15
15
  diff-lcs (1.5.0)
16
16
  e2mmap (0.1.0)
17
17
  github-markup (4.0.1)
18
- jaro_winkler (1.5.4)
18
+ jaro_winkler (1.5.6)
19
19
  json (2.6.3)
20
20
  kramdown (2.4.0)
21
21
  rexml
22
22
  kramdown-parser-gfm (1.1.0)
23
23
  kramdown (~> 2.0)
24
- mini_portile2 (2.8.1)
25
- minitest (5.17.0)
26
- nokogiri (1.14.0)
27
- mini_portile2 (~> 2.8.0)
28
- racc (~> 1.4)
29
- nokogiri (1.14.0-arm64-darwin)
30
- racc (~> 1.4)
31
- nokogiri (1.14.0-x86_64-darwin)
32
- racc (~> 1.4)
33
- nokogiri (1.14.0-x86_64-linux)
24
+ language_server-protocol (3.17.0.3)
25
+ mini_portile2 (2.8.4)
26
+ minitest (5.19.0)
27
+ nokogiri (1.15.3)
28
+ mini_portile2 (~> 2.8.2)
34
29
  racc (~> 1.4)
35
30
  numpy (0.4.0)
36
31
  pycall (>= 1.2.0.beta1)
37
- parallel (1.22.1)
38
- parser (3.2.0.0)
32
+ parallel (1.23.0)
33
+ parser (3.2.2.3)
39
34
  ast (~> 2.4.1)
35
+ racc
40
36
  pycall (1.4.2)
41
- racc (1.6.2)
37
+ racc (1.7.1)
42
38
  rainbow (3.1.1)
43
39
  rake (13.0.6)
44
- redcarpet (3.5.1)
45
- regexp_parser (2.6.2)
40
+ rbs (2.8.4)
41
+ redcarpet (3.6.0)
42
+ regexp_parser (2.8.1)
46
43
  reverse_markdown (2.1.1)
47
44
  nokogiri
48
45
  rexml (3.2.5)
@@ -50,57 +47,54 @@ GEM
50
47
  rspec-core (~> 3.12.0)
51
48
  rspec-expectations (~> 3.12.0)
52
49
  rspec-mocks (~> 3.12.0)
53
- rspec-core (3.12.0)
50
+ rspec-core (3.12.2)
54
51
  rspec-support (~> 3.12.0)
55
- rspec-expectations (3.12.2)
52
+ rspec-expectations (3.12.3)
56
53
  diff-lcs (>= 1.2.0, < 2.0)
57
54
  rspec-support (~> 3.12.0)
58
- rspec-mocks (3.12.3)
55
+ rspec-mocks (3.12.6)
59
56
  diff-lcs (>= 1.2.0, < 2.0)
60
57
  rspec-support (~> 3.12.0)
61
- rspec-support (3.12.0)
62
- rubocop (1.43.0)
58
+ rspec-support (3.12.1)
59
+ rubocop (1.55.0)
63
60
  json (~> 2.3)
61
+ language_server-protocol (>= 3.17.0)
64
62
  parallel (~> 1.10)
65
- parser (>= 3.2.0.0)
63
+ parser (>= 3.2.2.3)
66
64
  rainbow (>= 2.2.2, < 4.0)
67
65
  regexp_parser (>= 1.8, < 3.0)
68
66
  rexml (>= 3.2.5, < 4.0)
69
- rubocop-ast (>= 1.24.1, < 2.0)
67
+ rubocop-ast (>= 1.28.1, < 2.0)
70
68
  ruby-progressbar (~> 1.7)
71
69
  unicode-display_width (>= 2.4.0, < 3.0)
72
- rubocop-ast (1.24.1)
73
- parser (>= 3.1.1.0)
74
- ruby-progressbar (1.11.0)
75
- solargraph (0.48.0)
70
+ rubocop-ast (1.29.0)
71
+ parser (>= 3.2.1.0)
72
+ ruby-progressbar (1.13.0)
73
+ solargraph (0.49.0)
76
74
  backport (~> 1.2)
77
75
  benchmark
78
- bundler (>= 1.17.2)
76
+ bundler (~> 2.0)
79
77
  diff-lcs (~> 1.4)
80
78
  e2mmap
81
79
  jaro_winkler (~> 1.5)
82
80
  kramdown (~> 2.3)
83
81
  kramdown-parser-gfm (~> 1.1)
84
82
  parser (~> 3.0)
85
- reverse_markdown (>= 1.0.5, < 3)
86
- rubocop (>= 0.52)
83
+ rbs (~> 2.0)
84
+ reverse_markdown (~> 2.0)
85
+ rubocop (~> 1.38)
87
86
  thor (~> 1.0)
88
87
  tilt (~> 2.0)
89
88
  yard (~> 0.9, >= 0.9.24)
90
89
  terminal-table (3.0.2)
91
90
  unicode-display_width (>= 1.1.1, < 3)
92
- thor (1.2.1)
93
- tilt (2.0.11)
91
+ thor (1.2.2)
92
+ tilt (2.2.0)
94
93
  unicode-display_width (2.4.2)
95
- webrick (1.7.0)
96
- yard (0.9.28)
97
- webrick (~> 1.7.0)
94
+ yard (0.9.34)
98
95
 
99
96
  PLATFORMS
100
- arm64-darwin-20
101
97
  ruby
102
- x86_64-darwin-20
103
- x86_64-linux
104
98
 
105
99
  DEPENDENCIES
106
100
  bundler
@@ -117,4 +111,4 @@ DEPENDENCIES
117
111
  yard
118
112
 
119
113
  BUNDLED WITH
120
- 2.4.2
114
+ 2.4.13
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Spacy
4
4
  # The version number of the module
5
- VERSION = "0.1.5.1"
5
+ VERSION = "0.1.5.3"
6
6
  end
data/lib/ruby-spacy.rb CHANGED
@@ -7,7 +7,7 @@ require "pycall"
7
7
 
8
8
  # This module covers the areas of spaCy functionality for _using_ many varieties of its language models, not for _building_ ones.
9
9
  module Spacy
10
- MAX_RETRIAL = 20
10
+ MAX_RETRIAL = 5
11
11
 
12
12
  spacy = PyCall.import_module("spacy")
13
13
 
@@ -59,10 +59,16 @@ module Spacy
59
59
  # @param nlp [Language] an instance of {Language} class
60
60
  # @param py_doc [Object] an instance of Python `Doc` class
61
61
  # @param text [String] the text string to be analyzed
62
- def initialize(nlp, py_doc: nil, text: nil)
62
+ def initialize(nlp, py_doc: nil, text: nil, max_retrial: MAX_RETRIAL, retrial: 0)
63
63
  @py_nlp = nlp
64
64
  @py_doc = py_doc || @py_doc = nlp.call(text)
65
65
  @text = @py_doc.text
66
+ rescue StandardError
67
+ retrial += 1
68
+ raise "Error: Failed to construct a Doc object" unless retrial <= max_retrial
69
+
70
+ sleep 0.5
71
+ initialize(nlp, py_doc: py_doc, text: text, max_retrial: max_retrial, retrial: retrial)
66
72
  end
67
73
 
68
74
  # Retokenizes the text merging a span into a single token.
@@ -212,7 +218,7 @@ module Spacy
212
218
 
213
219
  # Creates a language model instance, which is conventionally referred to by a variable named `nlp`.
214
220
  # @param model [String] A language model installed in the system
215
- def initialize(model = "en_core_web_sm", max_retrial = MAX_RETRIAL, retrial = 0)
221
+ def initialize(model = "en_core_web_sm", max_retrial: MAX_RETRIAL, retrial: 0)
216
222
  @spacy_nlp_id = "nlp_#{model.object_id}"
217
223
  PyCall.exec("import spacy; #{@spacy_nlp_id} = spacy.load('#{model}')")
218
224
  @py_nlp = PyCall.eval(@spacy_nlp_id)
@@ -221,7 +227,7 @@ module Spacy
221
227
  raise "Error: Pycall failed to load Spacy" unless retrial <= max_retrial
222
228
 
223
229
  sleep 0.5
224
- initialize(model, max_retrial, retrial)
230
+ initialize(model, max_retrial: max_retrial, retrial: retrial)
225
231
  end
226
232
 
227
233
  # Reads and analyze the given text.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-spacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.1
4
+ version: 0.1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-22 00:00:00.000000000 Z
11
+ date: 2023-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  requirements: []
211
- rubygems_version: 3.4.1
211
+ rubygems_version: 3.4.12
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: A wrapper module for using spaCy natural language processing library from