/** * Creates a string representation of the attribute that * gets displayed in the list * * @return a string representation of the attribute */ public String toString() { String result = "@attribute " + m_name + " " + (m_type != Attribute.NOMINAL ? Attribute.typeToString(m_type) : " {"); if (m_type == Attribute.NOMINAL) { result += m_nomOrDate + "}"; } else if (m_type == Attribute.DATE) { result += " " + m_nomOrDate; } return result; }
/** * Creates a string representation of the attribute that * gets displayed in the list * * @return a string representation of the attribute */ public String toString() { String result = "@attribute " + m_name + " " + (m_type != Attribute.NOMINAL ? Attribute.typeToString(m_type) : " {"); if (m_type == Attribute.NOMINAL) { result += m_nomOrDate + "}"; } else if (m_type == Attribute.DATE) { result += " " + m_nomOrDate; } return result; }
/** * Returns a string representation of the attribute type. * * @param att the attribute to return the type string for * @return the string representation of the attribute type */ public static String typeToString(Attribute att) { return typeToString(att.type()); }
/** * Returns a string representation of the attribute type. * * @param att the attribute to return the type string for * @return the string representation of the attribute type */ public static String typeToString(Attribute att) { return typeToString(att.type()); }
@Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (!m_deleteBut.isEnabled()) { m_deleteBut.setEnabled(true); } checkUpDown(); AttDef entry = m_list.getSelectedValue(); if (entry != null) { m_attNameField.setText(entry.m_name); m_attTypeField.setSelectedItem(Attribute.typeToString(entry.m_type)); m_nominalOrDateFormatField .setText(entry.m_nomOrDate != null ? entry.m_nomOrDate : ""); } } } });
@Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (!m_deleteBut.isEnabled()) { m_deleteBut.setEnabled(true); } checkUpDown(); AttDef entry = m_list.getSelectedValue(); if (entry != null) { m_attNameField.setText(entry.m_name); m_attTypeField.setSelectedItem(Attribute.typeToString(entry.m_type)); m_nominalOrDateFormatField .setText(entry.m_nomOrDate != null ? entry.m_nomOrDate : ""); } } } });
return "Types differ: " + typeToString(this) + " != " + typeToString(att);
return "Types differ: " + typeToString(this) + " != " + typeToString(att);
type = (String) att.getChild(TYPE).getValue(""); weight = (Double) att.getChild(WEIGHT).getValue(new Double(1.0)); if (type.equals(Attribute.typeToString(Attribute.NUMERIC))) { result = new Attribute(name); else if (type.equals(Attribute.typeToString(Attribute.NOMINAL))) { labels = att.getChild(LABELS); values = new ArrayList<String>(); else if (type.equals(Attribute.typeToString(Attribute.DATE))) { dateformat = (String) att.getChild(DATEFORMAT).getValue("yyyy-MM-dd'T'HH:mm:ss"); result = new Attribute(name, dateformat); else if (type.equals(Attribute.typeToString(Attribute.STRING))) { result = new Attribute(name, (ArrayList<String>) null);
type = (String) att.getChild(TYPE).getValue(""); weight = (Double) att.getChild(WEIGHT).getValue(new Double(1.0)); if (type.equals(Attribute.typeToString(Attribute.NUMERIC))) { result = new Attribute(name); else if (type.equals(Attribute.typeToString(Attribute.NOMINAL))) { labels = att.getChild(LABELS); values = new ArrayList<String>(); else if (type.equals(Attribute.typeToString(Attribute.DATE))) { dateformat = (String) att.getChild(DATEFORMAT).getValue("yyyy-MM-dd'T'HH:mm:ss"); result = new Attribute(name, dateformat); else if (type.equals(Attribute.typeToString(Attribute.STRING))) { result = new Attribute(name, (ArrayList<String>) null);
/** * Builds a string listing the attribute values in a specified range of indices, * separated by commas and enclosed in brackets. * * @param instance the instance to print the values from * @return a string listing values of the attributes in the range */ protected String attributeValuesString(Instance instance) { StringBuffer text = new StringBuffer(); if (m_Attributes != null) { text.append(" <" + TAG_ATTRIBUTES + ">\n"); m_Attributes.setUpper(instance.numAttributes() - 1); for (int i=0; i<instance.numAttributes(); i++) { if (m_Attributes.isInRange(i) && i != instance.classIndex()) { text.append(" <" + TAG_ATTRIBUTE + " " + ATT_INDEX + "=\"" + (i+1) + "\"" + " " + ATT_NAME + "=\"" + sanitize(instance.attribute(i).name()) + "\"" + " " + ATT_TYPE + "=\"" + Attribute.typeToString(instance.attribute(i).type()) + "\"" + ">"); text.append(sanitize(instance.toString(i))); text.append("</" + TAG_ATTRIBUTE + ">\n"); } } text.append(" </" + TAG_ATTRIBUTES + ">\n"); } return text.toString(); }
/** * Builds a string listing the attribute values in a specified range of indices, * separated by commas and enclosed in brackets. * * @param instance the instance to print the values from * @return a string listing values of the attributes in the range */ protected String attributeValuesString(Instance instance) { StringBuffer text = new StringBuffer(); if (m_Attributes != null) { text.append(" <" + TAG_ATTRIBUTES + ">\n"); m_Attributes.setUpper(instance.numAttributes() - 1); for (int i=0; i<instance.numAttributes(); i++) { if (m_Attributes.isInRange(i) && i != instance.classIndex()) { text.append(" <" + TAG_ATTRIBUTE + " " + ATT_INDEX + "=\"" + (i+1) + "\"" + " " + ATT_NAME + "=\"" + sanitize(instance.attribute(i).name()) + "\"" + " " + ATT_TYPE + "=\"" + Attribute.typeToString(instance.attribute(i).type()) + "\"" + ">"); text.append(sanitize(instance.toString(i))); text.append("</" + TAG_ATTRIBUTE + ">\n"); } } text.append(" </" + TAG_ATTRIBUTES + ">\n"); } return text.toString(); }
"type mismatch - " + "model: " + Attribute.typeToString(modAtt) + " != incoming: " + Attribute.typeToString(incomingAtt)); problemCount++; } else {
throw new IllegalStateException( "Unhandled attribute type for attribute '" + instance.attribute(i).name() + ": " + Attribute.typeToString(instance.attribute(i).type()));
throw new IllegalStateException( "Unhandled attribute type for attribute '" + instance.attribute(i).name() + ": " + Attribute.typeToString(instance.attribute(i).type()));
System.err.println("Unhandled attribute type '" + Attribute.typeToString(data.attribute(index).type()) + "'!"); return null;
result.addPrimitive(TYPE, Attribute.typeToString(att)); result.addPrimitive(CLASS, (att.index() == inst.classIndex())); result.addPrimitive(WEIGHT, att.weight());
result.addPrimitive(TYPE, Attribute.typeToString(att)); result.addPrimitive(CLASS, (att.index() == inst.classIndex())); result.addPrimitive(WEIGHT, att.weight());
System.err.println( getName() + " [compareDatasets] datasets differ in attribute type at " + (x+1) + ": " + Attribute.typeToString(data1.attribute(x).type()) + " != " + Attribute.typeToString(data2.attribute(x).type()));
System.err.println( getName() + " [compareDatasets] datasets differ in attribute type at " + (x+1) + ": " + Attribute.typeToString(data1.attribute(x).type()) + " != " + Attribute.typeToString(data2.attribute(x).type()));