4.2.4 Class Stopword
Berfungsi untuk memanggil kamus stopword bila belum tersedia sekaligus memproses dalam tahapan stopword.
bacakamusstopwordfileKamusStopWord; hapusstopword;
bacakamusfileKamusStemWord; stem;
} }
List Code 4. 3 Class Dokumen
public class Tampilstopword { public static void mainString[] args {
JFileChooser path = new JFileChooser; FileFilter filter = new FileNameExtensionFilterText files
.txt, txt; path.addChoosableFileFilterfilter;
path.setFileFilterfilter; int result = path.showOpenDialognull;
if result == JFileChooser.APPROVE_OPTION { File file = path.getSelectedFile;
Dokumen dok = new Dokumenfile; result = path.showOpenDialognull;
if result == JFileChooser.APPROVE_OPTION { dok.setFileKamusStopWordpath.getSelectedFile.getPath;
result = path.showOpenDialognull; if result == JFileChooser.APPROVE_OPTION {
dok.setFileKamusStemWordpath.getSelectedFile.getPath; dok.Preprocessing;
System.out.printlndok.daftarKata; }
} }
} public static ListString TokenizeString Teks {
StringTokenizer token = new StringTokenizerTeks.toString.toLowerCase, .,?-
_+:;~[]{}=; return Collections.listEnumeration token;
} public static ListString bacakamusstopwordString filename {
try { FileInputStream FIS = new FileInputStreamfilename;
Scanner sc = new ScannerFIS; ListString hasil = new ArrayList;
while sc.hasNext { hasil.addsc.next;
} return hasil;
} catch FileNotFoundException ex { Logger.getLoggerTampilstopword.class.getName.logLevel.SEV
ERE, null, ex; return null;
} }
public static ListString hapusstopwordListString hasiltoken, ListString stopwords {
ListString hasilstopword = new ArrayListhasiltoken; IteratorString i = hasilstopword.iterator;
while i.hasNext { String token = i.next;
if stopwords.containstoken { i.remove;
} }
return hasilstopword; }
public static SetString bacakamus { JFileChooser path = new JFileChooser;
int result = path.showOpenDialognull; if result == JFileChooser.APPROVE_OPTION {
File filename = path.getSelectedFile; FileInputStream fis = null;
try { fis = new FileInputStreamfilename;
} catch FileNotFoundException ex { Logger.getLoggerTampilstopword.class.getName.logLevel.SEV
ERE, null, ex; }
Scanner s = new Scannerfis; SetString hasil = new HashSet;
while s.hasNext { hasil.adds.next;
}
4.2.5 Class Mencari Bobot