Sha256: b794ab0e7e4686282248736e69b450cb6f5fecd5d7e44176bf744e54c4a41f9a
Contents?: true
Size: 1.1 KB
Versions: 1
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-spacy-0.1.2 | examples/get_started/pos_tags_and_dependencies.rb |