List of usage examples for weka.filters Filter filterFile
public static void filterFile(Filter filter, String[] options) throws Exception
From source file:com.openkm.kea.filter.KEAFilter.java
License:Open Source License
/** * Main method for testing this class.// w ww. jav a 2s . co m * * @param argv should contain arguments to the filter: use -h for help */ public static void main(String[] argv) { try { if (Utils.getFlag('b', argv)) { Filter.batchFilterFile(new KEAFilter(new StopwordsEnglish()), argv); } else { Filter.filterFile(new KEAFilter(new StopwordsEnglish()), argv); } } catch (Exception ex) { log.info(ex.getMessage()); } }
From source file:com.openkm.kea.filter.KEAPhraseFilter.java
License:Open Source License
/** * Main method for testing this class.// w ww . java2 s.co m * * @param argv should contain arguments to the filter: use -h for help */ public static void main(String[] argv) { try { if (Utils.getFlag('b', argv)) { Filter.batchFilterFile(new KEAPhraseFilter(), argv); } else { Filter.filterFile(new KEAPhraseFilter(), argv); } } catch (Exception ex) { log.error(ex.getMessage(), ex); } }
From source file:com.openkm.kea.filter.NumbersFilter.java
License:Open Source License
/** * Main method for testing this class./* www . j a va 2s .c o m*/ * * @param argv should contain arguments to the filter: use -h for help */ public static void main(String[] argv) { try { if (Utils.getFlag('b', argv)) { Filter.batchFilterFile(new NumbersFilter(), argv); } else { Filter.filterFile(new NumbersFilter(), argv); } } catch (Exception ex) { log.info(ex.getMessage()); } }
From source file:kea.KEAFilter.java
License:Open Source License
/** * Main method for testing this class.//from w w w. j ava 2s . co m * * @param argv should contain arguments to the filter: use -h for help */ public static void main(String[] argv) { try { if (Utils.getFlag('b', argv)) { Filter.batchFilterFile(new KEAFilter(), argv); } else { Filter.filterFile(new KEAFilter(), argv); } } catch (Exception ex) { System.out.println(ex.getMessage()); } }
From source file:kea.KEAPhraseFilter.java
License:Open Source License
/** * Main method for testing this class./*from ww w . j ava 2 s . c o m*/ * * @param argv should contain arguments to the filter: use -h for help */ public static void main(String[] argv) { try { if (Utils.getFlag('b', argv)) { Filter.batchFilterFile(new KEAPhraseFilter(), argv); } else { Filter.filterFile(new KEAPhraseFilter(), argv); } } catch (Exception ex) { System.out.println(ex.getMessage()); } }
From source file:kea.NumbersFilter.java
License:Open Source License
/** * Main method for testing this class./*w w w .j a v a 2s .c om*/ * * @param argv should contain arguments to the filter: use -h for help */ public static void main(String[] argv) { try { if (Utils.getFlag('b', argv)) { Filter.batchFilterFile(new NumbersFilter(), argv); } else { Filter.filterFile(new NumbersFilter(), argv); } } catch (Exception ex) { System.out.println(ex.getMessage()); } }
From source file:net.sf.bddbddb.order.MyDiscretize.java
License:LGPL
/** * Main method for testing this class./*from w w w .j av a 2 s . c om*/ * * @param argv should contain arguments to the filter: use -h for help */ public static void main(String[] argv) { try { if (Utils.getFlag('b', argv)) { Filter.batchFilterFile(new MyDiscretize(), argv); } else { Filter.filterFile(new MyDiscretize(), argv); } } catch (Exception ex) { System.out.println(ex.getMessage()); } }
From source file:ocr.ARFFSymbolFilter.java
License:Apache License
public static void writeWeka(final String filenameout, final ArrayList<?> symbolData) { final int nsold = ARFFSymbolFilter.ns; ARFFSymbolFilter.tangent = (ARFFSymbolFilter.times > 1); try {//from ww w . j a v a2 s.co m if (!ARFFSymbolFilter.strokenumber) { ARFFSymbolFilter.ns = 1; } final DataOutputStream[] fileout = new DataOutputStream[ARFFSymbolFilter.ns]; final Instances[] instances = new Instances[ARFFSymbolFilter.ns]; System.out.println("Writing file"); for (int i = 0; i < ARFFSymbolFilter.ns; ++i) { final int k = ARFFSymbolFilter.strokenumber ? i : (nsold - 1); fileout[ARFFSymbolFilter.strokenumber ? i : 0] = new DataOutputStream(new FileOutputStream( filenameout + (ARFFSymbolFilter.strokenumber ? ("" + (k + 1)) : "") + ".arff#")); } final int tot = symbolData.size(); for (int j = 0; j < symbolData.size(); ++j) { final ArrayList<?> group = (ArrayList<?>) symbolData.get(j); for (int i = 0; i < group.size(); ++i) { final Symbol sym = (Symbol) group.get(i); final int k = ARFFSymbolFilter.strokenumber ? (sym.size() - 1) : 0; if (sym.name.equals("no_name") || sym.name.equals("empty_symbol")) { System.out.print("#" + sym.name + "#"); } else { for (int t = 0; t < ARFFSymbolFilter.times; ++t) { final String line = constructStringInstance(sym, ARFFSymbolFilter.alpha); if (line == null) { System.out.print("line=null!"); } else { if (instances[k] == null) { final StringTokenizer st = new StringTokenizer(line, " "); final int nt = st.countTokens() / 2; final FastVector att = new FastVector(); for (int kk = 0; kk < nt; ++kk) { final String token = st.nextToken(); att.addElement(new Attribute(new String(token))); st.nextToken(); } att.addElement(new Attribute("class", (FastVector) null)); (instances[k] = new Instances("Symbols of Size " + (k + 1), att, 1)) .setClassIndex(att.size() - 1); } final StringTokenizer st = new StringTokenizer(line, " "); final int nt = st.countTokens() / 2; final Instance inst = new Instance(nt + 1); for (int kk = 0; kk < nt; ++kk) { st.nextToken(); final String token = new String(st.nextToken()); inst.setValue(kk, Double.parseDouble(token)); } inst.setDataset(instances[k]); inst.setClassValue(oldReplace(sym.name, "\\", "")); instances[k].add(inst); } } } } if ((int) (100.0 * j) / tot % 10 == 0) { System.out.print((int) (100.0 * j) / tot + "%-"); } } for (int k = 0; k < ARFFSymbolFilter.ns; ++k) { if (fileout[ARFFSymbolFilter.strokenumber ? k : 0] == null) { System.out.println("fo" + fileout[ARFFSymbolFilter.strokenumber ? k : 0]); } if (instances[ARFFSymbolFilter.strokenumber ? k : 0] == null) { System.out.println("in:" + instances[ARFFSymbolFilter.strokenumber ? k : 0]); } fileout[ARFFSymbolFilter.strokenumber ? k : 0] .writeBytes(instances[ARFFSymbolFilter.strokenumber ? k : 0].toString()); fileout[ARFFSymbolFilter.strokenumber ? k : 0].close(); } final StringToNominal filter = new StringToNominal(); final String[] args = new String[4]; for (int k = 0; k < ARFFSymbolFilter.ns; ++k) { args[0] = "-i"; args[1] = filenameout + (ARFFSymbolFilter.strokenumber ? ("" + (k + 1)) : "") + ".arff#"; args[2] = "-o"; args[3] = filenameout + (ARFFSymbolFilter.strokenumber ? ("" + (k + 1)) : "") + ".arff"; Filter.filterFile(filter, args); new File(args[1]).delete(); } System.out.println("100.0%"); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } catch (Exception ioe) { ioe.printStackTrace(); } }