Sha256: dac5d444e87add16f34c9c2a92e78ddb13415ef32d4f1c00473f22d2ab6b8a83
Contents?: true
Size: 676 Bytes
Versions: 2
Compression:
Stored size: 676 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': " + doc[2].lefts.map(&:text).join(", ") puts "Words to the right of 'apple': " + doc[2].rights.map(&:text).join(", ") 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-spacy-0.1.4.1 | examples/linguistic_features/iterating_lefts_and_rights.rb |
ruby-spacy-0.1.4 | examples/linguistic_features/iterating_lefts_and_rights.rb |