Irodori » JapaneseAnalyzer plugin (Nutch) がすごく参考になります。
src/plugin/analysis-jp/src/java/org/apache/nutch/analysis/jp/JapaneseAnalyzer.java
sen: ドキュメント & ファイル: release から
lucene-ja-2.0test2.zip
sen-1.2.2.1.zip
をダウンロードしてきて、中に入ってる
lucene-ja.jar
sen.jar
を
src/plugin/analysis-jp/lib に置いて、クラスパスを通す。
※Senについては、辞書のコンパイルも別途済ませておく。
src/plugin/analysis-jp/build.xml
src/plugin/analysis-jp/plugin.xml
conf/nutch-default.xmlのplugin.includesの末尾に
|analysis-jp|language-identifier
を追加する。
この状態で、language-identifierによってlang(言語)がja(日本語)と判定されたものは
analysis-jpが適用されるのだが、nutch-1.0に含まれているlanguage-identifierは
日本語判定の材料を持っていない。
LanguageIdentifier - Nutch Wikiを参考に
適当に日本語を含んだテキストファイルを使ってja.ngpを生成すると、
とりあえずクローリングした日本語ページをjaと判定するようにはなったが・・・
言語判定の精度はまた別の問題なので、
ここではLanguageIdentifierで常にjaと判定させる。
src/plugin/languageidentifier/src/java/org/apache/nutch/analysis/lang/LanguageIndexingFilter.java の93行目
あとは、Crawlツール等で日本語ページをクローリングして
Luke - Lucene Index Toolboxでインデクスの中身を見てみると、

ちゃんと形態素解析されてる!
src/plugin/analysis-jp/src/java/org/apache/nutch/analysis/jp/JapaneseAnalyzer.java
package org.apache.nutch.analysis.jp;
// JDK imports
import java.io.Reader;
// Lucene imports
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
// Nutch imports
import org.apache.nutch.analysis.NutchAnalyzer;
/**
* A simple Japanese Analyzer that wraps the Lucene one.
*/
public class JapaneseAnalyzer extends NutchAnalyzer {
private final static Analyzer ANALYZER =
new org.apache.lucene.analysis.ja.JapaneseAnalyzer();
/** Creates a new instance of JapaneseAnalyzer */
public JapaneseAnalyzer() {
}
public TokenStream tokenStream(String fieldName, Reader reader) {
return ANALYZER.tokenStream(fieldName, reader);
}
}
sen: ドキュメント & ファイル: release から
lucene-ja-2.0test2.zip
sen-1.2.2.1.zip
をダウンロードしてきて、中に入ってる
lucene-ja.jar
sen.jar
を
src/plugin/analysis-jp/lib に置いて、クラスパスを通す。
※Senについては、辞書のコンパイルも別途済ませておく。
src/plugin/analysis-jp/build.xml
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="analysis-jp" default="jar-core">
<import file="../build-plugin.xml"/>
<!-- Build compilation dependencies -->
<target name="deps-jar">
<ant target="jar" inheritall="false" dir="../lib-lucene-analyzers"/>
</target>
<!-- Add compilation dependencies to classpath -->
<path id="plugin.deps">
<fileset dir="${nutch.root}/build">
<include name="**/lib-lucene-analyzers/*.jar" />
</fileset>
</path>
</project>
src/plugin/analysis-jp/plugin.xml
<?xml version="1.0" encoding="UTF-8"?> <plugin id="analysis-jp" name="Japanese Analysis Plug-in" version="1.0" provider-name="org.apache.nutch"> <runtime> <library name="analysis-jp.jar"> <export name="*" /> </library> <library name="lucene-ja.jar" /> <library name="sen.jar" /> </runtime> <requires> <import plugin="nutch-extensionpoints" /> </requires> <extension id="org.apache.nutch.analysis.jp" name="Japanese Analyzer" point="org.apache.nutch.analysis.NutchAnalyzer"> <implementation id="JapaneseAnalyzer" class="org.apache.nutch.analysis.jp.JapaneseAnalyzer"> <parameter name="lang" value="ja" /> </implementation> </extension> </plugin>
conf/nutch-default.xmlのplugin.includesの末尾に
|analysis-jp|language-identifier
を追加する。
この状態で、language-identifierによってlang(言語)がja(日本語)と判定されたものは
analysis-jpが適用されるのだが、nutch-1.0に含まれているlanguage-identifierは
日本語判定の材料を持っていない。
LanguageIdentifier - Nutch Wikiを参考に
適当に日本語を含んだテキストファイルを使ってja.ngpを生成すると、
とりあえずクローリングした日本語ページをjaと判定するようにはなったが・・・
言語判定の精度はまた別の問題なので、
ここではLanguageIdentifierで常にjaと判定させる。
src/plugin/languageidentifier/src/java/org/apache/nutch/analysis/lang/LanguageIndexingFilter.java の93行目
// doc.add("lang", lang);
doc.add("lang", "ja");
あとは、Crawlツール等で日本語ページをクローリングして
Luke - Lucene Index Toolboxでインデクスの中身を見てみると、

ちゃんと形態素解析されてる!