質問編集履歴
1
Lucene4.8.1
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,69 +1,44 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
3
|
Luceneを使って形態素解析のプログラムを作成しています。
|
4
|
-
出力する値をカタカナ変換できるようにしたい
|
5
|
-
|
6
|
-
[https://github.com/mwsoft/sample/blob/master/solr-filter-sample/src/jp/mwsoft/sample/lucene/filter/JapaneseReadingFormFilterSample.java](https://github.com/mwsoft/sample/blob/master/solr-filter-sample/src/jp/mwsoft/sample/lucene/filter/JapaneseReadingFormFilterSample.java)
|
7
|
-
このコンパイルエラーを解除してプログラムを実行できるようにしたいです。
|
4
|
+
出力する値をカタカナ変換できるようにしたいです。
|
5
|
+
バージョンはLucene4.8.1です。
|
8
6
|
|
9
|
-
|
7
|
+
```ここに言語を入力
|
10
|
-
|
8
|
+
例)
|
11
|
-
|
9
|
+
今日は雨です。
|
10
|
+
⇓
|
12
|
-
|
11
|
+
キョウ
|
12
|
+
ハ
|
13
|
+
アメ
|
14
|
+
デス
|
15
|
+
。
|
13
16
|
```
|
14
|
-
型 JapaneseReadingFormFilterSample.MyAnalyzer は継承された抽象メソッド Analyzer.createComponents(String) を実装する必要があります
|
15
|
-
```
|
16
17
|
|
17
|
-
### 該当のソースコード
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
参考にしているサンプルをプロジェクトに移行しましたがコンパイルエラーになってしまいます。
|
20
|
+
[https://github.com/mwsoft/sample/blob/master/solr-filter-sample/src/jp/mwsoft/sample/lucene/filter/JapaneseReadingFormFilterSample.java](https://github.com/mwsoft/sample/blob/master/solr-filter-sample/src/jp/mwsoft/sample/lucene/filter/JapaneseReadingFormFilterSample.java)
|
21
|
+
またバージョン違いによりメソッドも変わっているような気がします。
|
22
|
+
### 発生している問題・エラーメッセージ
|
22
23
|
|
23
|
-
import org.apache.lucene.analysis.Analyzer;
|
24
|
-
import org.apache.lucene.analysis.TokenStream;
|
25
|
-
import org.apache.lucene.analysis.ja.JapaneseReadingFormFilter;
|
26
|
-
import org.apache.lucene.analysis.ja.JapaneseTokenizer;
|
27
|
-
|
24
|
+
現状、サンプルコードをそのまま転機すると以下のコンパイルエラーになります。継承に関するメソッドを実装してもさらにコンパイルエラーが出てしまいます。また、Lucene4.8.1で動くようにしたいです。もしかしたらメソッドが少し変わっているかもしれません。
|
28
25
|
|
29
|
-
public class JapaneseReadingFormFilterSample {
|
30
26
|
|
31
|
-
public static void main(String[] args) throws Exception {
|
32
27
|
|
33
|
-
MyAnalyzer analyzer = new MyAnalyzer();
|
34
28
|
|
35
|
-
String str = "疲れたろう。僕も疲れたんだ。";
|
36
|
-
|
37
|
-
Reader reader = new StringReader(str);
|
38
|
-
TokenStream stream = analyzer.tokenStream("", reader);
|
39
|
-
|
40
|
-
while (stream.incrementToken()) {
|
41
|
-
CharTermAttribute term = stream.getAttribute(CharTermAttribute.class);
|
42
|
-
System.out.print(term.toString() + "\t");
|
43
|
-
}
|
44
|
-
// => ツカレ タロ ウ ボク モ ツカレ タ ン ダ
|
45
|
-
}
|
46
|
-
|
47
|
-
static class MyAnalyzer extends Analyzer {
|
48
|
-
public final TokenStream tokenStream(String fieldName, Reader reader) {
|
49
|
-
TokenStream result = new JapaneseTokenizer(reader, null, true, JapaneseTokenizer.Mode.NORMAL);
|
50
|
-
result = new JapaneseReadingFormFilter(result, true);
|
51
|
-
return result;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|
55
|
-
```
|
56
|
-
|
57
29
|
### 試したこと
|
58
|
-
サンプルを修正してエラーの対処をしていきましたが、
|
30
|
+
サンプルを修正してエラーの対処をしていきましたが、Lucene4.8.1に適合させることができませんでした。
|
59
31
|
|
60
32
|
|
61
33
|
### 補足情報(FW/ツールのバージョンなど)
|
34
|
+
開発環境:Eclipse4.8.0
|
35
|
+
言語:Java1.7
|
36
|
+
Java用プロジェクト管理ツール:Maven1.7
|
37
|
+
全文検索ソフトウェア:Lucene4.8.1
|
62
38
|
|
63
39
|
↓pom.xml
|
64
40
|
```pom.xml
|
65
|
-
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
41
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
66
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
67
42
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
68
43
|
<modelVersion>4.0.0</modelVersion>
|
69
44
|
|
@@ -110,18 +85,8 @@
|
|
110
85
|
<dependencies>
|
111
86
|
<dependency>
|
112
87
|
<groupId>org.apache.lucene</groupId>
|
113
|
-
<artifactId>lucene-core</artifactId>
|
114
|
-
<version>8.1.0</version>
|
115
|
-
</dependency>
|
116
|
-
<dependency>
|
117
|
-
<groupId>org.apache.lucene</groupId>
|
118
|
-
<artifactId>lucene-queryparser</artifactId>
|
119
|
-
<version>8.1.0</version>
|
120
|
-
</dependency>
|
121
|
-
<dependency>
|
122
|
-
<groupId>org.apache.lucene</groupId>
|
123
88
|
<artifactId>lucene-analyzers-kuromoji</artifactId>
|
124
|
-
<version>8.1
|
89
|
+
<version>4.8.1</version>
|
125
90
|
</dependency>
|
126
91
|
<dependency>
|
127
92
|
<groupId>junit</groupId>
|
@@ -132,4 +97,5 @@
|
|
132
97
|
</dependencies>
|
133
98
|
</project>
|
134
99
|
|
100
|
+
|
135
101
|
```
|