-1

Here is class from Lucene library that I want to take advantage (make use) of.. But I don't know how to use/implement that library in Java..

Example: I have string array >> menjadikan, menjawab, penerbangan

Can you help me in Java with creating such an array??

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Lita
  • 175
  • 1
  • 2
  • 11
  • I just knew.. I'm very glad you're giving me a warning and fix the question. I will remember that. – Lita Apr 06 '15 at 23:38

1 Answers1

0

Here is an example code snippet (based on the Lucene test code) that creates a Lucene analyser using the Indonesian stemmer.

import java.io.IOException;
import java.io.Reader;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.KeywordTokenizer;


  ...
  Analyzer a = new Analyzer() {
    @Override
    public TokenStreamComponents createComponents(
               String fieldName, Reader reader) {
      Tokenizer tokenizer = new KeywordTokenizer(reader);
      return new TokenStreamComponents(tokenizer, 
                 new IndonesianStemFilter(tokenizer));
    }
  };

You could also instantiate IndonesianStemmer directly, and call the stem method on individual words. For example;

  IndonesianStemmer stemmer = new IndonesianStemmer();
  ...
  char[] chars = "menjadikan".toCharArray();
  int len = stemmer.stem(chars, chars.length, false);
  String stem = new String(chars, 0, len);

WARNING: the above code is not tested.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • I didn't downvote, but: The StemFilter usage you've provided seems quite unusual, and not very useful except in pretty specific cases. The question is quite unclear to me, so not sure if it fits or not, really. Also, judging by the example words given in the question, your `stemmer.stem` call should probably have `stemDerviational` set to `true`. Don't think any of that warrants a downvote though. Probably more likely they just downvoted for answering a question they thought ought to be closed. – femtoRgon Apr 06 '15 at 06:00