• 締切済み

WindowsでMeCab

以前、ここで質問をした時に教えて貰った、MeCabをWindowsで動かそうと一時がんばっていましたがどうも上手くいきませんでした。 しかし、PCを変えて同じように「ナマズのブログ」さんのPPM http://namazu.asablo.jp/blog/cat/mecab/ でインストールして設定をしたら、なんと動いたんです。 しかし、これがコマンドライン上でだけなんです。 CGIに組み込んでApache上のページで動かそうとするとエラーが出ます。お決まりのInternal Server Errorです。 「Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, tsujimura@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.」 コマンドラインで出来てサーバーソフト上で出来ない理由が分かりません。悔しくて頭がおかしくないそうです。すいません、疲れてます。 以下が動作させたスクリプトです。とあるHPに載っていたものを使用したので文法に間違いはないと思います。 use strict; use MeCab; my $str = "この文を形態素解析して下さい。"; my $mecab = MeCab::Tagger->new(); my $node = $mecab->parseToNode($str); for( ; $node; $node = $node->{next} ) { next unless defined $node->{surface}; my $midasi = $node->{surface}; my( $hinsi, $yomi ) = (split( /,/, $node->{feature} ))[0,7]; print $midasi, "\t", $yomi, "\t", $hinsi, "\n"; }

  • Perl
  • 回答数4
  • ありがとう数1

みんなの回答

回答No.4

すいません、先間違いました。これです。 http://gh33-it.blogspot.com/2010/05/ruby.html

回答No.3

全角文字を含む文字列を切る すいませんか、日本語苦手です。資料があります。http://gh33-it.blogspot.com/

参考URL:
http://gh33-it.blogspot.com/
  • vsba23895
  • ベストアンサー率58% (18/31)
回答No.2

>my $node = $mecab->parseToNode($str); >で処理が止まっている事は確認出来てきます。 その状態で Internal Server Error ということは、httpd のログに何か出ている筈ですが、何と出ていますか。

  • vsba23895
  • ベストアンサー率58% (18/31)
回答No.1

mecab 以前で止まっている可能性があります。 use strict; use MeCab; の2行だけの cgi にしても Internal Server Error になるようなら、恐らく httpd のアカウントでの実行権限がない、Mecab のモジュールの読み出し権限がない、モジュールのディレクトリが見付からない、などが原因です。いずれも httpd のログに書かれると思いますが。 又、www サーバに出力するには、まず MIME ヘッダ Content-type: text/plain とか Content-type: text/html とか が必要ですが、それが欠けているようです。この場合、ブラウザからは真っ白ページと見え、httpd のログには inapropriate header from scirptとか書かれるかと思います。 なお、my $mecab= MeCab::Tagger->new(); の直後で、本当に $mecab オブジェクトが生成できたか ($mecab が undef ではないか)を確かめるのが安全です。

jukimoto
質問者

補足

すいません、説明が足らず。 mecabは動いてます。 MIMEヘッダは付けてると真っ白になります。 オブジェクトは出来てきます。 その次の行の my $node = $mecab->parseToNode($str); で処理が止まっている事は確認出来てきます。

関連するQ&A

  • MeCab(和布蕪)をPerlで使うには

    MeCabをPerlから使おうと思い、MeCab本体であるmecab-0.93.exeと mecab-perl-0.93.tar.gzをダウンロードしました。 mecab-perl-0.93ディレクトリにあるtest.plをWindowsのコマンドプロンプトにて実行してみたのですが、エラーがでてしまいます。プログラムとエラーは以下の通りです。どういったエラーなのか良く分かりません。アドバイスお願いします。 <プログラム> #!c:/perl/bin/perl use lib $ENV{PWD} . "/blib/lib"; use lib $ENV{PWD} . "/blib/arch"; use MeCab; print $MeCab::VERSION, "\n"; my $sentence = "太郎はこの本を二郎を見た女性に渡した。"; my $c = new MeCab::Tagger (join " ", @ARGV); print $c->parse($sentence); for (my $m = $c->parseToNode ($sentence); $m; $m = $m->{next}) { printf ("%s\t%s\n", $m->{surface}, $m->{feature}); } <エラー内容> % test.pl Can't locate loadable object for module MeCab in @INC (@INC contains: /blib/arch /blib/lib C:/Perl/lib C:/Perl/site/lib .) at MeCab.pm line 8 Compilation failed in require at C:\Program Files\MeCab\mecab-perl-0.93\test.pl line5 BEGIN failes--compilation aborted at C:\Program Files\MeCab\mecab-perl-0.93\test.pl line5 以上です。

  • perl MeCab 和布蕪 エラー

    perlで、テキストを形態素解析し、専門用語を抽出するコードを書いています。 Text::MeCab と TermExtract::MeCab; を利用しているのですが、 よくわからないエラーがでます。 以下 ソースとエラー文になります。 <ソース> #! /usr/bin/perl use Text::MeCab; use TermExtract::MeCab; my $text = "私はももが好きです。"; my $mtext = getMecabText($text); sub getMecabText{ my ($text) = shift @_; my @arg = ($0,"Ochasen"); my $mecab = new Text::MeCab::Tagger(\@arg); my $exdata = new TermExtract::MeCab; $text = $mecab->parse($text); return $text; } printKeyWord($mtext); sub printKeyWord{ my ($mtext) = shift @_; my $data = new TermExtract::MeCab; my $output_mode = 1; $data->use_TF; my @noun_list = $data->get_imp_word($mtext,'var'); foreach (@noun_list) { next if $_->[0] =~ /^(昭和)*(平成)*(\d+年)*(\d+月)*(\d+日)*(午前)*(午後)*(\d+時)*(\d+分)*(\d+秒)*$/; next if $_->[0] =~ /^\d+$/; printf "%-60s %16.2f\n", $_->[0], $_->[1] if $output_mode == 1; printf "%s\n", $_->[0] if $output_mode == 2; printf "%s,", $_->[0] if $output_mode == 3; } } <エラー文> Can't locate loadable object for module Text::MeCab in @INC (@INC contains: C:/usr/site/lib C:/usr/lib .) at C:/usr/lib/DynaLoader.pm line 21 BEGIN failed--compilation aborted at C:/usr/lib/Text/MeCab.pm line 21. Compilation failed in require at ./lab/a.cgi line 2. BEGIN failed--compilation aborted at ./lab/a.cgi line 2. C:/usr/site/lib と C:/usr/lib の中に MeCab.pmファイルを置いても同じエラーがでます。 DynaLoader.pm line 21 や MeCab.pm line 21 は改行のみでした。 MeCab.pm は http://search.cpan.org/~dmaki/Text-MeCab-0.20013/lib/Text/MeCab.pm の Source にあるものをコピペして設置しています。 いろいろと格闘したのですが、お手上げ状態です。 原因がわかる方いらっしゃれば教えていただきたいです。 よろしくお願いしいたします。

  • 500 Internal Server Error

    http://iboard3.to/ で始まるURLのどのサイトでも 500 Internal Server Error Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, info@iboard2.to and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. と表示され、見ることができません。 どうしたらよいですか?

  • mixiで動画をUPしたら・・・・

    mixiで動画をUPしたら・・・・ Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, mixi and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. というエラーが出たんですが、今になっても直りません。 どうすればよいですか?

  • 教えてgooサーバーエラー

    すみません 教えてgooでInternal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, root@ask01.goo.ne.jp and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. という表記が出てきます。 よく意味が分からないのですが、どのように対処すればよいのでしょうか よろしくお願いします

  • Opera8.54にしたらスキンがダウンロードできない!

    みなさんこんにちは。 本日Operaの8.54がアップされていたので ダウンロード&インストールしました。 すると今までの設定が初期化され 初めてOperaを入れた時の状態に戻りました。 (Flash等のプラグインも) それから今までの使い勝手のいいように 戻したんですが、他のスキンを使おうとしても なぜか下記の文章がでて出来ません。       ↓ Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, my@opera.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Apache Server at my.opera.com Port 80 原因はなんでしょうか? みなさんお願いします。

  • 続・メールの送信

    Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. -------------------------------------------------------------------------------- Apache/2.0.39 Server at www.altoworld.com Port 80 こんな表示が出て、白紙でメールだけは届きます

    • ベストアンサー
    • CGI
  • あるHPにアクセスしてのエラー

    以下のエラーが出ました。これは、私の方のせいですかね?いきなり英語でエラーメッセージが出ても・・・ Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, あるHPのアドレス and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. どうしたらいいのでしょうか?

  • Movable Type 3.34を使ってますが、急にブログが更新できなくなりました。

    Movable Type 3.34を使ってますが、急にブログが更新できなくなりました。 どなたか、お助けくださいませ。。 こんなエラーメッセージが出ます。 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, postmaster@ONES-CREATE.COM and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.

  • Internal Server Error???

    こんにちは。 CGIを作ったのですが、 【Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@life-web.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. 】 と言うエラーが出て動きません. もう一つ同じようなcgiを作ったのですが、そちらは普通に動きます.すみませんが、このエラーの場合はどうしたらいいですか? CGIはメールフォームからのメールを送信するものです。

    • ベストアンサー
    • CGI