Sha256: 369c863789727b80bc47ed950be01b1e650253703cffddfb290ed376a785d6c1

Contents?: true

Size: 864 Bytes

Versions: 2

Compression:

Stored size: 864 Bytes

Contents

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

nlp = Spacy::Language.new("en_core_web_sm")
doc = nlp.read("I love coffee")

headings = ["text", "shape", "prefix", "suffix", "is_alpha", "is_digit"]
rows = []

doc.each do |word|
  lexeme = nlp.vocab(word.text)
  rows << [lexeme.text, lexeme.shape, lexeme.prefix, lexeme.suffix, lexeme.is_alpha, lexeme.is_digit]
end

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

# +--------+-------+--------+--------+----------+----------+
# | text   | shape | prefix | suffix | is_alpha | is_digit |
# +--------+-------+--------+--------+----------+----------+
# | I      | X     | I      | I      | true     | false    |
# | love   | xxxx  | l      | ove    | true     | false    |
# | coffee | xxxx  | c      | fee    | true     | false    |
# +--------+-------+--------+--------+----------+----------+

Version data entries

2 entries across 2 versions & 1 rubygems

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