Giter Club home page Giter Club logo

naivebayes's Introduction

ナイーブベイズで中二病判定

What's this?

中二病なセリフを学習し、入力されたセリフが中二病かどうかを判定してくれるアプリケーションです。

つかいかた

$cd src
$python3 classifier.py
Training...
Training...
input =>僕に勝つのはまだ早いよ
中二病

input =>打ち返せない球はないよ
中二病

input =>あなたは中二病ですか?
中二病ではない

input =>俺は中二病なんぞではない!
中二病

input =>exit

実行すると学習結果がmodel.jsonというファイルに出力されます。

ファイル名を引数として渡すと、保存された学習結果を利用することができます。

$python3 classifier.py model.json

環境設定

パッケージのインストール

Twitter APIとbeautifulsoupをインストールします。

sudo pip3 install twitter beautifulsoup4

設定ファイルの記述

  1. Twitterの開発者用ページにアクセスしてTwitter APIのAccess Tokenを発行してください。
  2. Yahoo デベロッパーネットワークにアクセスして形態素解析APIを利用するためのアプリケーションIDを発行してください。
  3. 取得したAccess TokenとアプリケーションIDをsrc/settings.cfgに書き込みます。
  4. 中二病なツイートをしているアカウントをいくつか探し、そのIDをsrc/settings.cfgのtrue_accountsに設定します。
  5. 中二病でないツイートをしているアカウントをfalse_accountsに設定します。
[YAHOO]
# YahooのアプリケーションID
appid = 'your yahoo app id'

[TWITTER]
consumer_key = 'your consumer key'
consumer_secret = 'your consumer secret'

token = 'your access token'
token_secret = 'your access token secret'

true_target_name = '中二病'
# 中二病なセリフをツイートしているアカウントのID
true_accounts = ['true_account_id1','true_account_id2']

false_target_name = '中二病ではない'
# 普通のアカウントのID (自分のアカウントなど自由に設定してください)
false_accounts = ['false_account_id1','false_account_id2']

以上で設定は終了です。

naivebayes's People

Contributors

ishitatakeshi avatar

Watchers

James Cloos avatar kurozumi avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.