Sha256: b810273c0b0e012c50bd5b3573683bb5900a21f45da497ba708c7804f267bf9d

Contents?: true

Size: 363 Bytes

Versions: 1

Compression:

Stored size: 363 Bytes

Contents

# frozen_string_literal: true

require 'natto'
require 'to_nouns/version'

module ToNouns
  refine String do
    def to_nouns(general: false)
      append = general ? ',一般' : nil
      nouns  = []

      Natto::MeCab.new.parse(to_s) do |n|
        next unless n.feature =~ /名詞#{append}/
        nouns << n.surface
      end

      nouns
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
to_nouns-0.2.0 lib/to_nouns.rb