ネガポジ判定を行う必要性があったので、ruby gemを探してみたところ下記がみつかりました。
ネガポジ判定を行うGem作ってみた
install手順が、記載の内容から更新があったようなので、まとめてみます。
環境
- MacBookAir
- OSX 10.12.6
手順
- homebrewをinstall
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- 形態素解析エンジンをinstall
$ brew install mecab
$ brew install mecab-ipadic
- rbenvをinstallして、最新versionのrubyをinstall(systemに元々はいっているruby2.0.0でも動くだろうけど、せっかくなので))
$ brew update
$ brew install rbenv
$ rbenv init
$ rbenv install -l
$ rbenv install 2.4.1
$ rbenv versions
$ rbenv global 2.4.1
$ ruby -v
- 事前に必要なgemをinstall
$ gem install natto
$ gem install bundler
- negapoji gemをinstall
$ git clone https://github.com/hatt0519/negapoji.git
$ cd negapoji
$ bundle install
$ gem build negapoji.gemspec
$ gem install negapoji
Successfully installed negapoji-0.1.0
Parsing documentation for negapoji-0.1.0
Done installing documentation for negapoji after 0 seconds
1 gem installed
- サンプルスクリプトを用意
test_negapoji.rb
# coding: utf-8
require "negapoji"
while text = STDIN.gets
p Negapoji.judge(text) if text.is_a?(String)
end
- サンプルスクリプトを実行
$ ruby test_negapoji.rb
おはようございます。
"positive"
痛いです
"negative"
以上