Sha256: 04dfa8e5f0a9363a636235c54349d4eda078ddbd799e3d07b2c3275ca515bdc4

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

# frozen_string_literal: true

# add path to ruby-spacy lib to load path
$LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))

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

nlp = Spacy::Language.new("en_core_web_lg")
doc = nlp.read("dog cat banana afskfsd")

headings = %w[text has_vector vector_norm is_oov]
rows = []

doc.each do |token|
  rows << [token.text, token.has_vector, token.vector_norm, token.is_oov]
end

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

# +---------+------------+-------------------+--------+
# | text    | has_vector | vector_norm       | is_oov |
# +---------+------------+-------------------+--------+
# | dog     | true       | 7.033673286437988 | false  |
# | cat     | true       | 6.680818557739258 | false  |
# | banana  | true       | 6.700014114379883 | false  |
# | afskfsd | false      | 0.0               | true   |
# +---------+------------+-------------------+--------+

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-spacy-0.2.3 examples/get_started/word_vectors.rb
ruby-spacy-0.2.2 examples/get_started/word_vectors.rb