Sha256: 0020f3b27930b7daa458171ed27b19b7fcff582b7e717d18a49e01cdd7222111

Contents?: true

Size: 474 Bytes

Versions: 1

Compression:

Stored size: 474 Bytes

Contents

require 'natto'

module Middleman
  module Blog
    module Similar
      module Tagger
        class Mecab
          def call(article)
            Natto::MeCab.new.parse(article.body.gsub(%r{</?[^>]+>}, ''))
                        .split("\n")
                        .map { |l| l.split("\t") }
                        .select { |l| l[1] && l[1].start_with?('名詞,一般') }
                        .map { |l| l[0] }
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-blog-similar-2.0.1 lib/middleman-blog-similar/tagger/mecab.rb