python-mecab: やはりmecabはmake installしたほうがよいのではないか

deb1:/var/lib/mecab/dic/utf8# apt-cache search ctypes
emacs-goodies-el – Miscellaneous add-ons for Emacs
python-ctypes – Python package to create and manipulate C data types
python-musicbrainz – Second generation incarnation of the CD Index – python bindings
python2.5 – An interactive high-level object-oriented language (version 2.5)

 

deb1:/var/lib/mecab/dic/utf8# apt-get install python-ctypes
Reading package lists… Done
Building dependency tree… Done
The following NEW packages will be installed:
  python-ctypes
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 196kB of archives.
After unpacking 819kB of additional disk space will be used.
Get:1 http://cdn.debian.or.jp etch/main python-ctypes 1.0.0-1.1 [196kB]
Fetched 196kB in 0s (260kB/s)
Selecting previously deselected package python-ctypes.
(Reading database … 46088 files and directories currently installed.)
Unpacking python-ctypes (from …/python-ctypes_1.0.0-1.1_i386.deb) …
Setting up python-ctypes (1.0.0-1.1) …
INFO: using unsupported version ‘/usr/bin/python2.5’

 

Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> dir(cdll)
[‘LoadLibrary’, ‘__class__’, ‘__delattr__’, ‘__dict__’, ‘__doc__’, ‘__getattr__’, ‘__getattribute__’, ‘__getitem__’, ‘__hash__’, ‘__init__’, ‘__module__’, ‘__new__’, ‘__reduce__’, ‘__reduce_ex__’, ‘__repr__’, ‘__setattr__’, ‘__str__’, ‘__weakref__’, ‘_dlltype’]

 

ctypesは Windowsで使うみたい。

 

deb1:/usr/local/src# wget http://downloads.sourceforge.net/mecab/mecab-python-0.97.tar.gz?modtime=1202034647&big_mirror=0
[1] 31215
deb1:/usr/local/src# –05:32:13–  http://downloads.sourceforge.net/mecab/mecab-python-0.97.tar.gz?modtime=1202034647
           => `mecab-python-0.97.tar.gz?modtime=1202034647′
Resolving downloads.sourceforge.net… 66.35.250.203
Connecting to downloads.sourceforge.net|66.35.250.203|:80… connected.
HTTP request sent, awaiting response… 302 Found
Location: http://jaist.dl.sourceforge.net/sourceforge/mecab/mecab-python-0.97.tar.gz [following]
–05:32:13–  http://jaist.dl.sourceforge.net/sourceforge/mecab/mecab-python-0.97.tar.gz
           => `mecab-python-0.97.tar.gz’
Resolving jaist.dl.sourceforge.net… 150.65.7.130
Connecting to jaist.dl.sourceforge.net|150.65.7.130|:80… connected.
HTTP request sent, awaiting response… 302 Found
Location: http://prdownloads.sourceforge.net/mecab/mecab-python-0.97.tar.gz?download&failedmirror=jaist.dl.sourceforge.net [following]
–05:32:14–  http://prdownloads.sourceforge.net/mecab/mecab-python-0.97.tar.gz?download&failedmirror=jaist.dl.sourceforge.net
           => `mecab-python-0.97.tar.gz?download&failedmirror=jaist.dl.sourceforge.net’
Resolving prdownloads.sourceforge.net… 66.35.250.217
Connecting to prdownloads.sourceforge.net|66.35.250.217|:80… connected.
HTTP request sent, awaiting response… 301 Moved Permanently
Location: http://downloads.sourceforge.net/mecab/mecab-python-0.97.tar.gz?download&failedmirror=jaist.dl.sourceforge.net [following]
–05:32:14–  http://downloads.sourceforge.net/mecab/mecab-python-0.97.tar.gz?download&failedmirror=jaist.dl.sourceforge.net
           => `mecab-python-0.97.tar.gz?download&failedmirror=jaist.dl.sourceforge.net’
Reusing existing connection to downloads.sourceforge.net:80.
HTTP request sent, awaiting response… 302 Found
Location: http://superb-east.dl.sourceforge.net/sourceforge/mecab/mecab-python-0.97.tar.gz [following]
–05:32:14–  http://superb-east.dl.sourceforge.net/sourceforge/mecab/mecab-python-0.97.tar.gz
           => `mecab-python-0.97.tar.gz’
Resolving superb-east.dl.sourceforge.net… 209.160.66.130
Connecting to superb-east.dl.sourceforge.net|209.160.66.130|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 53,415 (52K) [application/x-gzip]

100%[=============================================>] 53,415        40.63K/s

05:32:17 (40.53 KB/s) – `mecab-python-0.97.tar.gz’ saved [53415/53415]

[1]+  Done                    wget http://downloads.sourceforge.net/mecab/mecab-python-0.97.tar.gz?modtime=1202034647

 

deb1:/usr/local/src# tar xvfz mecab-python-0.97.tar.gz
mecab-python-0.97/
mecab-python-0.97/COPYING
mecab-python-0.97/BSD
mecab-python-0.97/LGPL
mecab-python-0.97/GPL
mecab-python-0.97/AUTHORS
mecab-python-0.97/MeCab.py
mecab-python-0.97/MeCab.pyc
mecab-python-0.97/MeCab_wrap.cxx
mecab-python-0.97/README
mecab-python-0.97/setup.py
mecab-python-0.97/test.py
mecab-python-0.97/bindings.html

 

deb1:/usr/local/src# cd mecab-python-0.97
deb1:/usr/local/src/mecab-python-0.97# more README
MeCab python module

$Id: README,v 1.1.1.1 2005/12/03 14:18:50 taku-ku Exp $;

1. Installation

  % python setup.py build
  % su
  # python setup.py install

  You can change the install directory with the –prefix option. For example:

  % python setup.py install –prefix=/tmp/pybuild/foobar

2. How to use?

   see ‘test.py’ as a sample program.

 

deb1:/usr/local/src/mecab-python-0.97# python setup.py install
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.4
copying MeCab.py -> build/lib.linux-i686-2.4
running build_ext
building ‘_MeCab’ extension
creating build/temp.linux-i686-2.4
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include -I/usr/include/python2.4 -c MeCab_wrap.cxx -o build/temp.linux-i686-2.4/MeCab_wrap.o
gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory
error: command ‘gcc’ failed with exit status 1

 

deb1:/usr/local/src/mecab-python-0.97# apt-get install g++
Reading package lists… Done
Building dependency tree… Done
The following extra packages will be installed:
  g++-4.1 libstdc++6-4.1-dev
Suggested packages:
  gcc-4.1-doc lib64stdc++6 libstdc++6-4.1-doc
The following NEW packages will be installed:
  g++ g++-4.1 libstdc++6-4.1-dev
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 4250kB of archives.
After unpacking 16.2MB of additional disk space will be used.
Do you want to continue [Y/n]? Y

 

コンパイルエラー。

deb1:/usr/local/src/mecab-python-0.97# gcc –version
gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

deb1:/usr/local/src/mecab-python-0.97# g++ –version
g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 

deb1:/usr/local/src/mecab-python-0.97# mecab -v
mecab of 0.93

 

deb1:/usr/local/src# wget http://downloads.sourceforge.net/mecab/mecab-python-0.93.tar.gz?modtime=1159112326&big_mirror=0
[1] 31402
deb1:/usr/local/src# –05:49:50–  http://downloads.sourceforge.net/mecab/mecab-python-0.93.tar.gz?modtime=1159112326
           => `mecab-python-0.93.tar.gz?modtime=1159112326′
Resolving downloads.sourceforge.net… 66.35.250.203
Connecting to downloads.sourceforge.net|66.35.250.203|:80… connected.
HTTP request sent, awaiting response… 302 Found
Location: http://jaist.dl.sourceforge.net/sourceforge/mecab/mecab-python-0.93.tar.gz [following]
–05:49:50–  http://jaist.dl.sourceforge.net/sourceforge/mecab/mecab-python-0.93.tar.gz
           => `mecab-python-0.93.tar.gz’
Resolving jaist.dl.sourceforge.net… 150.65.7.130
Connecting to jaist.dl.sourceforge.net|150.65.7.130|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 35,118 (34K) [application/x-gzip]

100%[=============================================>] 35,118       209.28K/s

05:49:51 (208.05 KB/s) – `mecab-python-0.93.tar.gz’ saved [35118/35118]

[1]+  Done                    wget http://downloads.sourceforge.net/mecab/mecab-python-0.93.tar.gz?modtime=1159112326

 

deb1:/usr/local/src/mecab-python-0.93# ls
MeCab.py  MeCab.pyc  MeCab_wrap.cxx  README  bindings.html  setup.py  test.py
deb1:/usr/local/src/mecab-python-0.93# python setup.py install
running install
running build
running build_py
creating build
creating build/lib.linux-i686-2.4
copying MeCab.py -> build/lib.linux-i686-2.4
running build_ext
building ‘_MeCab’ extension
creating build/temp.linux-i686-2.4
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include -I/usr/include/python2.4 -c MeCab_wrap.cxx -o build/temp.linux-i686-2.4/MeCab_wrap.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
g++ -pthread -shared build/temp.linux-i686-2.4/MeCab_wrap.o -lmecab -lstdc++ -o build/lib.linux-i686-2.4/_MeCab.so
running install_lib
copying build/lib.linux-i686-2.4/MeCab.py -> /usr/lib/python2.4/site-packages
copying build/lib.linux-i686-2.4/_MeCab.so -> /usr/lib/python2.4/site-packages
byte-compiling /usr/lib/python2.4/site-packages/MeCab.py to MeCab.pyc

 

hide@deb1:~$ python
Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MeCab
>>> dir(MeCab)
[‘MECAB_BOS_NODE’, ‘MECAB_EOS_NODE’, ‘MECAB_NOR_NODE’, ‘MECAB_UNK_NODE’, ‘Node’, ‘Path’, ‘Tagger’, ‘Tagger_create’, ‘Tagger_version’, ‘VERSION’, ‘_MeCab’, ‘__builtins__’, ‘__doc__’, ‘__file__’, ‘__name__’, ‘_newclass’, ‘_object’, ‘_swig_getattr’, ‘_swig_setattr’, ‘_swig_setattr_nondynamic’, ‘new’, ‘new_instancemethod’]
>>> m=MeCab.Tagger()
>>> print m.parse(‘今日もしないとね’)
�       ̾��,� �̾,*,*,*,*,*
�日もし�        �ü�,����,*,*,*,*
��      ̾��,�ȿ �̾,*,*,*,*,*
��とね  �ü�,����,*,*,*,*
EOS

 

辞書の指定が必要。

 

>>> m=MeCab.Tagger(‘-d /var/lib/mecab/dic/utf8’)
>>> print m.parse(‘今日もしないとね’)
今日    名詞,時相名詞,*,*,今日,きょう,代表表記:今日
もし    副詞,*,*,*,もし,もし,代表表記:もし
ない    形容詞,*,イ形容詞アウオ段,基本形,ない,ない,代表表記:無い
と      助詞,格助詞,*,*,と,と,*
ね      助詞,終助詞,*,*,ね,ね,*
EOS

>

>>> m=MeCab.Tagger(‘-d /var/lib/mecab/dic/utf8 -U %M -F "%pS%f[5]" -E "\n"’)
>>> print m.parse(‘今日もしないとね’)
"きょう""もし""ない""と""ね""

カテゴリー: 未分類 パーマリンク

python-mecab: やはりmecabはmake installしたほうがよいのではないか への2件のフィードバック

  1. Unknown より:

    Hi,Do you need advertising displays, digital signages, ad players, advertisement player and LCD advertisings? Please go Here:www.amberdigital.com.hk(Amberdigital).we have explored and developed the international market with professionalism. We have built a widespread marketing network, and set up a capable management team dedicated to provide beyond-expectation services to our customers.
    amberdigital Contact Us
    website:www.amberdigital.com.hk
    alibaba:amberdigital.en.alibaba.com[dgfiafbahabgefd]

  2. Unknown より:

    Hi,Do you need digital signages, advertising displays, digital sign, advertisement displays and advertising players? Please go Here:www.amberdigital.com.hk(Amberdigital).we have explored and developed the international market with professionalism. We have built a widespread marketing network, and set up a capable management team dedicated to provide beyond-expectation services to our customers.
    amberdigital Contact Us
    website:www.amberdigital.com.hk
    alibaba:amberdigital.en.alibaba.com[cbcahfhbjbifga]

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト / 変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト / 変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト / 変更 )

Google+ フォト

Google+ アカウントを使ってコメントしています。 ログアウト / 変更 )

%s と連携中