LoginSignup
3
2

More than 5 years have passed since last update.

ネガポジ判定を行うGemを使ってみた

Last updated at Posted at 2017-08-18

ネガポジ判定を行う必要性があったので、ruby gemを探してみたところ下記がみつかりました。
ネガポジ判定を行うGem作ってみた

install手順が、記載の内容から更新があったようなので、まとめてみます。

環境

  • MacBookAir
    • OSX 10.12.6

手順

  1. homebrewをinstall
  $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. 形態素解析エンジンをinstall
$ brew install mecab
$ brew install mecab-ipadic
  1. 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
  1. 事前に必要なgemをinstall
$ gem install natto
$ gem install bundler
  1. 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
  1. サンプルスクリプトを用意
test_negapoji.rb
# coding: utf-8
require "negapoji"
while text = STDIN.gets
  p Negapoji.judge(text) if text.is_a?(String)
end
  1. サンプルスクリプトを実行
$ ruby test_negapoji.rb
おはようございます。
"positive"
痛いです
"negative"

以上

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2