Sha256: bdbbdcf5710efc4a45fd5743f07225f4626e761b69fa1b8b1ab3f4252c73d276
Contents?: true
Size: 397 Bytes
Versions: 2
Compression:
Stored size: 397 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.text end end end end puts results.to_s # ["shift"]
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-spacy-0.1.4.1 | examples/linguistic_features/iterating_children.rb |
ruby-spacy-0.1.4 | examples/linguistic_features/iterating_children.rb |