Sha256: 24435ea7ee1f0545b4bd80b2d8a6c2d680ba33e8b49b8036b054faf767d1c5c2

Contents?: true

Size: 696 Bytes

Versions: 1

Compression:

Stored size: 696 Bytes

Contents

require "ruby-spacy"
require "terminal-table"

nlp = Spacy::Language.new("en_core_web_sm")

doc = nlp.read("bright red apples on the tree")

puts "Text: " + doc.text

puts "Words to the left of 'apple': " + Spacy.generator_to_array(doc[2].lefts).to_s
puts "Words to the right of 'apple': " + Spacy.generator_to_array(doc[2].rights).to_s

puts "Num of the words to the left of 'apple': " + doc[2].n_lefts.to_s
puts "Num of the words to the right of 'apple': " + doc[2].n_rights.to_s

# Text: bright red apples on the tree
# Words to the left of 'apple': [bright, red]
# Words to the right of 'apple': [on]
# Num of the words to the left of 'apple': 2
# Num of the words to the right of 'apple': 1

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-spacy-0.1.3 examples/linguistic_features/iterating_lefts_and_rights.rb