Package weka.experiment

Examples of weka.experiment.PropertyNode


  setVisible(false);
      }
    });
    m_RootObject = rootObject;
    m_Root = new DefaultMutableTreeNode(
       new PropertyNode(m_RootObject));
    createNodes(m_Root);
   
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    //    setBorder(BorderFactory.createTitledBorder("Select a property"));
View Full Code Here


   *
   * @param localNode a value of type 'DefaultMutableTreeNode'
   */
  protected void createNodes(DefaultMutableTreeNode localNode) {

    PropertyNode pNode = (PropertyNode)localNode.getUserObject();
    Object localObject = pNode.value;
    // Find all the properties of the object in the root node
    PropertyDescriptor localProperties[];
    try {
      BeanInfo bi = Introspector.getBeanInfo(localObject.getClass());
      localProperties = bi.getPropertyDescriptors();
    } catch (IntrospectionException ex) {
      System.err.println(Messages.getInstance().getString("PropertySelectorDialog_CreateNodes_Error_Text_First"));
      return;
    }

    // Put their values into child nodes.
    for (int i = 0; i < localProperties.length; i++) {
      // Don't display hidden or expert properties.
      if (localProperties[i].isHidden() || localProperties[i].isExpert()) {
  continue;
      }
      String name = localProperties[i].getDisplayName();
      Class type = localProperties[i].getPropertyType();
      Method getter = localProperties[i].getReadMethod();
      Method setter = localProperties[i].getWriteMethod();
      Object value = null;
      // Only display read/write properties.
      if (getter == null || setter == null) {
  continue;
      }
      try {
  Object args[] = { };
  value = getter.invoke(localObject, args);
  PropertyEditor editor = null;
  Class pec = localProperties[i].getPropertyEditorClass();
  if (pec != null) {
    try {
      editor = (PropertyEditor)pec.newInstance();
    } catch (Exception ex) {
    }
  }
  if (editor == null) {
    editor = PropertyEditorManager.findEditor(type);
  }
  if ((editor == null) || (value == null)) {
    continue;
  }
      } catch (InvocationTargetException ex) {
  System.err.println(Messages.getInstance().getString("PropertySelectorDialog_CreateNodes_Error_Text_Second") + name
         + Messages.getInstance().getString("PropertySelectorDialog_CreateNodes_Error_Text_Third")
         + ex.getTargetException());
  ex.getTargetException().printStackTrace();
  continue;
      } catch (Exception ex) {
  System.err.println(Messages.getInstance().getString("PropertySelectorDialog_CreateNodes_Error_Text_Fourth") + name
         + Messages.getInstance().getString("PropertySelectorDialog_CreateNodes_Error_Text_Fifth") + ex);
  ex.printStackTrace();
  continue;
      }
      // Make a child node
      DefaultMutableTreeNode child = new DefaultMutableTreeNode(
             new PropertyNode(value,
                  localProperties[i],
                  localObject.getClass()));
      localNode.add(child);
      createNodes(child);
    }
View Full Code Here

      int result = jd.showDialog();
      if (result == PropertySelectorDialog.APPROVE_OPTION) {
  System.err.println(Messages.getInstance().getString("PropertySelectorDialog_Main_Error_Text_First"));
  PropertyNode [] path = jd.getPath();
  for (int i = 0; i < path.length; i++) {
    PropertyNode pn = path[i];
    System.err.println("" + (i + 1) + "  " + pn.toString()
           + " " + pn.value.toString());
  }
      } else {
  System.err.println(Messages.getInstance().getString("PropertySelectorDialog_Main_Error_Text_Second"));
      }
View Full Code Here

      cvrp.setNumFolds(m_numFolds);
      cvrp.setSplitEvaluator(se);
     
      PropertyNode[] propertyPath = new PropertyNode[2];
      try {
  propertyPath[0] = new PropertyNode(se, new PropertyDescriptor("splitEvaluator",
                      CrossValidationResultProducer.class),
             CrossValidationResultProducer.class);
  propertyPath[1] = new PropertyNode(sec, new PropertyDescriptor("classifier",
                       se.getClass()),
             se.getClass());
      } catch (IntrospectionException e) {
  e.printStackTrace();
      }
     
      m_Exp.setResultProducer(cvrp);
      m_Exp.setPropertyPath(propertyPath);

    } else {
      RandomSplitResultProducer rsrp = new RandomSplitResultProducer();
      rsrp.setRandomizeData(m_ExperimentTypeCBox.getSelectedItem() == TYPE_RANDOMSPLIT_TEXT);
      rsrp.setTrainPercent(m_trainPercent);
      rsrp.setSplitEvaluator(se);

      PropertyNode[] propertyPath = new PropertyNode[2];
      try {
  propertyPath[0] = new PropertyNode(se, new PropertyDescriptor("splitEvaluator",
                      RandomSplitResultProducer.class),
             RandomSplitResultProducer.class);
  propertyPath[1] = new PropertyNode(sec, new PropertyDescriptor("classifier",
                       se.getClass()),
             se.getClass());
      } catch (IntrospectionException e) {
  e.printStackTrace();
      }
View Full Code Here

  setVisible(false);
      }
    });
    m_RootObject = rootObject;
    m_Root = new DefaultMutableTreeNode(
       new PropertyNode(m_RootObject));
    createNodes(m_Root);
   
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    //    setBorder(BorderFactory.createTitledBorder("Select a property"));
View Full Code Here

   *
   * @param localNode a value of type 'DefaultMutableTreeNode'
   */
  protected void createNodes(DefaultMutableTreeNode localNode) {

    PropertyNode pNode = (PropertyNode)localNode.getUserObject();
    Object localObject = pNode.value;
    // Find all the properties of the object in the root node
    PropertyDescriptor localProperties[];
    try {
      BeanInfo bi = Introspector.getBeanInfo(localObject.getClass());
      localProperties = bi.getPropertyDescriptors();
    } catch (IntrospectionException ex) {
      System.err.println("PropertySelectorDialog: Couldn't introspect");
      return;
    }

    // Put their values into child nodes.
    for (int i = 0; i < localProperties.length; i++) {
      // Don't display hidden or expert properties.
      if (localProperties[i].isHidden() || localProperties[i].isExpert()) {
  continue;
      }
      String name = localProperties[i].getDisplayName();
      Class type = localProperties[i].getPropertyType();
      Method getter = localProperties[i].getReadMethod();
      Method setter = localProperties[i].getWriteMethod();
      Object value = null;
      // Only display read/write properties.
      if (getter == null || setter == null) {
  continue;
      }
      try {
  Object args[] = { };
  value = getter.invoke(localObject, args);
  PropertyEditor editor = null;
  Class pec = localProperties[i].getPropertyEditorClass();
  if (pec != null) {
    try {
      editor = (PropertyEditor)pec.newInstance();
    } catch (Exception ex) {
    }
  }
  if (editor == null) {
    editor = PropertyEditorManager.findEditor(type);
  }
  if ((editor == null) || (value == null)) {
    continue;
  }
      } catch (InvocationTargetException ex) {
  System.err.println("Skipping property " + name
         + " ; exception on target: "
         + ex.getTargetException());
  ex.getTargetException().printStackTrace();
  continue;
      } catch (Exception ex) {
  System.err.println("Skipping property " + name
         + " ; exception: " + ex);
  ex.printStackTrace();
  continue;
      }
      // Make a child node
      DefaultMutableTreeNode child = new DefaultMutableTreeNode(
             new PropertyNode(value,
                  localProperties[i],
                  localObject.getClass()));
      localNode.add(child);
      createNodes(child);
    }
View Full Code Here

      int result = jd.showDialog();
      if (result == PropertySelectorDialog.APPROVE_OPTION) {
  System.err.println("Property Selected");
  PropertyNode [] path = jd.getPath();
  for (int i = 0; i < path.length; i++) {
    PropertyNode pn = path[i];
    System.err.println("" + (i + 1) + "  " + pn.toString()
           + " " + pn.value.toString());
  }
      } else {
  System.err.println("Cancelled");
      }
View Full Code Here

    * @return the node that was created
    * @throws Exception if the DOM creation fails
    */
   public Element writePropertyNode(Element parent, Object o, String name) throws Exception {
      Element              node;
      PropertyNode         pnode;
      Vector               children;
      int                  i;
      Element              child;

      // for debugging only
      if (DEBUG)
         trace(new Throwable(), name);
     
      m_CurrentNode = parent;
     
      pnode = (PropertyNode) o;
      node  = (Element) parent.appendChild(m_Document.getDocument().createElement(TAG_OBJECT));
      node.setAttribute(ATT_NAME, name);
      node.setAttribute(ATT_CLASS, pnode.getClass().getName());
      node.setAttribute(ATT_PRIMITIVE, VAL_NO);
      node.setAttribute(ATT_ARRAY, VAL_NO);
     
      if (pnode.value != null)
         invokeWriteToXML(node, pnode.value, NAME_PROPERTYNODE_VALUE);
View Full Code Here

         cls = Class.forName(parentClass);
      else
         cls = null;
     
      if (cls != null)
         result = new PropertyNode(value, new PropertyDescriptor(property, cls), cls);
      else
         result = new PropertyNode(value);
     
      return result;
   }
View Full Code Here

      cvrp.setNumFolds(m_numFolds);
      cvrp.setSplitEvaluator(se);
     
      PropertyNode[] propertyPath = new PropertyNode[2];
      try {
  propertyPath[0] = new PropertyNode(se, new PropertyDescriptor("splitEvaluator",
                      CrossValidationResultProducer.class),
             CrossValidationResultProducer.class);
  propertyPath[1] = new PropertyNode(sec, new PropertyDescriptor("classifier",
                       se.getClass()),
             se.getClass());
      } catch (IntrospectionException e) {
  e.printStackTrace();
      }
     
      m_Exp.setResultProducer(cvrp);
      m_Exp.setPropertyPath(propertyPath);

    } else {
      RandomSplitResultProducer rsrp = new RandomSplitResultProducer();
      rsrp.setRandomizeData(m_ExperimentTypeCBox.getSelectedItem() == TYPE_RANDOMSPLIT_TEXT);
      rsrp.setTrainPercent(m_trainPercent);
      rsrp.setSplitEvaluator(se);

      PropertyNode[] propertyPath = new PropertyNode[2];
      try {
  propertyPath[0] = new PropertyNode(se, new PropertyDescriptor("splitEvaluator",
                      RandomSplitResultProducer.class),
             RandomSplitResultProducer.class);
  propertyPath[1] = new PropertyNode(sec, new PropertyDescriptor("classifier",
                       se.getClass()),
             se.getClass());
      } catch (IntrospectionException e) {
  e.printStackTrace();
      }
View Full Code Here

TOP

Related Classes of weka.experiment.PropertyNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.