List of usage examples for weka.core Utils readProperties
public static Properties readProperties(String resourceName) throws Exception
From source file:adams.gui.application.WekaExperimenterPreferencesPanel.java
License:Open Source License
@Override protected void initGUI() { super.initGUI(); addPropertyType("Extension", PropertyType.LIST); setList("Extension", new String[] { ".exp", ".xml" }); addPropertyType("Destination", PropertyType.LIST); setList("Destination", new String[] { "ARFF file", "CSV file", "JDBC database" }); addPropertyType("ExperimentType", PropertyType.LIST); setList("ExperimentType", new String[] { "Cross-validation", "Train/Test Percentage Split (data randomized)", "Train/Test Percentage Split (order preserved)" }); addPropertyType("UseClassification", PropertyType.BOOLEAN); addPropertyType("Folds", PropertyType.INTEGER); addPropertyType("TrainPercentage", PropertyType.INTEGER); addPropertyType("Repetitions", PropertyType.INTEGER); addPropertyType("DatasetsFirst", PropertyType.BOOLEAN); addPropertyType("InitialDatasetsDirectory", PropertyType.DIRECTORY); addPropertyType("UseRelativePaths", PropertyType.BOOLEAN); addPropertyType("Tester", PropertyType.LIST); setList("Tester", new String[] { "Paired T-Tester (corrected)", "Paired T-Tester" }); addPropertyType("Row", PropertyType.STRING); addPropertyType("Column", PropertyType.STRING); addPropertyType("ComparisonField", PropertyType.STRING); addPropertyType("Significance", PropertyType.DOUBLE); addPropertyType("Sorting", PropertyType.STRING); addPropertyType("ShowStdDev", PropertyType.BOOLEAN); addPropertyType("ShowAverage", PropertyType.BOOLEAN); addPropertyType("MeanPrecision", PropertyType.INTEGER); addPropertyType("StdDevPrecision", PropertyType.INTEGER); addPropertyType("OutputFormat", PropertyType.OBJECT_EDITOR); setChooser("OutputFormat", new GenericObjectEditorPanel(weka.experiment.ResultMatrix.class, new weka.experiment.ResultMatrixPlainText(), true)); addPropertyType("RemoveFilterClassnames", PropertyType.BOOLEAN); try {//from w ww . j a va2 s. c o m setPreferences(new Properties(Utils.readProperties(ExperimenterDefaults.PROPERTY_FILE))); } catch (Exception e) { System.err.println("Failed to load WEKA Experimenter properties:"); e.printStackTrace(); setPreferences(new Properties()); } }
From source file:adams.gui.application.WekaExplorerPreferencesPanel.java
License:Open Source License
@Override protected void initGUI() { super.initGUI(); addPropertyType("Tabs", PropertyType.STRING); addPropertyType("InitialDirectory", PropertyType.DIRECTORY_ABSOLUTE); addPropertyType("enableUndo", PropertyType.BOOLEAN); addPropertyType("undoDirectory", PropertyType.DIRECTORY_ABSOLUTE); addPropertyType("Filter", PropertyType.OBJECT_EDITOR); setChooser("Filter", new GenericObjectEditorPanel(weka.filters.Filter.class, new weka.filters.AllFilter(), true)); addPropertyType("Classifier", PropertyType.OBJECT_EDITOR); setChooser("Classifier", new GenericObjectEditorPanel(weka.classifiers.Classifier.class, new weka.classifiers.rules.ZeroR(), true)); addPropertyType("ClassifierTestMode", PropertyType.LIST); setList("ClassifierTestMode", new String[] { "1", "2", "3", "4" }); setHelp("ClassifierTestMode", "1 - cross-validation, 2 - percentage split, 3 - use training set, 4 - supplied test set"); addPropertyType("ClassifierCrossvalidationFolds", PropertyType.INTEGER); addPropertyType("ClassifierPercentageSplit", PropertyType.INTEGER); addPropertyType("ClassifierOutputModel", PropertyType.BOOLEAN); addPropertyType("ClassifierOutputPerClassStats", PropertyType.BOOLEAN); addPropertyType("ClassifierOutputEntropyEvalMeasures", PropertyType.BOOLEAN); addPropertyType("ClassifierOutputConfusionMatrix", PropertyType.BOOLEAN); addPropertyType("ClassifierStorePredictionsForVis", PropertyType.BOOLEAN); addPropertyType("ClassifierOutputPredictions", PropertyType.BOOLEAN); addPropertyType("ClassifierOutputAdditionalAttributes", PropertyType.STRING); addPropertyType("ClassifierCostSensitiveEval", PropertyType.BOOLEAN); addPropertyType("ClassifierRandomSeed", PropertyType.INTEGER); addPropertyType("ClassifierPreserveOrder", PropertyType.BOOLEAN); addPropertyType("ClassifierOutputSourceCode", PropertyType.BOOLEAN); addPropertyType("ClassifierSourceCodeClass", PropertyType.STRING); addPropertyType("ClassifierErrorsPlotInstances", PropertyType.STRING); addPropertyType("ClassifierErrorsMinimumPlotSizeNumeric", PropertyType.INTEGER); addPropertyType("ClassifierErrorsMaximumPlotSizeNumeric", PropertyType.INTEGER); addPropertyType("Clusterer", PropertyType.OBJECT_EDITOR); setChooser("Clusterer", new GenericObjectEditorPanel(weka.clusterers.Clusterer.class, new weka.clusterers.SimpleKMeans(), true)); addPropertyType("ClustererTestMode", PropertyType.LIST); setList("ClustererTestMode", new String[] { "2", "3", "4", "5" }); setHelp("ClustererTestMode", "2 - percentage split, 3 - use training set, 4 - supplied test set, 5 - classes to clusters evaluation"); addPropertyType("ClustererStoreClustersForVis", PropertyType.BOOLEAN); addPropertyType("ClustererAssignmentsPlotInstances", PropertyType.STRING); addPropertyType("Associator", PropertyType.OBJECT_EDITOR); setChooser("Associator", new GenericObjectEditorPanel(weka.associations.Associator.class, new weka.associations.Apriori(), true)); addPropertyType("ASEvaluation", PropertyType.OBJECT_EDITOR); setChooser("ASEvaluation", new GenericObjectEditorPanel(weka.attributeSelection.ASEvaluation.class, new weka.attributeSelection.CfsSubsetEval(), true)); addPropertyType("ASSearch", PropertyType.OBJECT_EDITOR); setChooser("ASSearch", new GenericObjectEditorPanel(weka.attributeSelection.ASSearch.class, new weka.attributeSelection.BestFirst(), true)); addPropertyType("ASTestMode", PropertyType.LIST); setList("ASTestMode", new String[] { "0", "1" }); setHelp("ASTestMode", "0 - use full training set, 1 - cross-validation"); addPropertyType("ASCrossvalidationFolds", PropertyType.INTEGER); addPropertyType("ASRandomSeed", PropertyType.INTEGER); try {/*from w w w .j a v a 2 s.c o m*/ setPreferences(new Properties(Utils.readProperties(ExplorerDefaults.PROPERTY_FILE))); } catch (Exception e) { System.err.println("Failed to load WEKA Explorer properties:"); e.printStackTrace(); setPreferences(new Properties()); } }
From source file:distributed.hadoop.AbstractHadoopJobConfig.java
License:Open Source License
/** * Load the properties file//from ww w . ja v a 2 s. c om */ protected static void loadProps() { if (WEKA_HADOOP_PROPS == null) { try { WEKA_HADOOP_PROPS = Utils.readProperties(HADOOP_PROPS); } catch (Exception ex) { ex.printStackTrace(); } } }
From source file:meka.core.PropsUtils.java
License:Open Source License
/** * Reads properties that inherit from three locations. Properties are first * defined in the system resource location (i.e. in the CLASSPATH). These * default properties must exist. Properties optionally defined in the user * properties location (WekaPackageManager.PROPERTIES_DIR) override default * settings. Properties defined in the current directory (optional) override * all these settings.//from w w w .j av a 2 s . c o m * * @param props the location of the props file that should be loaded. * e.g.: "weka/core/Utils.props". * @return the Properties * @throws Exception if an error occurs reading the properties files. * @see Utils#readProperties(String) */ public static Properties read(String props) throws Exception { Properties result; result = Utils.readProperties(props); if (DEBUG) System.out.println("start<PropsUtils.read: " + props + ">\n" + toString(result, null) + "end<PropsUtils.read: " + props + ">\n"); return result; }
From source file:meka.gui.core.GUIHelper.java
License:Open Source License
/** * Initializes the properties if necessary. *//*from w ww .j av a 2s . c o m*/ public static synchronized Properties getProperties() { String filename; if (m_Properties == null) { filename = "meka/gui/core/" + FILENAME; try { m_Properties = Utils.readProperties(filename); } catch (Exception e) { System.err.println("Failed to read properties: " + filename); e.printStackTrace(); m_Properties = new Properties(); } } return m_Properties; }
From source file:org.pentaho.dm.kf.GroovyComponentCustomizer.java
License:Open Source License
public GroovyComponentCustomizer() { Properties props;/*from ww w . j a v a 2s . co m*/ try { props = Utils.readProperties(PROPERTIES_FILE); } catch (Exception ex) { ex.printStackTrace(); props = new Properties(); } // check for SyntaxDocument boolean syntaxDocAvailable = true; try { Class.forName("weka.gui.scripting.SyntaxDocument"); } catch (Exception ex) { syntaxDocAvailable = false; } if (props.getProperty("Syntax", "false").equals("true") && syntaxDocAvailable) { try { Class syntaxClass = Class.forName("weka.gui.scripting.SyntaxDocument"); Constructor constructor = syntaxClass.getConstructor(Properties.class); Object doc = constructor.newInstance(props); // SyntaxDocument doc = new SyntaxDocument(props); m_textPane.setDocument((DefaultStyledDocument) doc); // m_textPane.setBackground(doc.getBackgroundColor()); m_textPane.setBackground( VisualizeUtils.processColour(props.getProperty("BackgroundColor", "white"), Color.WHITE)); } catch (Exception ex) { ex.printStackTrace(); } } else { m_textPane.setForeground( VisualizeUtils.processColour(props.getProperty("ForegroundColor", "black"), Color.BLACK)); m_textPane.setBackground( VisualizeUtils.processColour(props.getProperty("BackgroundColor", "white"), Color.WHITE)); m_textPane.setFont(new Font(props.getProperty("FontName", "monospaced"), Font.PLAIN, Integer.parseInt(props.getProperty("FontSize", "12")))); } final JFileChooser fileChooser = new JFileChooser(); fileChooser.setAcceptAllFileFilterUsed(true); fileChooser.setMultiSelectionEnabled(false); setUpNewScript(); setLayout(new BorderLayout()); add(new JScrollPane(m_textPane), BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BorderLayout()); JPanel newCompile = new JPanel(); newCompile.setLayout(new BorderLayout()); JButton newBut = new JButton("New"); JButton compileBut = new JButton("Compile"); JButton okBut = new JButton("OK"); JButton cancelBut = new JButton("Cancel"); newCompile.add(newBut, BorderLayout.WEST); newCompile.add(compileBut, BorderLayout.EAST); buttonPanel.add(newCompile, BorderLayout.WEST); buttonPanel.add(okBut, BorderLayout.CENTER); buttonPanel.add(cancelBut, BorderLayout.EAST); add(buttonPanel, BorderLayout.SOUTH); newBut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newScript(fileChooser); } }); compileBut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doCompile(); } }); okBut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_groovyP != null) { m_groovyP.setScript(m_script.getContent()); if (m_modifyListener != null) { m_modifyListener.setModifiedStatus(GroovyComponentCustomizer.this, true); } // close the dialog m_parentWindow.dispose(); } } }); cancelBut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // just close the dialog // TODO if their are mods, ask the user (same if the frame is closed // from the close widget) if (m_modifyListener != null) { m_modifyListener.setModifiedStatus(GroovyComponentCustomizer.this, false); } m_parentWindow.dispose(); } }); m_menuBar = new JMenuBar(); JMenu fileM = new JMenu(); m_menuBar.add(fileM); fileM.setText("File"); fileM.setMnemonic('F'); JMenuItem newItem = new JMenuItem(); fileM.add(newItem); newItem.setText("New"); newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)); newItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newScript(fileChooser); } }); JMenuItem loadItem = new JMenuItem(); fileM.add(loadItem); loadItem.setText("Open File..."); loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK)); loadItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int retVal = fileChooser.showOpenDialog(GroovyComponentCustomizer.this); if (retVal == JFileChooser.APPROVE_OPTION) { boolean ok = m_script.open(fileChooser.getSelectedFile()); if (!ok) { JOptionPane.showMessageDialog(GroovyComponentCustomizer.this, "Couldn't open file '" + fileChooser.getSelectedFile() + "'!"); } } } }); JMenuItem saveItem = new JMenuItem(); fileM.add(saveItem); saveItem.setText("Save"); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); saveItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_script.getFilename() != null) { save(null); } else { save(fileChooser); } } }); JMenuItem saveAsItem = new JMenuItem(); fileM.add(saveAsItem); saveAsItem.setText("Save As..."); saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK)); saveAsItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { save(fileChooser); } }); JMenu scriptM = new JMenu(); m_menuBar.add(scriptM); scriptM.setText("Script"); scriptM.setMnemonic('S'); JMenuItem compileItem = new JMenuItem(); scriptM.add(compileItem); compileItem.setText("Compile"); compileItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK)); compileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doCompile(); } }); Dimension d = new Dimension(600, 800); m_textPane.setMinimumSize(d); m_textPane.setPreferredSize(d); }
From source file:py.fpuna.lib.ExtendedDatabaseUtils.java
License:Open Source License
/** * Reads properties and sets up the database drivers. * * @throws Exception if an error occurs//from w ww .jav a 2 s . c o m */ public void init() throws Exception { if (DRIVERS_ERRORS == null) { DRIVERS_ERRORS = new Vector(); } try { PROPERTIES = Utils.readProperties(getPropertyFile()); // Register the drivers in jdbc DriverManager String drivers = PROPERTIES.getProperty("jdbcDriver", "jdbc.idbDriver"); if (drivers == null && dataSource == null) { throw new Exception("No database drivers (JDBC) specified"); } // The call to newInstance() is necessary on some platforms // (with some java VM implementations) if (drivers != null && dataSource == null) { StringTokenizer st = new StringTokenizer(drivers, ", "); while (st.hasMoreTokens()) { String driver = st.nextToken(); boolean result; try { Class.forName(driver); DRIVERS.addElement(driver); result = true; } catch (Exception e) { result = false; } if (m_Debug || (!result && !DRIVERS_ERRORS.contains(driver))) { System.err.println("Trying to add database driver (JDBC): " + driver + " - " + (result ? "Success!" : "Error, not in CLASSPATH?")); } if (!result) { DRIVERS_ERRORS.add(driver); } } } } catch (Exception ex) { System.err.println("Problem reading properties. Fix before continuing."); System.err.println(ex); } m_DatabaseURL = PROPERTIES.getProperty("jdbcURL", "jdbc:idb=experiments.prp"); m_stringType = PROPERTIES.getProperty("CREATE_STRING", "LONGVARCHAR"); m_intType = PROPERTIES.getProperty("CREATE_INT", "INT"); m_doubleType = PROPERTIES.getProperty("CREATE_DOUBLE", "DOUBLE"); m_checkForUpperCaseNames = PROPERTIES.getProperty("checkUpperCaseNames", "false").equals("true"); m_checkForLowerCaseNames = PROPERTIES.getProperty("checkLowerCaseNames", "false").equals("true"); m_setAutoCommit = PROPERTIES.getProperty("setAutoCommit", "true").equals("true"); m_createIndex = PROPERTIES.getProperty("createIndex", "false").equals("true"); setKeywords( PROPERTIES.getProperty("Keywords", "AND,ASC,BY,DESC,FROM,GROUP,INSERT,ORDER,SELECT,UPDATE,WHERE")); setKeywordsMaskChar(PROPERTIES.getProperty("KeywordsMaskChar", "_")); }