ruby-spacy 0.1.5.4 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +2 -1
  5. data/README.md +169 -3
  6. data/examples/get_started/lexeme.rb +3 -0
  7. data/examples/get_started/linguistic_annotations.rb +3 -0
  8. data/examples/get_started/morphology.rb +3 -0
  9. data/examples/get_started/most_similar.rb +3 -0
  10. data/examples/get_started/named_entities.rb +3 -0
  11. data/examples/get_started/outputs/test_dep.svg +0 -0
  12. data/examples/get_started/outputs/test_dep_compact.svg +0 -0
  13. data/examples/get_started/outputs/test_ent.html +0 -0
  14. data/examples/get_started/pos_tags_and_dependencies.rb +3 -0
  15. data/examples/get_started/similarity.rb +3 -0
  16. data/examples/get_started/tokenization.rb +3 -0
  17. data/examples/get_started/visualizing_dependencies.rb +3 -0
  18. data/examples/get_started/visualizing_dependencies_compact.rb +3 -0
  19. data/examples/get_started/visualizing_named_entities.rb +3 -0
  20. data/examples/get_started/vocab.rb +3 -0
  21. data/examples/get_started/word_vectors.rb +3 -0
  22. data/examples/japanese/ancestors.rb +3 -0
  23. data/examples/japanese/entity_annotations_and_labels.rb +3 -0
  24. data/examples/japanese/information_extraction.rb +3 -0
  25. data/examples/japanese/lemmatization.rb +3 -0
  26. data/examples/japanese/most_similar.rb +3 -0
  27. data/examples/japanese/named_entity_recognition.rb +3 -0
  28. data/examples/japanese/navigating_parse_tree.rb +3 -0
  29. data/examples/japanese/noun_chunks.rb +3 -0
  30. data/examples/japanese/outputs/test_dep.svg +0 -0
  31. data/examples/japanese/outputs/test_ent.html +0 -0
  32. data/examples/japanese/pos_tagging.rb +3 -0
  33. data/examples/japanese/sentence_segmentation.rb +3 -0
  34. data/examples/japanese/similarity.rb +3 -0
  35. data/examples/japanese/tokenization.rb +3 -0
  36. data/examples/japanese/visualizing_dependencies.rb +3 -0
  37. data/examples/japanese/visualizing_named_entities.rb +3 -0
  38. data/examples/linguistic_features/ancestors.rb +3 -0
  39. data/examples/linguistic_features/entity_annotations_and_labels.rb +3 -0
  40. data/examples/linguistic_features/finding_a_verb_with_a_subject.rb +3 -0
  41. data/examples/linguistic_features/information_extraction.rb +3 -0
  42. data/examples/linguistic_features/iterating_children.rb +4 -1
  43. data/examples/linguistic_features/iterating_lefts_and_rights.rb +3 -0
  44. data/examples/linguistic_features/lemmatization.rb +3 -0
  45. data/examples/linguistic_features/named_entity_recognition.rb +3 -0
  46. data/examples/linguistic_features/navigating_parse_tree.rb +3 -0
  47. data/examples/linguistic_features/noun_chunks.rb +3 -0
  48. data/examples/linguistic_features/outputs/test_ent.html +0 -0
  49. data/examples/linguistic_features/pos_tagging.rb +3 -0
  50. data/examples/linguistic_features/retokenize_1.rb +3 -0
  51. data/examples/linguistic_features/retokenize_2.rb +3 -0
  52. data/examples/linguistic_features/rule_based_morphology.rb +3 -0
  53. data/examples/linguistic_features/sentence_segmentation.rb +3 -0
  54. data/examples/linguistic_features/similarity.rb +3 -0
  55. data/examples/linguistic_features/similarity_between_lexemes.rb +3 -0
  56. data/examples/linguistic_features/similarity_between_spans.rb +3 -0
  57. data/examples/linguistic_features/tokenization.rb +3 -0
  58. data/examples/openai_integration/openai_completion.rb +19 -0
  59. data/examples/openai_integration/openai_embeddings.rb +22 -0
  60. data/examples/openai_integration/openai_query_1.rb +20 -0
  61. data/examples/openai_integration/openai_query_2.rb +32 -0
  62. data/examples/openai_integration/openai_query_3.rb +74 -0
  63. data/examples/openai_integration/openai_query_4.rb +39 -0
  64. data/examples/rule_based_matching/creating_spans_from_matches.rb +3 -0
  65. data/examples/rule_based_matching/matcher.rb +3 -0
  66. data/lib/ruby-spacy/version.rb +1 -1
  67. data/lib/ruby-spacy.rb +139 -2
  68. data/ruby-spacy.gemspec +2 -1
  69. metadata +24 -8
  70. data/.python-version +0 -1
  71. data/.rubocop.yml +0 -48
  72. data/.solargraph.yml +0 -22
  73. data/.yardopts +0 -2
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
3
6
  require "ruby-spacy"
4
7
  require "terminal-table"
5
8
 
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
3
6
  require "ruby-spacy"
4
7
  require "terminal-table"
5
8
 
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
3
6
  require "ruby-spacy"
4
7
 
5
8
  nlp = Spacy::Language.new("en_core_web_sm")
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
3
6
  require "ruby-spacy"
4
7
  require "terminal-table"
5
8
 
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
3
6
  require "ruby-spacy"
4
7
  require "terminal-table"
5
8
 
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
3
6
  require "ruby-spacy"
4
7
  require "terminal-table"
5
8
 
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
3
6
  require "ruby-spacy"
4
7
  require "terminal-table"
5
8
 
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
6
+ require "ruby-spacy"
7
+
8
+ api_key = ENV["OPENAI_API_KEY"]
9
+ nlp = Spacy::Language.new("en_core_web_sm")
10
+ doc = nlp.read("Vladimir Nabokov was a")
11
+
12
+ # default parameter values
13
+ # max_tokens: 1000
14
+ # temperature: 0.7
15
+ # model: "gpt-3.5-turbo-0613"
16
+ res = doc.openai_completion(access_token: api_key)
17
+ puts res
18
+
19
+ # Russian-American novelist and lepidopterist. He was born in 1899 in St. Petersburg, Russia, and later emigrated to the United States in 1940. Nabokov is best known for his novel "Lolita," which was published in 1955 and caused much controversy due to its controversial subject matter. Throughout his career, Nabokov wrote many other notable works, including "Pale Fire" and "Ada or Ardor: A Family Chronicle." In addition to his writing, Nabokov was also a passionate butterfly collector and taxonomist, publishing several scientific papers on the subject. He passed away in 1977, leaving behind a rich literary legacy.
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
6
+ require "ruby-spacy"
7
+
8
+ api_key = ENV["OPENAI_API_KEY"]
9
+ nlp = Spacy::Language.new("en_core_web_sm")
10
+ doc = nlp.read("Vladimir Nabokov was a Russian-American novelist, poet, translator and entomologist.")
11
+
12
+ # default model : text-embedding-ada-002
13
+ res = doc.openai_embeddings(access_token: api_key)
14
+
15
+ puts res
16
+
17
+ # -0.00208362
18
+ # -0.01645165
19
+ # 0.0110955965
20
+ # 0.012802119
21
+ # 0.0012175755
22
+ # ...
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
6
+ require "ruby-spacy"
7
+
8
+ api_key = ENV["OPENAI_API_KEY"]
9
+ nlp = Spacy::Language.new("en_core_web_sm")
10
+ doc = nlp.read("The Beatles released 12 studio albums")
11
+
12
+ # default parameter values
13
+ # max_tokens: 1000
14
+ # temperature: 0.7
15
+ # model: "gpt-3.5-turbo-0613"
16
+ res = doc.openai_query(access_token: api_key, prompt: "Translate the text to Japanese.")
17
+
18
+ puts res
19
+
20
+ # ビートルズは12枚のスタジオアルバムをリリースしました。
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
6
+ require "ruby-spacy"
7
+
8
+ api_key = ENV["OPENAI_API_KEY"]
9
+ nlp = Spacy::Language.new("en_core_web_sm")
10
+ doc = nlp.read("The Beatles were an English rock band formed in Liverpool in 1960.")
11
+
12
+ # default parameter values
13
+ # max_tokens: 1000
14
+ # temperature: 0.7
15
+ # model: "gpt-3.5-turbo-0613"
16
+ res = doc.openai_query(access_token: api_key, prompt: "Extract the topic of the document and list 10 entities (names, concepts, locations, etc.) that are relevant to the topic.")
17
+
18
+ puts res
19
+
20
+ # Topic: The Beatles
21
+ #
22
+ # Entities:
23
+ # 1. The Beatles (band)
24
+ # 2. English (nationality)
25
+ # 3. Rock band
26
+ # 4. Liverpool (city)
27
+ # 5. 1960 (year)
28
+ # 6. John Lennon (member)
29
+ # 7. Paul McCartney (member)
30
+ # 8. George Harrison (member)
31
+ # 9. Ringo Starr (member)
32
+ # 10. Music
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
6
+ require "ruby-spacy"
7
+
8
+ api_key = ENV["OPENAI_API_KEY"]
9
+ nlp = Spacy::Language.new("en_core_web_sm")
10
+ doc = nlp.read("The Beatles released 12 studio albums")
11
+
12
+ # default parameter values
13
+ # max_tokens: 1000
14
+ # temperature: 0.7
15
+ # model: "gpt-3.5-turbo-0613"
16
+ res = doc.openai_query(access_token: api_key, prompt: "List detailed morphology data of each of the word used in the sentence")
17
+
18
+ puts res
19
+
20
+ # Here is the detailed morphology data for each word in the sentence:
21
+ #
22
+ # 1. Token: "The"
23
+ # - Surface: "The"
24
+ # - Lemma: "the"
25
+ # - Part-of-speech: Determiner (DET)
26
+ # - Tag: DT
27
+ # - Dependency: Determiner (det)
28
+ # - Entity type: None
29
+ # - Morphology: {'Definite': 'Def', 'PronType': 'Art'}
30
+ #
31
+ # 2. Token: "Beatles"
32
+ # - Surface: "Beatles"
33
+ # - Lemma: "beatle"
34
+ # - Part-of-speech: Noun (NOUN)
35
+ # - Tag: NNS
36
+ # - Dependency: Noun subject (nsubj)
37
+ # - Entity type: GPE (Geopolitical Entity)
38
+ # - Morphology: {'Number': 'Plur'}
39
+ #
40
+ # 3. Token: "released"
41
+ # - Surface: "released"
42
+ # - Lemma: "release"
43
+ # - Part-of-speech: Verb (VERB)
44
+ # - Tag: VBD
45
+ # - Dependency: Root
46
+ # - Entity type: None
47
+ # - Morphology: {'Tense': 'Past', 'VerbForm': 'Fin'}
48
+ #
49
+ # 4. Token: "12"
50
+ # - Surface: "12"
51
+ # - Lemma: "12"
52
+ # - Part-of-speech: Numeral (NUM)
53
+ # - Tag: CD
54
+ # - Dependency: Numeric modifier (nummod)
55
+ # - Entity type: Cardinal number (CARDINAL)
56
+ # - Morphology: {'NumType': 'Card'}
57
+ #
58
+ # 5. Token: "studio"
59
+ # - Surface: "studio"
60
+ # - Lemma: "studio"
61
+ # - Part-of-speech: Noun (NOUN)
62
+ # - Tag: NN
63
+ # - Dependency: Compound
64
+ # - Entity type: None
65
+ # - Morphology: {'Number': 'Sing'}
66
+ #
67
+ # 6. Token: "albums"
68
+ # - Surface: "albums"
69
+ # - Lemma: "album"
70
+ # - Part-of-speech: Noun (NOUN)
71
+ # - Tag: NNS
72
+ # - Dependency: Direct object (dobj)
73
+ # - Entity type: None
74
+ # - Morphology: {'Number': 'Plur'}
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
6
+ require "ruby-spacy"
7
+
8
+ api_key = ENV["OPENAI_API_KEY"]
9
+ nlp = Spacy::Language.new("en_core_web_sm")
10
+ doc = nlp.read("The Beatles released 12 studio albums")
11
+
12
+ # default parameter values
13
+ # max_tokens: 1000
14
+ # temperature: 0.7
15
+ # model: "gpt-3.5-turbo-0613"
16
+ res = doc.openai_query(
17
+ access_token: api_key,
18
+ model: "gpt-4",
19
+ prompt: "Generate a tree diagram from the text in the following style: [S [NP [Det the] [N cat]] [VP [V sat] [PP [P on] [NP the mat]]]"
20
+ )
21
+
22
+ puts res
23
+
24
+ # [S
25
+ # [NP
26
+ # [Det The]
27
+ # [N Beatles]
28
+ # ]
29
+ # [VP
30
+ # [V released]
31
+ # [NP
32
+ # [Num 12]
33
+ # [N
34
+ # [N studio]
35
+ # [N albums]
36
+ # ]
37
+ # ]
38
+ # ]
39
+ # ]
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
3
6
  require "ruby-spacy"
4
7
  require "terminal-table"
5
8
 
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # add path to ruby-spacy lib to load path
4
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
5
+
3
6
  require "ruby-spacy"
4
7
 
5
8
  nlp = Spacy::Language.new("en_core_web_sm")
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Spacy
4
4
  # The version number of the module
5
- VERSION = "0.1.5.4"
5
+ VERSION = "0.2.2"
6
6
  end
data/lib/ruby-spacy.rb CHANGED
@@ -4,12 +4,14 @@ require_relative "ruby-spacy/version"
4
4
  require "strscan"
5
5
  require "numpy"
6
6
  require "pycall"
7
+ require "openai"
7
8
 
8
9
  # This module covers the areas of spaCy functionality for _using_ many varieties of its language models, not for _building_ ones.
9
10
  module Spacy
10
11
  MAX_RETRIAL = 5
11
12
 
12
13
  spacy = PyCall.import_module("spacy")
14
+ SpacyVersion = spacy.__version__
13
15
 
14
16
  # Python `Language` class
15
17
  PyLanguage = spacy.language.Language
@@ -27,7 +29,7 @@ module Spacy
27
29
  PyMatcher = spacy.matcher.Matcher
28
30
 
29
31
  # Python `displacy` object
30
- PyDisplacy = spacy.displacy
32
+ PyDisplacy = PyCall.import_module('spacy.displacy')
31
33
 
32
34
  # A utility module method to convert Python's generator object to a Ruby array,
33
35
  # mainly used on the items inside the array returned from dependency-related methods
@@ -36,6 +38,18 @@ module Spacy
36
38
  PyCall::List.call(py_generator)
37
39
  end
38
40
 
41
+ @openai_client = nil
42
+
43
+ def self.openai_client(access_token:)
44
+ # If @client is already set, just return it. Otherwise, create a new instance.
45
+ @openai_client ||= OpenAI::Client.new(access_token: access_token)
46
+ end
47
+
48
+ # Provide an accessor method to get the client (optional)
49
+ def self.client
50
+ @openai_client
51
+ end
52
+
39
53
  # See also spaCy Python API document for [`Doc`](https://spacy.io/api/doc).
40
54
  class Doc
41
55
  # @return [Object] a Python `Language` instance accessible via `PyCall`
@@ -59,7 +73,8 @@ module Spacy
59
73
  # @param nlp [Language] an instance of {Language} class
60
74
  # @param py_doc [Object] an instance of Python `Doc` class
61
75
  # @param text [String] the text string to be analyzed
62
- def initialize(nlp, py_doc: nil, text: nil, max_retrial: MAX_RETRIAL, retrial: 0)
76
+ def initialize(nlp, py_doc: nil, text: nil, max_retrial: MAX_RETRIAL,
77
+ retrial: 0)
63
78
  @py_nlp = nlp
64
79
  @py_doc = py_doc || @py_doc = nlp.call(text)
65
80
  @text = @py_doc.text
@@ -198,6 +213,128 @@ module Spacy
198
213
  PyDisplacy.render(py_doc, style: style, options: { compact: compact }, jupyter: false)
199
214
  end
200
215
 
216
+ def openai_query(access_token: nil,
217
+ max_tokens: 1000,
218
+ temperature: 0.7,
219
+ model: "gpt-3.5-turbo-0613",
220
+ messages: [],
221
+ prompt: nil)
222
+ if messages.empty?
223
+ messages = [
224
+ { role: "system", content: prompt },
225
+ { role: "user", content: @text }
226
+ ]
227
+ end
228
+
229
+ access_token ||= ENV["OPENAI_API_KEY"]
230
+ raise "Error: OPENAI_API_KEY is not set" unless access_token
231
+
232
+ begin
233
+ response = Spacy.openai_client(access_token: access_token).chat(
234
+ parameters: {
235
+ model: model,
236
+ messages: messages,
237
+ max_tokens: max_tokens,
238
+ temperature: temperature,
239
+ function_call: "auto",
240
+ stream: false,
241
+ functions: [
242
+ {
243
+ name: "get_tokens",
244
+ description: "Tokenize given text and return a list of tokens with their attributes: surface, lemma, tag, pos (part-of-speech), dep (dependency), ent_type (entity type), and morphology",
245
+ "parameters": {
246
+ "type": "object",
247
+ "properties": {
248
+ "text": {
249
+ "type": "string",
250
+ "description": "text to be tokenized"
251
+ }
252
+ },
253
+ "required": ["text"]
254
+ }
255
+ }
256
+ ]
257
+ }
258
+ )
259
+
260
+ message = response.dig("choices", 0, "message")
261
+
262
+ if message["role"] == "assistant" && message["function_call"]
263
+ messages << message
264
+ function_name = message.dig("function_call", "name")
265
+ _args = JSON.parse(message.dig("function_call", "arguments"))
266
+ case function_name
267
+ when "get_tokens"
268
+ res = tokens.map do |t|
269
+ {
270
+ "surface": t.text,
271
+ "lemma": t.lemma,
272
+ "pos": t.pos,
273
+ "tag": t.tag,
274
+ "dep": t.dep,
275
+ "ent_type": t.ent_type,
276
+ "morphology": t.morphology
277
+ }
278
+ end.to_json
279
+ end
280
+ messages << { role: "system", content: res }
281
+ openai_query(access_token: access_token, max_tokens: max_tokens,
282
+ temperature: temperature, model: model,
283
+ messages: messages, prompt: prompt)
284
+ else
285
+ message["content"]
286
+ end
287
+ rescue StandardError => e
288
+ puts "Error: OpenAI API call failed."
289
+ pp e.message
290
+ pp e.backtrace
291
+ end
292
+ end
293
+
294
+ def openai_completion(access_token: nil, max_tokens: 1000, temperature: 0.7, model: "gpt-3.5-turbo-0613")
295
+ messages = [
296
+ { role: "system", content: "Complete the text input by the user." },
297
+ { role: "user", content: @text }
298
+ ]
299
+ access_token ||= ENV["OPENAI_API_KEY"]
300
+ raise "Error: OPENAI_API_KEY is not set" unless access_token
301
+
302
+ begin
303
+ response = Spacy.openai_client(access_token: access_token).chat(
304
+ parameters: {
305
+ model: model,
306
+ messages: messages,
307
+ max_tokens: max_tokens,
308
+ temperature: temperature
309
+ }
310
+ )
311
+ response.dig("choices", 0, "message", "content")
312
+ rescue StandardError => e
313
+ puts "Error: OpenAI API call failed."
314
+ pp e.message
315
+ pp e.backtrace
316
+ end
317
+ end
318
+
319
+ def openai_embeddings(access_token: nil, model: "text-embedding-ada-002")
320
+ access_token ||= ENV["OPENAI_API_KEY"]
321
+ raise "Error: OPENAI_API_KEY is not set" unless access_token
322
+
323
+ begin
324
+ response = Spacy.openai_client(access_token: access_token).embeddings(
325
+ parameters: {
326
+ model: model,
327
+ input: @text
328
+ }
329
+ )
330
+ response.dig("data", 0, "embedding")
331
+ rescue StandardError => e
332
+ puts "Error: OpenAI API call failed."
333
+ pp e.message
334
+ pp e.backtrace
335
+ end
336
+ end
337
+
201
338
  # Methods defined in Python but not wrapped in ruby-spacy can be called by this dynamic method handling mechanism.
202
339
  def method_missing(name, *args)
203
340
  @py_doc.send(name, *args)
data/ruby-spacy.gemspec CHANGED
@@ -32,7 +32,8 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "solargraph"
33
33
 
34
34
  spec.add_dependency "numpy", "~> 0.4.0"
35
- spec.add_dependency "pycall", "~> 1.4.0"
35
+ spec.add_dependency "pycall", "~> 1.5.1"
36
+ spec.add_dependency "ruby-openai"
36
37
  spec.add_dependency "terminal-table", "~> 3.0.1"
37
38
 
38
39
  # For more information and examples about making a new gem, checkout our
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.4
4
+ version: 0.2.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-07-28 00:00:00.000000000 Z
11
+ date: 2023-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.4.0
89
+ version: 1.5.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.4.0
96
+ version: 1.5.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: ruby-openai
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: terminal-table
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -121,10 +135,6 @@ extensions: []
121
135
  extra_rdoc_files: []
122
136
  files:
123
137
  - ".gitignore"
124
- - ".python-version"
125
- - ".rubocop.yml"
126
- - ".solargraph.yml"
127
- - ".yardopts"
128
138
  - CHANGELOG.md
129
139
  - Gemfile
130
140
  - LICENSE.txt
@@ -184,6 +194,12 @@ files:
184
194
  - examples/linguistic_features/similarity_between_lexemes.rb
185
195
  - examples/linguistic_features/similarity_between_spans.rb
186
196
  - examples/linguistic_features/tokenization.rb
197
+ - examples/openai_integration/openai_completion.rb
198
+ - examples/openai_integration/openai_embeddings.rb
199
+ - examples/openai_integration/openai_query_1.rb
200
+ - examples/openai_integration/openai_query_2.rb
201
+ - examples/openai_integration/openai_query_3.rb
202
+ - examples/openai_integration/openai_query_4.rb
187
203
  - examples/rule_based_matching/creating_spans_from_matches.rb
188
204
  - examples/rule_based_matching/matcher.rb
189
205
  - lib/ruby-spacy.rb
data/.python-version DELETED
@@ -1 +0,0 @@
1
- 3.10.6
data/.rubocop.yml DELETED
@@ -1,48 +0,0 @@
1
- AllCops:
2
- NewCops: disable
3
- SuggestExtensions: false
4
- TargetRubyVersion: 2.6
5
-
6
- Documentation:
7
- Enabled: false
8
-
9
- Naming/VariableNumber:
10
- Enabled: false
11
-
12
- Naming/FileName:
13
- Enabled: false
14
-
15
- Style/StringLiterals:
16
- Enabled: true
17
- EnforcedStyle: double_quotes
18
-
19
- Style/StringLiteralsInInterpolation:
20
- Enabled: true
21
- EnforcedStyle: double_quotes
22
-
23
- Layout/LineLength:
24
- Max: 400
25
-
26
- Metrics/MethodLength:
27
- Max: 80
28
-
29
- Metrics/BlockLength:
30
- Max: 60
31
-
32
- Metrics/AbcSize:
33
- Max: 60
34
-
35
- Metrics/PerceivedComplexity:
36
- Max: 10
37
-
38
- Metrics/ClassLength:
39
- Max: 400
40
-
41
- Metrics/CyclomaticComplexity:
42
- Max: 20
43
-
44
- Metrics/ParameterLists:
45
- Max: 8
46
-
47
- Metrics/ModuleLength:
48
- Max: 200
data/.solargraph.yml DELETED
@@ -1,22 +0,0 @@
1
- ---
2
- include:
3
- - "**/*.rb"
4
- exclude:
5
- - spec/**/*
6
- - test/**/*
7
- - vendor/**/*
8
- - ".bundle/**/*"
9
- require: []
10
- domains: []
11
- reporters:
12
- - rubocop
13
- # - require_not_found
14
- formatter:
15
- rubocop:
16
- cops: safe
17
- except: []
18
- only: []
19
- extra_args: []
20
- require_paths: []
21
- plugins: []
22
- max_files: 5000
data/.yardopts DELETED
@@ -1,2 +0,0 @@
1
- --markup-provider=redcarpet
2
- --markup=markdown