<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>さくらたんどっとびーず &#187; MeCab</title>
	<atom:link href="http://sakuratan.biz/archives/tag/mecab/feed" rel="self" type="application/rss+xml" />
	<link>http://sakuratan.biz</link>
	<description>モロモロ工事中です</description>
	<lastBuildDate>Sun, 25 Jun 2023 12:51:51 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>さくらインターネットスタンダードプランで UTF-8 の MeCab を使う際のメモ</title>
		<link>http://sakuratan.biz/archives/1349</link>
		<comments>http://sakuratan.biz/archives/1349#comments</comments>
		<pubDate>Sun, 25 Oct 2009 10:31:49 +0000</pubDate>
		<dc:creator>さくら</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[ウェブアプリ]]></category>
		<category><![CDATA[MeCab]]></category>
		<category><![CDATA[さくらインターネット]]></category>

		<guid isPermaLink="false">http://sakuratan.biz/?p=1349</guid>
		<description><![CDATA[最近ちーと忙しいもので、ブログの間隔空ちゃってます。サーセン＞＜ あんまりあいだ空けるのもアレなので、今日はさくらインターネットのスタンダード鯖で、MeCab を UTF-8 で使う方法を簡単にご紹介。 まず MeCab は形態素解析のライブラリです。本家サイトはこちら。 MeCab: Yet Another Part-of-Speech and Morphological Analyzer さく... <div style="margin-top:1ex"><a href="http://sakuratan.biz/archives/1349">(続きを読む)</a></div>]]></description>
			<content:encoded><![CDATA[<p>最近ちーと忙しいもので、ブログの間隔空ちゃってます。サーセン＞＜</p>
<p>あんまりあいだ空けるのもアレなので、今日はさくらインターネットのスタンダード鯖で、MeCab を UTF-8 で使う方法を簡単にご紹介。</p>
<p>まず MeCab は形態素解析のライブラリです。本家サイトはこちら。</p>
<blockquote><p>
<a href="http://mecab.sourceforge.net/">MeCab: Yet Another Part-of-Speech and Morphological Analyzer</a>
</p></blockquote>
<p>さくらインターネットのサーバには元から MeCab がインストールされてますので、単に使うだけならそのままでおkです。ただ EUC-JP 版の辞書がインスコされてますので、そのまま UTF-8 なウェブアプリで使用すると<a href="http://www.atmarkit.co.jp/fjava/rensai3/mojibake02/mojibake02.html">〜問題</a>が発生します。今日ご紹介するのはそれを回避する方法です。</p>
<p>回避方法は簡単で、UTF-8 な辞書ファイルを別にインスコするだけです。以下、具体的なやり方。</p>
<ol>
<li><b>辞書のアーカイブをサーバにアップロード</b><br />
<a href="http://mecab.sourceforge.net/#download">MeCab のダウンロードページ</a> から、IPA 辞書の最新版をダウンロードして、サーバにうpします。</li>
<li><b>アーカイブを展開してインスコ</b><br />
以下のコマンドをおもむろに打ち込み、UTF-8 の辞書を $HOME/lib/mecab/dic/ipadic-utf8 にインスコします。インスコ先のパスは適当に変えてください。</p>
<pre>% tar xvzf mecab-ipadic-2.7.0-20070610.tar.gz
% cd mecab-ipadic-2.7.0-20070610
% ./configure --with-charset=utf8 --with-dicdir=$HOME/lib/mecab/dic/ipadic-utf8
% make
% make install</pre>
</li>
<li><b>MeCab を動かす</b><br />
コマンドラインから MeCab を動かす際は、-d オプションで辞書のディレクトリを指定します。</p>
<pre>% mecab -d ~/lib/mecab/dic/ipadic-utf8 utf8.txt
あ      フィラー,*,*,*,*,*,あ,ア,ア
ああ    感動詞,*,*,*,*,*,ああ,アア,アー
EOS</pre>
<p>プログラムから使用する場合も基本的には同じです。以下は Python バインディングでの使用例。</p>
<pre>import os
import MeCab
dicdir = os.path.expanduser('~/lib/mecab/dic/ipadic-utf8')
m = MeCab.Tagger ("-Ochasen -d%s" % dicdir)
print m.parse ("今日もしないとね")</pre>
</li>
</ol>
<p><img src="http://sakuratan.biz/blog/wp-content/plugins/sakura-icons/icon2.png" width="160" height="160" border="0" style="border:0;float:left" /><br />
ということで本日はこの辺にて。<br />
ではでは☆<br clear="left" /></p>
]]></content:encoded>
			<wfw:commentRss>http://sakuratan.biz/archives/1349/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
