å½¢æ ç´ è§£æã¨ã³ã¸ã³ MeCab 0.98pre3 éè¯ãã«ã
MeCab 0.98pre3 ã® Python ãã¤ã³ãã£ã³ã°ã Windows XP Pro, MinGW, Python 2.5.4 and Python 2.6.2 ã¨ããç°å¢ã§ã³ã³ãã¤ã«ãã¦ã¿ããæãã¦ã¿ãã
æ¹æ³ã¯æ¨å¹´11æã®ã形態素解析エンジン MeCab 0.97 とその Python バインディングを MinGW でビルドする - 銀月の符号ãã¨ã»ã¼å¤ããããéã㯠C:\python26\include, C:\Python26\libs ãç°å¢å¤æ° C_INCLUDE_PATH, LIBRARY_PATH ã«å ¥ãã¦ããªããã¨ãããã distutils(ã¤ã¾ã setup.py) ãç¨ãã¦ãã«ãããéã«ã¯ä¸è¦ã¨ãããã¨ãããã£ãã®ã§ã
åºæ¥ä¸ãã£ããã®
mecab-python の Windows 用バイナリ、ダウンロード
libmecab-1.dll
MinGW ã§ä½ã£ãlibmecab-1 ã©ã¤ãã©ãªã mecab-python ã¨ã»ããã§ä½¿ãã
使ãæ¹
ä¸è¨ã®ã»ãã libmecab-1.dll, MeCab.py, _MeCab.pyd, ipadic ããã£ã¬ã¯ããªï¼ã¹ãã¼ã¹ããã«ããã¤ãæåãå«ã¾ãªããã¨ï¼ã«ã¾ã¨ãããããã« mecabrc è¨å®ãã¡ã¤ã«ãã¤ããã mecabrc ã®ä¸èº«ã¯ç©ºã§ããããè¾æ¸ãæå®ããããã«ãã¦ããã¨å¾ã§æ¥½ã
dicdir = ipadic
ããã§æºåå®äºã Hello Mecab ããã°ã©ã ã¯ãã®ãããªæãã -r ãªãã·ã§ã³ã§ mecabrc ã®ãã¹ãæå®ããã MeCab ã¨ã®ããåãã¯ã¦ãã³ã¼ãæååã§ã¯ãªããè¾æ¸ã¨åãã¨ã³ã³ã¼ãã£ã³ã°ï¼ä»å㯠UTF-8ï¼ã«ç´ãããã¤ãåã§è¡ãã
>>> import MeCab >>> s = u'ãããããããããã®ãã¡' >>> tagger = MeCab.Tagger('-r mecabrc') >>> result = tagger.parse(s.encode('utf-8')) >>> result = result.decode('utf-8') >>> print result ããã åè©,ä¸è¬,*,*,*,*,ããã,ã¹ã¢ã¢,ã¹ã¢ã¢ ã å©è©,ä¿å©è©,*,*,*,*,ã,ã¢,㢠ãã åè©,ä¸è¬,*,*,*,*,ãã,ã¢ã¢,ã¢ã¢ ã å©è©,ä¿å©è©,*,*,*,*,ã,ã¢,㢠ãã åè©,ä¸è¬,*,*,*,*,ãã,ã¢ã¢,ã¢ã¢ ã® å©è©,é£ä½å,*,*,*,*,ã®,ã,ã ãã¡ åè©,éèªç«,å¯è©å¯è½,*,*,*,ãã¡,ã¦ã,ã¦ã EOS
mecabrc ã空ã§è¾æ¸ãæå®ãã¦ããªãå ´å㯠-d ãªãã·ã§ã³ãä»ãã¦è¾æ¸ãæå®ããããã«ããã°ããã
>>> tagger = MeCab.Tagger('-r mecabrc -d ipadic')
ãã詳ãã MeCab SWIG ãã¤ã³ãã£ã³ã°ã®èª¬æã¯æ¬å®¶ã® http://mecab.sourceforge.net/bindings.html ãåç §ã
å¯ç£ç©
mecab.exe
libmecab ãä½ã£ãéã«ãããã§ããã mecab.exe ã ãã欲ãã人ã¯ãããªããããéè¯ãã«ãã§ã¯ãªããMeCab 本家ã®ã¤ã³ã¹ãã¼ã©ã¼ããåå¾ãããã¨ãæ¨å¥¨ã