ruby-spacy 0.1.5.1 → 0.1.5.2

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: 968ceb2100aed3cac0218e19de4cf1a76b5bbedc81135128b136f7550242a27f
4
+ data.tar.gz: 37218f586e6ecd6a026aeec3dbb1794d26c0e14b9e55aeb38030e52ef5114937
5
5
  SHA512:
6
- metadata.gz: da5fd99c782737cea2e1fa125b66de561522ac541e7a3c15f6ebbda7c6eae1e55925b043cd3421463d95c8dda450ed6d1c65704b88a92acff4b9c716d38a96d4
7
- data.tar.gz: db33fe51cbe8d6613afaed4e648928b95e4d78481831c0f998cca443d181903af444719d90275035b1b582d4bd281b6dc3e8624e9177506b8ad2ef836b6d82e6
6
+ metadata.gz: 219c19baad143b8eea1e3d2072ef76e7fda32d77696537e92daa982e083ade0e5a9ad8b1db15bf8c846fe8245a090d72ed258bf8daad7c9e26bd8bf87ccb1b79
7
+ data.tar.gz: 1491cf3afd7eb0a1ba894eb5cee9679cb22bc9385a4fb9996046c6016975ce4ad7d838b4f2dc6dad8bb9c542a52048bb5aa5f613fdfd74a79e566cd985b9b11e
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.1)
5
5
  numpy (~> 0.4.0)
6
6
  pycall (~> 1.4.0)
7
7
  terminal-table (~> 3.0.1)
@@ -59,7 +59,7 @@ GEM
59
59
  diff-lcs (>= 1.2.0, < 2.0)
60
60
  rspec-support (~> 3.12.0)
61
61
  rspec-support (3.12.0)
62
- rubocop (1.43.0)
62
+ rubocop (1.44.1)
63
63
  json (~> 2.3)
64
64
  parallel (~> 1.10)
65
65
  parser (>= 3.2.0.0)
@@ -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.2"
6
6
  end
data/lib/ruby-spacy.rb CHANGED
@@ -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.2
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-01-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.3.3
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: A wrapper module for using spaCy natural language processing library from