ruby-spacy 0.4.0 → 0.4.1

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/README.md +61 -1
  4. data/Rakefile +13 -0
  5. data/examples/get_started/lexeme.rb +0 -0
  6. data/examples/get_started/linguistic_annotations.rb +0 -0
  7. data/examples/get_started/morphology.rb +0 -0
  8. data/examples/get_started/most_similar.rb +0 -0
  9. data/examples/get_started/named_entities.rb +0 -0
  10. data/examples/get_started/outputs/test_dep.svg +0 -0
  11. data/examples/get_started/outputs/test_dep_compact.svg +0 -0
  12. data/examples/get_started/outputs/test_ent.html +0 -0
  13. data/examples/get_started/pos_tags_and_dependencies.rb +0 -0
  14. data/examples/get_started/similarity.rb +0 -0
  15. data/examples/get_started/tokenization.rb +0 -0
  16. data/examples/get_started/visualizing_dependencies.rb +0 -0
  17. data/examples/get_started/visualizing_dependencies_compact.rb +0 -0
  18. data/examples/get_started/visualizing_named_entities.rb +0 -0
  19. data/examples/get_started/vocab.rb +0 -0
  20. data/examples/get_started/word_vectors.rb +0 -0
  21. data/examples/japanese/ancestors.rb +0 -0
  22. data/examples/japanese/entity_annotations_and_labels.rb +0 -0
  23. data/examples/japanese/information_extraction.rb +0 -0
  24. data/examples/japanese/lemmatization.rb +0 -0
  25. data/examples/japanese/most_similar.rb +0 -0
  26. data/examples/japanese/named_entity_recognition.rb +0 -0
  27. data/examples/japanese/navigating_parse_tree.rb +0 -0
  28. data/examples/japanese/noun_chunks.rb +0 -0
  29. data/examples/japanese/outputs/test_dep.svg +0 -0
  30. data/examples/japanese/outputs/test_ent.html +0 -0
  31. data/examples/japanese/pos_tagging.rb +0 -0
  32. data/examples/japanese/sentence_segmentation.rb +0 -0
  33. data/examples/japanese/similarity.rb +0 -0
  34. data/examples/japanese/tokenization.rb +0 -0
  35. data/examples/japanese/visualizing_dependencies.rb +0 -0
  36. data/examples/japanese/visualizing_named_entities.rb +0 -0
  37. data/examples/linguistic_features/ancestors.rb +0 -0
  38. data/examples/linguistic_features/entity_annotations_and_labels.rb +0 -0
  39. data/examples/linguistic_features/finding_a_verb_with_a_subject.rb +0 -0
  40. data/examples/linguistic_features/information_extraction.rb +0 -0
  41. data/examples/linguistic_features/iterating_children.rb +0 -0
  42. data/examples/linguistic_features/iterating_lefts_and_rights.rb +0 -0
  43. data/examples/linguistic_features/lemmatization.rb +0 -0
  44. data/examples/linguistic_features/named_entity_recognition.rb +0 -0
  45. data/examples/linguistic_features/navigating_parse_tree.rb +0 -0
  46. data/examples/linguistic_features/noun_chunks.rb +0 -0
  47. data/examples/linguistic_features/outputs/test_ent.html +0 -0
  48. data/examples/linguistic_features/pos_tagging.rb +0 -0
  49. data/examples/linguistic_features/retokenize_1.rb +0 -0
  50. data/examples/linguistic_features/retokenize_2.rb +0 -0
  51. data/examples/linguistic_features/rule_based_morphology.rb +0 -0
  52. data/examples/linguistic_features/sentence_segmentation.rb +0 -0
  53. data/examples/linguistic_features/similarity.rb +0 -0
  54. data/examples/linguistic_features/similarity_between_lexemes.rb +0 -0
  55. data/examples/linguistic_features/similarity_between_spans.rb +0 -0
  56. data/examples/linguistic_features/tokenization.rb +0 -0
  57. data/examples/openai_integration/openai_embeddings.rb +0 -0
  58. data/examples/rule_based_matching/creating_spans_from_matches.rb +0 -0
  59. data/examples/rule_based_matching/matcher.rb +0 -0
  60. data/lib/ruby-spacy/version.rb +1 -1
  61. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6185c586feb32fa51efcd4349398cd4ca9541280a5cc8a1b6a73eb93a987d4ac
4
- data.tar.gz: a146a9c40e2d5293e2401cb16b8ac6866cbb577e11a10d9657c406f933e7a3aa
3
+ metadata.gz: 9bf4e97474302a2fffe019227e5afbb26c815036d13ec75bae6349f7186dff31
4
+ data.tar.gz: 2cd4012d9545d0a5ad9d2ebb03d07e40ae54acdfb18f0c9132c8848cce5cfd8e
5
5
  SHA512:
6
- metadata.gz: bf558d4e9a7a6765fd7d088bbf8324a6ee0e4f4186962551d71e5a991e0aefd1e51a186f19c2824fabcc6afd0c83960771f082237febece52c2a522ccb39a5cf
7
- data.tar.gz: 3a64559cf8c169d1ac1ecdef526d26e5776989b9cc203a8ed30e0dd5d87ff62a4d1b741aff30c8cb49e5ffb716c6068f9af3a12d50d0d4de8ad6f22ebe80ea0d
6
+ metadata.gz: 208f43e0efa0334ec159fb56e836f315bd5469a3768e77e0f6b7fa3ec936e722546e0323cc7bf5790393cc2fc52318e172355b821b6f3c83268de3cbf35ba139
7
+ data.tar.gz: 753515dcb7fb3e44ea2c4419e83baf9e0e8f9c6810a4f65cbfc3a631414b33019b5a0b4915c9a87edd8ac34fb8aac48673954c092c50e2e1cc152713bde48466
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.4.1 - 2026-07-19
4
+ ### Fixed
5
+ - Gem packaging: normalize file permissions at build time so packaged files
6
+ are world-readable (0644 / 0755). Version 0.4.0 shipped 11 owner-only
7
+ (0600) files, which made the gem unusable after `sudo gem install`
8
+
9
+ ## 0.4.0 - 2026-02-23
10
+ ### Added
11
+ - `Language#with_openai` block API with `OpenAIHelper` for streamlined OpenAI integration
12
+ - `Doc#linguistic_summary` for JSON-formatted spaCy analysis output
13
+ - `Token#idx`, `Span#text`/`Span#to_s`, `Language#memory_zone` (spaCy 3.8+)
14
+
15
+ ### Fixed
16
+ - `Doc#ents` returns proper `Span` objects instead of raw Python objects
17
+
18
+ ### Changed
19
+ - Model name validation in `Language#initialize` for security
20
+ - OpenAI client: temperature support for o-series models, 429 retry with
21
+ exponential backoff, client reuse, `dimensions`/`response_format` parameters,
22
+ tool call depth limit
23
+ - Improved `respond_to_missing?` across all wrapper classes
24
+ - Added `instance_variables_to_inspect` for Ruby 4.0+ compatibility
25
+ - Added `base64` gem dependency (required for Ruby 3.4+)
26
+
3
27
  ## 0.3.0 - 2025-01-06
4
28
  ### Added
5
29
  - Ruby 4.0 support
data/README.md CHANGED
@@ -13,11 +13,12 @@
13
13
  | ✅ | Access to pre-trained word vectors |
14
14
  | ✅ | OpenAI Chat/Completion/Embeddings API integration |
15
15
 
16
- Current Version: `0.3.0`
16
+ Current Version: `0.4.0`
17
17
 
18
18
  - Ruby 4.0 supported
19
19
  - spaCy 3.8 supported
20
20
  - OpenAI GPT-5 API integration
21
+ - Block-based OpenAI API with linguistic analysis
21
22
 
22
23
  ## Installation of Prerequisites
23
24
 
@@ -843,6 +844,65 @@ Output:
843
844
  ...
844
845
  ```
845
846
 
847
+ ### Block-based OpenAI API
848
+
849
+ The `Language#with_openai` block API provides a streamlined way to combine spaCy's linguistic analysis with OpenAI. The `Doc#linguistic_summary` method generates a JSON summary of spaCy's analysis (tokens, entities, noun chunks, etc.) that can be passed directly to the LLM as context.
850
+
851
+ **Basic usage:**
852
+
853
+ ```ruby
854
+ require "ruby-spacy"
855
+
856
+ nlp = Spacy::Language.new("en_core_web_sm")
857
+ doc = nlp.read("Apple Inc. was founded by Steve Jobs in California.")
858
+
859
+ nlp.with_openai(model: "gpt-5-mini") do |ai|
860
+ result = ai.chat(
861
+ system: "You are a linguistic analyst. Analyze the given linguistic data.",
862
+ user: doc.linguistic_summary
863
+ )
864
+ puts result
865
+ end
866
+ ```
867
+
868
+ **Batch processing with `pipe`:**
869
+
870
+ ```ruby
871
+ require "ruby-spacy"
872
+
873
+ nlp = Spacy::Language.new("en_core_web_sm")
874
+ texts = ["The bank approved the loan.", "I sat on the river bank."]
875
+
876
+ nlp.with_openai(model: "gpt-5-mini") do |ai|
877
+ nlp.pipe(texts).each do |doc|
878
+ result = ai.chat(
879
+ system: "Identify the meaning of 'bank' in one word based on the linguistic context.",
880
+ user: doc.linguistic_summary
881
+ )
882
+ puts "#{doc.text} => #{result}"
883
+ end
884
+ end
885
+ ```
886
+
887
+ **Customizing linguistic summary:**
888
+
889
+ ```ruby
890
+ # Include sentences and morphology, exclude noun chunks
891
+ summary = doc.linguistic_summary(
892
+ sections: [:text, :tokens, :entities, :sentences],
893
+ token_attributes: [:text, :lemma, :pos, :dep, :head, :morphology]
894
+ )
895
+ ```
896
+
897
+ **Embeddings:**
898
+
899
+ ```ruby
900
+ nlp.with_openai do |ai|
901
+ vector = ai.embeddings("Hello world")
902
+ puts vector.length # => 1536
903
+ end
904
+ ```
905
+
846
906
  ## Advanced Usage
847
907
 
848
908
  ### Setting a Timeout
data/Rakefile CHANGED
@@ -10,3 +10,16 @@ Rake::TestTask.new(:test) do |t|
10
10
  end
11
11
 
12
12
  task default: :test
13
+
14
+ # Gem packaging preserves on-disk file modes; owner-only permissions here
15
+ # produce gems whose files are unreadable after a sudo install. Executable
16
+ # status is determined by path alone because local (Dropbox-synced) modes
17
+ # are unreliable.
18
+ task :normalize_permissions do
19
+ `git ls-files -z`.split("\x0").each do |f|
20
+ executable = f.start_with?("bin/", "exe/")
21
+ File.chmod(executable ? 0o755 : 0o644, f)
22
+ end
23
+ end
24
+
25
+ Rake::Task["build"].enhance([:normalize_permissions])
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Spacy
4
4
  # The version number of the module
5
- VERSION = "0.4.0"
5
+ VERSION = "0.4.1"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-spacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe