Sha256: 728ab9bc25ed457171a997252ea91c2c558fc6ee45f9783373eb00a7ccb8aa0f

Contents?: true

Size: 952 Bytes

Versions: 2

Compression:

Stored size: 952 Bytes

Contents

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

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

sentence = "San Francisco considers banning sidewalk delivery robots" 
doc = nlp.read(sentence)

headings = ["text", "ent_iob", "ent_iob_", "ent_type_"]
rows = []

doc.each do |ent|
  rows << [ent.text, ent.ent_iob, ent.ent_iob_, ent.ent_type]
end

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

# +-----------+---------+----------+-----------+
# | text      | ent_iob | ent_iob_ | ent_type_ |
# +-----------+---------+----------+-----------+
# | San       | 3       | B        | GPE       |
# | Francisco | 1       | I        | GPE       |
# | considers | 2       | O        |           |
# | banning   | 2       | O        |           |
# | sidewalk  | 2       | O        |           |
# | delivery  | 2       | O        |           |
# | robots    | 2       | O        |           |
# +-----------+---------+----------+-----------+

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-spacy-0.1.4.1 examples/linguistic_features/entity_annotations_and_labels.rb
ruby-spacy-0.1.4 examples/linguistic_features/entity_annotations_and_labels.rb