Example usage for org.apache.lucene.analysis.id IndonesianStemmer stem

List of usage examples for org.apache.lucene.analysis.id IndonesianStemmer stem

Introduction

In this page you can find the example usage for org.apache.lucene.analysis.id IndonesianStemmer stem.

Prototype

public int stem(char text[], int length, boolean stemDerivational) 

Source Link

Document

Stem a term (returning its new length).

Usage

From source file:news.classifier.MyIndonesiaStemmer.java

@Override
public String stem(String word) {
    IndonesianStemmer stemmer = new IndonesianStemmer();
    char unstemmedWord[] = word.toCharArray();
    int stemmedWordLength = stemmer.stem(unstemmedWord, unstemmedWord.length, true);
    stemmedWord = String.copyValueOf(unstemmedWord, 0, stemmedWordLength);
    return stemmedWord;
}

From source file:stki_tugas_02.FormTokenisasi.java

String stemmKata(String term) {
    IndonesianStemmer stemmer = new IndonesianStemmer();
    char[] chars = term.toCharArray();
    int len = stemmer.stem(chars, chars.length, true);
    String stem = new String(chars, 0, len);
    return stem;//ww  w .j  a va2s . c o  m
}

From source file:textmining.tugasakhir.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:
    jTabbedPane1.setSelectedIndex(3);/*  w ww .  j  a v a2 s  .  com*/
    IndonesianStemmer stemmer = new IndonesianStemmer();
    // Stemming Document 1
    for (int i = 0; i < wordsList1.size(); i++) {
        dooc1.add(wordsList1.get(i));
        char[] chars = dooc1.get(i).toCharArray();
        int len = stemmer.stem(chars, chars.length, true);
        String stem = new String(chars, 0, len);
        repdoc1.add(stem);
    }
    // Stemming Document 2
    for (int i = 0; i < wordsList2.size(); i++) {
        dooc2.add(wordsList2.get(i));
        char[] chars = dooc2.get(i).toCharArray();
        int len = stemmer.stem(chars, chars.length, true);
        String stem = new String(chars, 0, len);
        repdoc2.add(stem);
    }
    // Stemming Document 3
    for (int i = 0; i < wordsList3.size(); i++) {
        dooc3.add(wordsList3.get(i));
        char[] chars = dooc3.get(i).toCharArray();
        int len = stemmer.stem(chars, chars.length, true);
        String stem = new String(chars, 0, len);
        repdoc3.add(stem);
    }
    // Stemming Document 4
    for (int i = 0; i < wordsList4.size(); i++) {
        dooc4.add(wordsList4.get(i));
        char[] chars = dooc4.get(i).toCharArray();
        int len = stemmer.stem(chars, chars.length, true);
        String stem = new String(chars, 0, len);
        repdoc4.add(stem);
    }
    // Stemming Document 5 
    for (int i = 0; i < wordsList5.size(); i++) {
        dooc5.add(wordsList5.get(i));
        char[] chars = dooc5.get(i).toCharArray();
        int len = stemmer.stem(chars, chars.length, true);
        String stem = new String(chars, 0, len);
        repdoc5.add(stem);
    }

    //       
    jTextArea5.setText("Doc 1 : " + repdoc1 + "\n\n" + "Doc 2 : " + repdoc2 + "\n\n" + "Doc 3 : " + repdoc3
            + "\n\n" + "Doc 4 : " + repdoc4 + "\n\n" + "Doc 5 : " + repdoc5 + "\n\n");

    for (int i = wordsList1.size() - 1; i >= 0; i--) {
        wordsList1.remove(i);
    }
    for (int i = 0; i < repdoc1.size(); i++) {
        wordsList1.add(i, repdoc1.get(i));
    }

    for (int i = wordsList2.size() - 1; i >= 0; i--) {
        wordsList2.remove(i);
    }
    for (int i = 0; i < repdoc2.size(); i++) {
        wordsList2.add(i, repdoc2.get(i));
    }

    for (int i = wordsList3.size() - 1; i >= 0; i--) {
        wordsList3.remove(i);
    }
    for (int i = 0; i < repdoc3.size(); i++) {
        wordsList3.add(i, repdoc3.get(i));
    }

    for (int i = wordsList4.size() - 1; i >= 0; i--) {
        wordsList4.remove(i);
    }
    for (int i = 0; i < repdoc4.size(); i++) {
        wordsList4.add(i, repdoc4.get(i));
    }

    for (int i = wordsList5.size() - 1; i >= 0; i--) {
        wordsList5.remove(i);
    }
    for (int i = 0; i < repdoc5.size(); i++) {
        wordsList5.add(i, repdoc5.get(i));
    }

    jButton2.setEnabled(false);
}