Sha256: c360326c2b47ce2ce93ff23c2745c227fb1530404b46c0b2f3138fa13f5d88da
Contents?: true
Size: 558 Bytes
Versions: 1
Compression:
Stored size: 558 Bytes
Contents
# -*- coding: UTF-8 -*- require 'middleman-blog-similar/algorithm/word_frequency' class Middleman::Blog::Similar::Algorithm::WordFrequency::Mecab < ::Middleman::Blog::Similar::Algorithm::WordFrequency class CommandNotFound < StandardError; end def words res = [] IO.popen("mecab 2>/dev/null", 'r+') {|f| f.puts article.untagged_body f.puts article.title f.close_write while line = f.gets word, pos = line.split(/[\t\s]+/) res << word if pos && pos.start_with?('名詞') end } res end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
middleman-blog-similar-1.1.0 | lib/middleman-blog-similar/algorithm/word_frequency/mecab.rb |