Sha256: c6c019eb8fe9272255c1dee8eaa2486f29f79b8b6de480f9223c607216e4ff5c
Contents?: true
Size: 1.41 KB
Versions: 2
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.map(&:text).join(", ")] 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-spacy-0.1.4.1 | examples/linguistic_features/navigating_parse_tree.rb |
ruby-spacy-0.1.4 | examples/linguistic_features/navigating_parse_tree.rb |