Sha256: b5a6a123ff6cb7a6bb211564cd3084e2412c13682b73651a6718d525900fd312

Contents?: true

Size: 757 Bytes

Versions: 4

Compression:

Stored size: 757 Bytes

Contents

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

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

sentence = "任天堂は1983年にファミコンを14,800円で発売した。"
doc = nlp.read(sentence)

headings = ["text", "start", "end", "label"]
rows = []

doc.ents.each do |ent|
  rows << [ent.text, ent.start_char, ent.end_char, ent.label_]
end

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

# +------------+-------+-----+---------+
# | text       | start | end | label   |
# +------------+-------+-----+---------+
# | 任天堂     | 0     | 3   | ORG     |
# | 1983年     | 4     | 9   | DATE    |
# | ファミコン | 10    | 15  | PRODUCT |
# | 14,800円   | 16    | 23  | MONEY   |
# +------------+-------+-----+---------+

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-spacy-0.1.3 examples/japanese/named_entity_recognition.rb
ruby-spacy-0.1.2 examples/japanese/named_entity_recognition.rb
ruby-spacy-0.1.1 examples/japanese/named_entity_recognition.rb
ruby-spacy-0.1.0 examples/japanese/named_entity_recognition.rb