Sha256: 8d50ee17cea74e96844b098c0595b88e3ed1ab2752ab72401bc7c73f168ea26f

Contents?: true

Size: 789 Bytes

Versions: 2

Compression:

Stored size: 789 Bytes

Contents

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

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

doc = nlp.read("自動運転車は保険責任を製造者に転嫁する。")

headings = ["text", "root.text", "root.dep", "root.head.text"]
rows = []

doc.noun_chunks.each do |chunk|
  rows << [chunk.text, chunk.root.text, chunk.root.dep, chunk.root.head.text]
end

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

# +------------+-----------+----------+----------------+
# | text       | root.text | root.dep | root.head.text |
# +------------+-----------+----------+----------------+
# | 自動運転車 | 車        | nsubj    | 転嫁           |
# | 製造者     | 者        | obl      | 転嫁           |
# +------------+-----------+----------+----------------+

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-spacy-0.1.4.1 examples/japanese/noun_chunks.rb
ruby-spacy-0.1.4 examples/japanese/noun_chunks.rb