Sha256: fda062c2a8c97bc23b81d2692df0dedcd6206841cb87877532b4d613804f003a
Contents?: true
Size: 1008 Bytes
Versions: 2
Compression:
Stored size: 1008 Bytes
Contents
require "ruby-spacy" require "terminal-table" nlp = Spacy::Language.new("en_core_web_sm") lemmatizer = nlp.get_pipe("lemmatizer") puts "Lemmatizer mode: " + lemmatizer.mode doc = nlp.read("Autonomous cars shift insurance liability toward manufacturers") headings = ["text", "root.text", "root.dep", "root.head.text"] rows = [] doc.noun_chunks.each do |chunk| rows << [chunk.text, chunk.root.text, chunk.root.dep, chunk.root.head.text] end table = Terminal::Table.new rows: rows, headings: headings puts table # +---------------------+---------------+----------+----------------+ # | text | root.text | root.dep | root.head.text | # +---------------------+---------------+----------+----------------+ # | Autonomous cars | cars | nsubj | shift | # | insurance liability | liability | dobj | shift | # | manufacturers | manufacturers | pobj | toward | # +---------------------+---------------+----------+----------------+
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-spacy-0.1.4.1 | examples/linguistic_features/noun_chunks.rb |
ruby-spacy-0.1.4 | examples/linguistic_features/noun_chunks.rb |