/** * Get the comma-separated list of labels that are added. * * @return the list of labels */ public String getLabels() { String result; int i; result = ""; for (i = 0; i < m_Labels.size(); i++) { if (i > 0) { result += ","; } result += Utils.quote(m_Labels.get(i)); } return result; }
/** * Get the comma-separated list of labels that are added. * * @return the list of labels */ public String getLabels() { String result; int i; result = ""; for (i = 0; i < m_Labels.size(); i++) { if (i > 0) { result += ","; } result += Utils.quote(m_Labels.get(i)); } return result; }
/** * returns the matrix in CSV format. * * @return the matrix as string */ public String toStringMatrix() { StringBuffer result; String[][] cells; int i; int n; result = new StringBuffer(); cells = toArray(); for (i = 0; i < cells.length; i++) { for (n = 0; n < cells[i].length; n++) { if (n > 0) result.append(","); result.append(Utils.quote(cells[i][n])); } result.append("\n"); } return result.toString(); }
/** * returns the matrix in CSV format. * * @return the matrix as string */ public String toStringMatrix() { StringBuffer result; String[][] cells; int i; int n; result = new StringBuffer(); cells = toArray(); for (i = 0; i < cells.length; i++) { for (n = 0; n < cells[i].length; n++) { if (n > 0) result.append(","); result.append(Utils.quote(cells[i][n])); } result.append("\n"); } return result.toString(); }
/** * Returns the dataset as a string in ARFF format. Strings are quoted if they * contain whitespace characters, or if they are a question mark. * * @return the dataset in ARFF format as a string */ @Override public String toString() { StringBuffer text = new StringBuffer(); text.append(ARFF_RELATION).append(" ").append(Utils.quote(m_RelationName)) .append("\n\n"); for (int i = 0; i < numAttributes(); i++) { text.append(attribute(i)).append("\n"); } text.append("\n").append(ARFF_DATA).append("\n"); text.append(stringWithoutHeader()); return text.toString(); }
/** * Returns the dataset as a string in ARFF format. Strings are quoted if they * contain whitespace characters, or if they are a question mark. * * @return the dataset in ARFF format as a string */ @Override public String toString() { StringBuffer text = new StringBuffer(); text.append(ARFF_RELATION).append(" ").append(Utils.quote(m_RelationName)) .append("\n\n"); for (int i = 0; i < numAttributes(); i++) { text.append(attribute(i)).append("\n"); } text.append("\n").append(ARFF_DATA).append("\n"); text.append(stringWithoutHeader()); return text.toString(); }
/** * Gets the current settings of the datagenerator RDG1. Removing of * blacklisted options has to be done in the derived class, that defines the * blacklist-entry. * * @return an array of strings suitable for passing to setOptions * @see #removeBlacklist(String[]) */ @Override public String[] getOptions() { Vector<String> result = new Vector<String>(); // to avoid endless loop if (!m_CreatingRelationName) { result.add("-r"); result.add(Utils.quote(getRelationNameToUse())); } if (getDebug()) { result.add("-d"); } result.add("-S"); result.add("" + getSeed()); return result.toArray(new String[result.size()]); }
/** * Gets the current settings of the datagenerator RDG1. Removing of * blacklisted options has to be done in the derived class, that defines the * blacklist-entry. * * @return an array of strings suitable for passing to setOptions * @see #removeBlacklist(String[]) */ @Override public String[] getOptions() { Vector<String> result = new Vector<String>(); // to avoid endless loop if (!m_CreatingRelationName) { result.add("-r"); result.add(Utils.quote(getRelationNameToUse())); } if (getDebug()) { result.add("-d"); } result.add("-S"); result.add("" + getSeed()); return result.toArray(new String[result.size()]); }
/** * returns a key for all the col names, for better readability if * the names got cut off. * * @return the key */ public String toStringKey() { String result; int i; result = "Key,\n"; for (i = 0; i < getColCount(); i++) { if (getColHidden(i)) continue; result += LEFT_PARENTHESES + (i+1) + RIGHT_PARENTHESES + "," + Utils.quote(removeFilterName(m_ColNames[i])) + "\n"; } return result; }
public static Attribute featureToAttribute(Feature feature) throws TextClassificationException { String name = Utils.quote(feature.getName()); Object value = feature.getValue(); Attribute attribute; // if value is a number then create a numeric attribute if (value instanceof Number) { attribute = new Attribute(name); } // if value is a boolean then create a numeric attribute else if (value instanceof Boolean) { attribute = new Attribute(name); } // if value is an Enum thene create a nominal attribute else if (value instanceof Enum) { Object[] enumConstants = value.getClass().getEnumConstants(); ArrayList<String> attributeValues = new ArrayList<String>(enumConstants.length); for (Object enumConstant : enumConstants) { attributeValues.add(enumConstant.toString()); } attribute = new Attribute(name, attributeValues); } else { attribute = new Attribute(name, (ArrayList<String>) null); } return attribute; }
public static Attribute featureToAttribute(Feature feature) throws TextClassificationException { String name = Utils.quote(feature.getName()); Object value = feature.getValue(); Attribute attribute; // if value is a number then create a numeric attribute if (value instanceof Number) { attribute = new Attribute(name); } // if value is a boolean then create a numeric attribute else if (value instanceof Boolean) { attribute = new Attribute(name); } // if value is an Enum thene create a nominal attribute else if (value instanceof Enum) { Object[] enumConstants = value.getClass().getEnumConstants(); ArrayList<String> attributeValues = new ArrayList<String>(enumConstants.length); for (Object enumConstant : enumConstants) { attributeValues.add(enumConstant.toString()); } attribute = new Attribute(name, attributeValues); } else { attribute = new Attribute(name, (ArrayList<String>) null); } return attribute; }
public static Attribute featureToAttribute(Feature feature, int attributeIndex) { String name = Utils.quote(feature.getName()); Object value = feature.getValue(); Attribute attribute; // if value is a number then create a numeric attribute if (value instanceof Number) { attribute = new Attribute(name); }// if value is a boolean then create a numeric attribute else if (value instanceof Boolean) { attribute = new Attribute(name); } // if value is an Enum thene create a nominal attribute else if (value instanceof Enum) { Object[] enumConstants = value.getClass().getEnumConstants(); ArrayList<String> attributeValues = new ArrayList<String>(enumConstants.length); for (Object enumConstant : enumConstants) { attributeValues.add(enumConstant.toString()); } attribute = new Attribute(name, attributeValues); } // if value is not a number, boolean, or enum, then we will create a // string attribute else { attribute = new Attribute(name, (ArrayList<String>) null); } return attribute; }
public static Attribute featureToAttribute(Feature feature) { String name = Utils.quote(feature.getName()); Object value = feature.getValue(); Attribute attribute; // if value is a number then create a numeric attribute if (value instanceof Number) { attribute = new Attribute(name); }// if value is a boolean then create a numeric attribute else if (value instanceof Boolean) { attribute = new Attribute(name); } // if value is an Enum thene create a nominal attribute else if (value instanceof Enum) { Object[] enumConstants = value.getClass().getEnumConstants(); ArrayList<String> attributeValues = new ArrayList<String>(enumConstants.length); for (Object enumConstant : enumConstants) { attributeValues.add(enumConstant.toString()); } attribute = new Attribute(name, attributeValues); } // if value is not a number, boolean, or enum, then we will create a // string attribute else { attribute = new Attribute(name, (ArrayList<String>) null); } return attribute; } }
|| m_Dataset.attribute(m_Indices[i]).isString()) { text.append(m_Indices[i] + " " + Utils.quote(m_Dataset.attribute(m_Indices[i]).value(1))); } else { text.append(m_Indices[i] + " 1");
/** * returns a key for all the col names, for better readability if * the names got cut off. * * @return the key */ public String toStringKey() { String result; int i; result = "Key,\n"; for (i = 0; i < getColCount(); i++) { if (getColHidden(i)) continue; result += LEFT_PARENTHESES + (i+1) + RIGHT_PARENTHESES + "," + Utils.quote(removeFilterName(m_ColNames[i])) + "\n"; } return result; }
public static Attribute featureToAttribute(Feature feature, int attributeIndex) { String name = Utils.quote(feature.getName()); Object value = feature.getValue(); Attribute attribute; // if value is a number then create a numeric attribute if (value instanceof Number) { attribute = new Attribute(name); }// if value is a boolean then create a numeric attribute else if (value instanceof Boolean) { attribute = new Attribute(name); } // if value is an Enum thene create a nominal attribute else if (value instanceof Enum) { Object[] enumConstants = value.getClass().getEnumConstants(); ArrayList<String> attributeValues = new ArrayList<String>(enumConstants.length); for (Object enumConstant : enumConstants) { attributeValues.add(enumConstant.toString()); } attribute = new Attribute(name, attributeValues); } // if value is not a number, boolean, or enum, then we will create a // string attribute else { attribute = new Attribute(name, (ArrayList<String>) null); } return attribute; }
throws TextClassificationException String name = Utils.quote(featureName); Attribute attribute;
output = Utils.quote(input); assertTrue("No quoting necessary", !output.startsWith("'") && !output.endsWith("'")); output = Utils.quote(input); assertTrue("Empty string quoted", output.startsWith("'") && output.endsWith("'")); assertTrue("Empty string restored", input.equals(Utils.unquote(output))); output = Utils.quote(input); assertTrue("Blank quoted", output.startsWith("'") && output.endsWith("'")); assertTrue("Blank restored", input.equals(Utils.unquote(output))); output = Utils.quote(input); assertTrue(">" + input + "< quoted", output.startsWith("'") && output.endsWith("'")); assertTrue(">" + input + "< restored", input.equals(Utils.unquote(output))); output = Utils.quote(input); assertTrue(">" + input + "< quoted", output.startsWith("'") && output.endsWith("'")); assertTrue(">" + input + "< restored", input.equals(Utils.unquote(output))); output = Utils.quote(input); assertTrue(">" + input + "< quoted", output.startsWith("'") && output.endsWith("'")); assertTrue(">" + input + "< restored", input.equals(Utils.unquote(output))); output = Utils.quote(input); assertTrue(">" + input + "< quoted", output.startsWith("'") && output.endsWith("'")); assertTrue(">" + input + "< restored", input.equals(Utils.unquote(output))); output = Utils.quote(input); assertTrue(">" + input + "< quoted", output.startsWith("'") && output.endsWith("'"));