mecabのユーザー辞書をつくってみる
mecabを社内でいじることがあったので、備忘録
mecabのユーザー辞書をつくる
なぜか「せなか」とう単語がmecabになかったので、辞書を更新する
$ echo "おやじのせなか" | mecab おやじ 名詞,一般,*,*,*,*,おやじ,オヤジ,オヤジ の 助詞,格助詞,一般,*,*,*,の,ノ,ノ せ 動詞,自立,*,*,サ変・スル,未然ヌ接続,する,セ,セ なか 名詞,非自立,副詞可能,*,*,*,なか,ナカ,ナカ
ディレクトリに移動
$ cd /home/foo/bar
追加したい言葉をCSVに追記
$ echo "せなか,1285,1285,5965,名詞,一般,*,*,*,*,背中,セナカ,セナカ" > user.csv
辞書を作成(コンパイル)
$ /home/foo/bar/libexec/mecab/mecab-dict-index -d /home/foo/bar -u user.dic -f utf-8 -t utf-8 user.csv reading user.csv ... 1 emitting double-array: 100% |###########################################| done!
- mecabrcを修正(コメントをはずす)
$ vim /usr/local/lib/mecab/dic/ipadic/dicrc userdic = /home/foo/bar/user.dic
$ echo "おやじのせなか" | mecab おやじ 名詞,一般,,,,,おやじ,オヤジ,オヤジ の 助詞,連体化,,,,,の,ノ,ノ せなか 名詞,一般,,,,,背中,セナカ,セナカ
参考
Embulkを使ってみた
PFIセミナーの担当だったので、いまはやりのEmbulkについて調べました。 そのときのSlideはこちら
Windows7 + Vagrant 1.6.5+ virtualbox 4.3.20の設定は動かない
発生した問題
Vagrant upを実行すると以下のようなメッセージが表示される。
C:\Users\abc>vagrant up Bringing machine 'default' up with 'virtualbox' provider... [default] Box 'precis64' was not found. Fetching box from specified URL for the provider 'virtualbox'. Note that if the URL does not have a box for this provider, you should interrupt Vagrant now and add the box yourself. Otherwise Vagrant will attempt to download the full box prior to discovering this error. Downloading or copying the box... Extracting box...ate: 922k/s, Estimated time remaining: --:--:--) Successfully added box 'precis64' with provider 'virtualbox'! [default] Importing base box 'precis64'... [default] Matching MAC address for NAT networking... [default] Setting the name of the VM... [default] Clearing any previously set forwarded ports... [default] Creating shared folders metadata... [default] Clearing any previously set network interfaces... [default] Preparing network interfaces based on configuration... [default] Forwarding ports... [default] -- 22 => 2222 (adapter 1) [default] Booting VM... [default] Waiting for machine to boot. This may take a few minutes... The guest machine entered an invalid state while waiting for it to boot. Valid states are 'starting, running'. The machine is in the 'poweroff' state. Please verify everything is configured properly and try again. If the provider you're using has a GUI that comes with it, it is often helpful to open that and watch the machine, since the GUI often has more helpful error messages than Vagrant can retrieve. For example, if you're using VirtualBox, run \`vagrant up\` while the VirtualBox GUI is open.
(vagrantから見た)プロバイダ(本件の場合はVirtualBox)にGUIがある場合、 そちらで確認した方がより有益な情報を確認できますよ。 ...といった内容のメッセージが表示される。解決方法はバージョンを変えないといけない。。 つらい
Ruby 2.0.0とWindows7 64bitとRails4.1の相性が悪すぎるのか。。
最近Railsを勉強しているのだが、セットアップでつまってしまったので備忘録。。。。
環境
起こった現象
セットアップ時
WindowsではDevKitがないとrailsのインストールができない。。。
下記からダウンロード Downloads
Pathが通ってるrubのフォルダに展開する
set PATH=D:\ruby\ruby200\bin;%PATH% start "ruby 2.0.0 x64" "%SystemRoot%\System64\cmd.exe"
ruby>ruby -v ruby 2.0.0p0 (2013-02-24) [x64-mingw32] DevKit の設定 D\ruby>cd DevKit472 D:\ruby\DevKit472>ruby dk.rb init D:\ruby\DevKit472\config.yml を編集 --- - D:/ruby/ruby200 を追加 D:\ruby\DevKit472>ruby dk.rb install
railsプロジェクト作成時
Railsプロジェクトを立ち上げてみる
C:\Users\hideto.masuoka\repos\rails\data\railbook>rails new railbook DL is deprecated, please use Fiddle Using rake 10.3.2 Using i18n 0.6.9 Using json 1.8.1 Using minitest 5.3.5 Using thread_safe 0.3.4 Using tzinfo 1.2.1 Using activesupport 4.1.1 Using builder 3.2.2 Using erubis 2.7.0 Using actionview 4.1.1 Using rack 1.5.2 Using rack-test 0.6.2 Using actionpack 4.1.1 Using mime-types 1.25.1 Using polyglot 0.3.5 Using treetop 1.4.15 Using mail 2.5.4 Using actionmailer 4.1.1 Using activemodel 4.1.1 Using arel 5.0.1.20140414130214 Using activerecord 4.1.1 Using coffee-script-source 1.7.0 Using execjs 2.2.1 Using coffee-script 2.2.0 Using thor 0.19.1 Using railties 4.1.1 Using coffee-rails 4.0.1 Using hike 1.2.3 Using multi_json 1.10.1 Using jbuilder 2.1.1 Using jquery-rails 3.1.1 Using bundler 1.6.3 Using tilt 1.4.1 Using sprockets 2.11.0 Using sprockets-rails 2.1.3 Using rails 4.1.1 Using rdoc 4.1.1 Using sass 3.2.19 Using sass-rails 4.0.3 Using sdoc 0.4.0 Using sqlite3 1.3.9 Using turbolinks 2.2.2 Using uglifier 2.5.1 Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed.
うまくいったのでrails serverを立ち上げようといたら。。。
C:\Users\hideto.masuoka\repos\rails\data\railbook>rails server => Booting WEBrick => Rails 4.1.8 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) => Ctrl-C to shutdown server Exiting C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:182:in `rescue in create_default_data_source': No source of timezone d ta could be found. (TZInfo::DataSourceNotFound) Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error. from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:179:in `create_default_data_source' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:40:in `block in get' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:39:in `synchronize' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:39:in `get' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/timezone.rb:629:in `data_source' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/timezone.rb:92:in `get' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/timezone_proxy.rb:67:in `real_timezone' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/timezone_proxy.rb:30:in `period_for_utc' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/timezone.rb:549:in `current_period' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/core_ext/object/try.rb:45:in `public_send' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/core_ext/object/try.rb:45:in `try' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/values/time_zone.rb:223:in `utc_offset' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/values/time_zone.rb:396:in `block in []' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/values/time_zone.rb:396:in `tap' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/values/time_zone.rb:396:in `[]' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/core_ext/time/zones.rb:60:in `find_zone!' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/railtie.rb:20:in `block in <class:Railtie>' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `instance_exec' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `run' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:55:in `block in run_initializers' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in `each' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:54:in `run_initializers' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/application.rb:300:in `initialize!' from C:/Users/hideto.masuoka/repos/rails/data/railbook/config/environment.rb:5:in `<top (required)>' from C:/Users/hideto.masuoka/repos/rails/data/railbook/config.ru:3:in `require' from C:/Users/hideto.masuoka/repos/rails/data/railbook/config.ru:3:in `block in <main>' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize' from C:/Users/hideto.masuoka/repos/rails/data/railbook/config.ru:in `new' from C:/Users/hideto.masuoka/repos/rails/data/railbook/config.ru:in `<main>' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/server.rb:50:in `app' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/server.rb:130:in `log_to_stdout' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/server.rb:67:in `start' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:81:in `block in server' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `tap' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `server' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>' from bin/rails:4:in `require' from bin/rails:4:in `<main>'
原因を調べても解決方法が出てこない、、 つらい。。。
参考
Jubatusハッカソンを見に行った。
Jubatusハッカソンのお手伝いをしてきました。
(お手伝いと行っても会場のお片付けぐらいしかしてませんが....)
Jubatusハッカソンとは
Jubatusハッカソンやります!丸一日かけてJubatusで何か作ってプレゼンして頂きます。放置してたデータ活用アイデア・デモ案、この機会に具現化しませんか? http://t.co/Skl7kFErty #jubatus_hackathon
— Jubatus (@JubatusOfficial) 2014, 9月 2
こんなイベントです。
賞品は....豪華!!! 1位 GoPro ウェアラブルカメラ HERO3 ホワイトエディション 2位 Leap Motion 小型モーションコントローラー 3位 Google Chromecas
最終発表
気になったり、スライドがあがっているものをまとめてみました。
和布蕪
相撲をもっと楽しむためのサービスをつくる
どんなサービス?
- お気に入りの力士と似た力士を探す
- Jubarecommenderを使う
- 面白い取り組みを探す
- jubaanomalyを使って異常度を計算する
予想通り(?)舞の海がめっちゃ異常値が高かったw
チームでやってるだけあって完成度の高いプレゼンテーションとサービスクオリティでしたー
ぜひ触ってみたいなと思いました。
草々
aoi_sora_siroi_tsuki (@aoi_sora_siroi_) | Twitterさん
Wikipediaから類似植物図鑑のWebサービスを構築して公開。 Jumbotron Template for Bootstrap
jubatus以前に、EC2もpythonもわからないのでやばい・・>_< 勉強にはなるなぁ・・。アプリまで行かない・・orz とりあえずEC2だと、python webはboto使っておけばいいのかなぁ・・。
— aoi_sora_siroi_tsuki (@aoi_sora_siroi_) 2014, 10月 3
深夜1時にこんなツイートをしていたのに、ちゃんとサービスまで持って行っているところがすごい..
大杉さん
トランプを画像認識する。Google Glassを使って、ポーカーの手を最適化することを想定している。
9とか10を認識するのは難しい。グレースケールで認識しているので、色の判別を活かせてないなど、まだまだ改善してもっとよくする知見が得られた。
dera
jubarecommenderを使ってtweetからniconicoやpixivで趣味嗜好が似てるユーザーをピックアップ。 niconicoやpixivやらないからはっきりわからないが、結果を見る限りなんとなく似ている気がした。
大友翔一(@GeoJackass)
Jubatus Hackathon by Otomo Shoichi
釣果から特徴量をとり、どういう傾向があるかを調べた。
新しい知見が得られたらしい(釣りに興味がないので、知見が理解できず...)
ijust3
niconicoへの投稿動画のトレンド検知(@Jubatus hackathon 2014/10/03)
niconico動画で最近盛り上がったタグを、最近の動画と過去も含めた動画を判別するJubaclassifierモデルのjubadump結果で求める。1回しか使われてないタグのスコアが高くなりすぎる傾向あったがそれなりの結果
Paper
Connpass というイベント支援サイトのイベント情報をレコメンドするサイトです。あとで読むサービスの Pocket のデータを元に、レコメンドするイベントを決めるので、本当に興味があるイベントのみをレコメンドする仕組み
#jubatus_hackathon Paperさんのサービスを使って私のPocket登録記事からレコメンドされた勉強会! クラウドでJavaでGithubでBitcoinでほげほげ、な感じ? pic.twitter.com/kW4ifoMjXw
— ヒド ショウヘイ (@sla) 2014, 10月 4
Jubatusハッカソンに参加して、イベントのレコメンデーションを作ってみた。 - よしだのブログ
なかなか面白そうなサービスになりそうな気がした
びア部
似てそうで似てないものをレコメンドする。
たしかに新たな知見が得られてよさそうだと思った
コアプライス
ECレコメンドの仕組みの中にJubatusを使う例。機械学習がおまかせで、あとは前処理の工夫に集中できる!!とおっしゃっていた。
Jubatus Hackathon #1 // Speaker Deck
すぐに使えそうな例だなとー思った。
nushio
@nusioさん
アセンブラ高速化のための並列実行優先度を求めるためにエミュレータ実行結果をJubatusで回帰、モデルをjubadumpして重みの降順ソートを優先度にしたら逆問題が解けたという話。 たった2日で論文がかける内容をつくれる@nusioさすがです
ところてん(仮)
フルスタックグロースデータサイエンティスト@tokorotenさんが実データ実験。ECサイトのある最適化にJubatusを使って現行のscikit-learn決定木モデルと比較、データが多ければすぐいけそう
DAISUKE AMANO on Twitter: "優勝!本番データに突っ込んでmongo殺したのがよかった!笑 #jubatus_hackathon"
本番環境のMongoを殺すなど果敢にトライされていたのですばらし
感想
全体としてrecommenderが多い印象だった。 たしかに問題設定が明確じゃないとrecommenderが使いやすいですよね...
ただ問題設定が明確なチームの発表がすごくわかりやすかった!!
Postgre SQLを使ってみる(ユーザー作成)
前回インストールしたので、今回は色々使ってみる
scientific linux6.5にyumでPostgre SQLをいれてみる - Anything can happen
SQLというよりDBAよりのことを書いてみる
ユーザー作成
- まずはロールを作成
/usr/pgsql-9.3/bin/createuser --superuser --createrole --password dba
- 次にDBを作成
/usr/pgsql-9.3/bin/createdb --owner=dba --no-password dba
これでDBAユーザーのデータベースができました。
引数一覧
オプション | 説明 |
---|---|
username | 作成するPostgreSQLユーザの名前を指定します。この名前は、そのPostgreSQLインストレーションの中で一意でなければなりません。 |
-s or --superuser | スーパーユーザになります。 |
-s or --superuser | スーパーユーザになりません。 (デフォルト) |
-d or --createdb | 新しいユーザに対してデータベースの作成を許可します。 |
-D or --no-createdb | 新しいユーザに対してデータベースの作成を禁止します。 これがデフォルトです。 |
-r or --createrole | 新しいユーザに対して新しいロールの作成を許可します。(つまり、このユーザはCREATEROLE権限を持つことになります。) |
-R or --no-createrole | 新しいユーザに対して新しいロールの作成を禁止します。 これがデフォルトです。 |
-l or --login | 新しいユーザに対してログインを許可します。(つまり、このユーザ名をセッション起動時のユーザ識別子として使用することができます。) これがデフォルトです。 |
-L or --no-login | 新しいユーザに対してログインを禁止します。(ログイン権限を持たないロールはデータベース権限管理という面で有意です。) |
-i or --inherit | 新しいロールは自動的にそのロールがメンバであるロールの権限を継承します。 これがデフォルトです。 |
-I or --no-inherit | 新しいロールは自動的にそのロールがメンバであるロールの権限を継承しません。 |
-c number or --connection-limit number | 新しいユーザの最大接続数を設定します。 デフォルトは無制限です。 |
scientific linux6.5にyumでPostgre SQLをいれてみる
Postgre SQLをインストールする機会があったので、手順をまとめる
環境
- scientific linux 6.5
手順
1.yumで何がはいるか確認
# yum list | grep postgresql
2.postgresqlのパッケージをインストールする
# yum -y install postgresql-server
3.postgresqlの開発版パッケージもインストールする
# yum -y install postgresql-devel
4.rpmをインストールする
# yum -y localinstall http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-sl93-9.3-1.noarch.rpm
とりあえずこれでインストールはdone
パッケージの一覧
パッケージ名 | 主に格納しているもの |
---|---|
postgresql-libs | libpqなどのPostgreSQLのライブラリ群。PostgreSQL以外のパッケージが必要とすることもあります。 |
postgresql | psqlやpg_dumpなどのPostgreSQLのクライアントユーティリティ |
postgresql-server | initdbやpg_ctlなどのPostgreSQLのサーバユーティリティ。DBMSサーバとして必要な機能はこれに含まれています。 |
postgresql-contrib | pgbenchやpg_statstatementなどのPostgreSQLのcontribモジュール。 |
postgresql-devel | PostgreSQLのヘッダやpg_configなどの開発用モジュール。 |
postgresql-doc | PostgreSQLのドキュメント。 |
postgresql-test | PostgreSQLのリグレッションテスト用モジュール。 |
つぎは、ユーザー作成等々