Sha256: 6b28c860437de1fe5df253e58a941e91501d186dda625d5ce510b91c73f01f85

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

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

nlp = Spacy::Language.new("en_core_web_sm")
doc = nlp.read("Apple is looking at buying U.K. startup for $1 billion.")

headings = ["text", "lemma", "pos", "tag", "dep"]
rows = []

doc.each do |token|
  rows << [token.text, token.lemma, token.pos, token.tag, token.dep]
end

table = Terminal::Table.new rows: rows, headings: headings
puts table

# +---------+---------+-------+-----+----------+
# | text    | lemma   | pos   | tag | dep      |
# +---------+---------+-------+-----+----------+
# | Apple   | Apple   | PROPN | NNP | nsubj    |
# | is      | be      | AUX   | VBZ | aux      |
# | looking | look    | VERB  | VBG | ROOT     |
# | at      | at      | ADP   | IN  | prep     |
# | buying  | buy     | VERB  | VBG | pcomp    |
# | U.K.    | U.K.    | PROPN | NNP | dobj     |
# | startup | startup | NOUN  | NN  | advcl    |
# | for     | for     | ADP   | IN  | prep     |
# | $       | $       | SYM   | $   | quantmod |
# | 1       | 1       | NUM   | CD  | compound |
# | billion | billion | NUM   | CD  | pobj     |
# +---------+---------+-------+-----+----------+

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-spacy-0.1.4.1 examples/get_started/pos_tags_and_dependencies.rb
ruby-spacy-0.1.4 examples/get_started/pos_tags_and_dependencies.rb