Sha256: a04ddd7dadac1e8eea0f3a36896ff6bc9719fbff1c3eb62171fe640d3e9fd2af

Contents?: true

Size: 390 Bytes

Versions: 4

Compression:

Stored size: 390 Bytes

Contents

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

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

doc = nlp.read("Autonomous cars shift insurance liability toward manufacturers")


results = []

doc.each do |token|
  if token.pos_ == "VERB"
    token.children.each do |child|
      if child.dep_ == "nsubj"
        results << child.head
      end
    end
  end
end

puts results.to_s

# [shift]

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-spacy-0.1.3 examples/linguistic_features/iterating_children.rb
ruby-spacy-0.1.2 examples/linguistic_features/iterating_children.rb
ruby-spacy-0.1.1 examples/linguistic_features/iterating_children.rb
ruby-spacy-0.1.0 examples/linguistic_features/iterating_children.rb