mecab

 単語リストの複合を分解

$ cat food_base_word_mecab.rb require 'MeCab' mecab=MeCab::Tagger.new() f=open("food_base_more_than10.txt") f.each{|i| word=i.split(",")[2] count=i.split(",")[5] #puts str; #str="すもももものもものうち." # str="ドライカレー" node=mecab.par…

mecabをpythonから使う

curl -O https://mecab.googlecode.com/files/mecab-python-0.98.tar.gz gzip -d mecab-python-0.98.tar.gz tar -xvf mecab-python-0.98.tar.gz

文章から連続する名詞をひとまとめにした形態素解析・複合語の形態素解析

名詞をひとまとめにした形態素解析 mecab 一番したのsurface版を使う。 featureだと未知語を無視する問題がある.複合語について http://kw.kait.jp/opac/kkb-022-021._;jsessionid=227623429A2954BED6FEE927770BEEC4?key=DNHDTDhttp://www.nihongokyoshi.co…

mecabとrubyである単語の前後にある単語を取得

以下でなく連続ワード対応版を使う:: (1)node.feature.split(",")[6].encode("UTF-8","UTF-8") -> node.surfece featureだと未知語がでなくなる問題がある。 (2)複合語版を使うべき。 http://d.hatena.ne.jp/arupaka-_-arupaka/20150511/1431327544m…

mecabとrubyで形態素解析して文章を単語に分割してリストにつめる[基本]

mecabとrubyで形態素解析して文章を単語に分割してリストにつめる[基本] # -*- coding: Utf-8 -*- require 'MeCab' def get_feature_from_text(text1,mecab) list1=[] node=mecab.parseToNode(text1) while node.next != nil do node=node.next list1.push(n…

rubyで食べたいの前にくるの単語を抽出

すごく原始的だけど。。 rubyで食べたいの前にくるの単語を抽出 # -*- coding: Utf-8 -*- require 'MeCab' m=MeCab::Tagger.new() text1="おはよう.うさぎを食べたい" node=m.parseToNode(text1) # node=node.next #node=node.next.next strold1="" strold2=…

ruby-mecabでワードカウント

ruby-mecabのインストールと説明は, http://d.hatena.ne.jp/arupaka-_-arupaka/20140812 # -*- coding: utf-8 -*- require 'MeCab' def word_counts(text,mecab) parsed=mecab.parseToNode(text) word_list=Hash::new(); word_list.default=0; while parsed…