Sha256: 3be9f54a098f1478a2503e6f4ff4b1d8eaf4dbb816172df22ccf4d7e639b5fdb
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
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", "dep", "head text", "head pos", "children"] rows = [] doc.each do |token| rows << [token.text, token.dep_, token.head.text, token.head.pos_, token.children.to_s] end table = Terminal::Table.new rows: rows, headings: headings puts table # Lemmatizer mode: rule # +---------------+----------+-----------+----------+---------------------------+ # | text | dep | head text | head pos | children | # +---------------+----------+-----------+----------+---------------------------+ # | Autonomous | amod | cars | NOUN | [] | # | cars | nsubj | shift | VERB | [Autonomous] | # | shift | ROOT | shift | VERB | [cars, liability, toward] | # | insurance | compound | liability | NOUN | [] | # | liability | dobj | shift | VERB | [insurance] | # | toward | prep | shift | VERB | [manufacturers] | # | manufacturers | pobj | toward | ADP | [] | # +---------------+----------+-----------+----------+---------------------------+
Version data entries
4 entries across 4 versions & 1 rubygems