KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > contineo > core > text > analyze > de > GermanAnalyzer


1 /*
2  * GermanAnalyzer.java
3  *
4  * Created on 23. Juli 2003, 19:15
5  */

6
7 package org.contineo.core.text.analyze.de;
8
9 import java.text.BreakIterator JavaDoc;
10
11 import org.contineo.core.text.analyze.AnalyseResult;
12 import org.contineo.core.text.analyze.Analyzer;
13 import org.contineo.core.text.analyze.Stemmer;
14 import org.contineo.core.text.analyze.StopTable;
15 import org.contineo.core.text.analyze.Stopwords;
16 import org.contineo.core.text.analyze.WordRanker;
17 import org.contineo.core.text.analyze.WordTable;
18 /**
19  * This class can analyze german texts by using the german stop word list.
20  * @author Michael Scholz
21  * @version 1.0
22  */

23 public class GermanAnalyzer extends WordRanker implements Analyzer {
24
25     private String JavaDoc[] germanStopwords;
26     
27     /**
28      * Creates a new instance of GermanAnalyzer.
29      */

30     public GermanAnalyzer() {
31         germanStopwords = Stopwords.getStopwords("de");
32         stoptable = StopTable.setStopWords(germanStopwords);
33     }
34  
35     /**
36      * Creates a new instance of GermanAnalyzer.
37      * @param stopwords - Array of user specific stop words.
38      */

39     public GermanAnalyzer(String JavaDoc stopwords[]) {
40         stoptable = StopTable.setStopWords(stopwords);
41     }
42     
43     /**
44      * Creates a new instance of GermanAnalyzer.
45      * @param len - Minimum length of words which should analyzed.
46      */

47     public GermanAnalyzer(int len) {
48         minlen = len;
49         germanStopwords = Stopwords.getStopwords("de");
50         stoptable = StopTable.setStopWords(germanStopwords);
51     }
52     
53     /**
54      * This method analyzes a given text and fills a hitlist.
55      * @param text - Text which should analyzed.
56      */

57     public void analyze(String JavaDoc text) {
58         BreakIterator JavaDoc boundary = BreakIterator.getWordInstance();
59         boundary.setText(text);
60         Stemmer stemmer = new GermanStemmer();
61         AnalyseResult result = WordTable.fillWordTable(boundary, new StringBuffer JavaDoc(text), stoptable, minlen, stemmer);
62         wordcount = result.getWordCount();
63         wordtable = result.getWordTable();
64     }
65 }
66
Popular Tags