Sha256: df0e0cb2fea3d3655cbe682d6557ac54bf213bdf48ad060d985a35676675eea9

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

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

nlp = Spacy::Language.new("en_core_web_sm")

sentence = "Credit and mortgage account holders must submit their requests"
doc = nlp.read(sentence)

headings = ["text", "pos", "dep", "head text"]
rows = []

doc.retokenize(doc[4].left_edge.i, doc[4].right_edge.i)

doc.each do |token|
  rows << [token.text, token.pos_, token.dep_, token.head.text]
end

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

# +-------------------------------------+------+-------+-----------+
# | text                                | pos  | dep   | head text |
# +-------------------------------------+------+-------+-----------+
# | Credit and mortgage account holders | NOUN | nsubj | submit    |
# | must                                | AUX  | aux   | submit    |
# | submit                              | VERB | ROOT  | submit    |
# | their                               | PRON | poss  | requests  |
# | requests                            | NOUN | dobj  | submit    |
# +-------------------------------------+------+-------+-----------+

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-spacy-0.1.3 examples/linguistic_features/retokenize_1.rb
ruby-spacy-0.1.2 examples/linguistic_features/retokenize_1.rb
ruby-spacy-0.1.1 examples/linguistic_features/retokenize_1.rb
ruby-spacy-0.1.0 examples/linguistic_features/retokenize_1.rb