KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > contineo > core > text > analyze > fr > FrenchAnalyzer


1 /*
2  * EnglishAnalyzer.java
3  *
4  * Created on 24. Juli 2003, 22:46
5  */

6
7 package org.contineo.core.text.analyze.fr;
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 english stop word list.
20  * @author Michael Scholz
21  * @version 1.0
22  */

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

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

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

47     public FrenchAnalyzer(int len) {
48         minlen = len;
49         frenchStopwords = Stopwords.getStopwords("fr");
50         stoptable = StopTable.setStopWords(frenchStopwords);
51     }
52     
53     /**
54      * This method analyzes a given text an 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 FrenchStemmer();
61         AnalyseResult result = WordTable.fillWordTable(boundary, new StringBuffer JavaDoc(text), stoptable, minlen, stemmer);
62         wordcount = result.getWordCount();
63         wordtable = result.getWordTable();
64     }
65     
66 }
67
Popular Tags