/** * Set the value of delimiters. For convenienve, the strings "\r", "\n", "\t", * "\'", "\\" get automatically translated into their character * representations '\r', '\n', '\t', '\'', '\\'. This means, one can either * use <code>setDelimiters("\r\n\t\\");</code> or * <code>setDelimiters("\\r\\n\\t\\\\");</code>. * * @param value Value to assign to delimiters. * @see Utils#unbackQuoteChars(String) */ public void setDelimiters(String value) { m_Delimiters = Utils.unbackQuoteChars(value); }
/** * Set the value of delimiters. For convenienve, the strings "\r", "\n", "\t", * "\'", "\\" get automatically translated into their character * representations '\r', '\n', '\t', '\'', '\\'. This means, one can either * use <code>setDelimiters("\r\n\t\\");</code> or * <code>setDelimiters("\\r\\n\\t\\\\");</code>. * * @param value Value to assign to delimiters. * @see Utils#unbackQuoteChars(String) */ public void setDelimiters(String value) { m_Delimiters = Utils.unbackQuoteChars(value); }
/** * Sets the character used as column separator. * * @param value the character to use */ public void setFieldSeparator(String value) { m_FieldSeparator = Utils.unbackQuoteChars(value); /* * if (m_FieldSeparator.length() != 1) { m_FieldSeparator = ","; System.err * .println( * "Field separator can only be a single character (exception being '\t'), " * + "defaulting back to '" + m_FieldSeparator + "'!"); } */ }
/** * Sets the character used as column separator. * * @param value the character to use */ public void setFieldSeparator(String value) { m_FieldSeparator = Utils.unbackQuoteChars(value); /* * if (m_FieldSeparator.length() != 1) { m_FieldSeparator = ","; System.err * .println( * "Field separator can only be a single character (exception being '\t'), " * + "defaulting back to '" + m_FieldSeparator + "'!"); } */ }
/** * Sets the character used as column separator. * * @param value the character to use */ public void setFieldSeparator(String value) { m_FieldSeparator = Utils.unbackQuoteChars(value); if (m_FieldSeparator.length() != 1) { m_FieldSeparator = ","; System.err .println("Field separator can only be a single character (exception being '\t'), " + "defaulting back to '" + m_FieldSeparator + "'!"); } }
/** * Sets the character used as column separator. * * @param value the character to use */ public void setFieldSeparator(String value) { m_FieldSeparator = Utils.unbackQuoteChars(value); if (m_FieldSeparator.length() != 1) { m_FieldSeparator = ","; System.err .println("Field separator can only be a single character (exception being '\t'), " + "defaulting back to '" + m_FieldSeparator + "'!"); } }
/** * Sets the character used as column separator. * * @param value the character to use */ public void setFieldSeparator(String value) { m_FieldSeparator = Utils.unbackQuoteChars(value); if (m_FieldSeparator.length() != 1) { m_FieldSeparator = ","; System.err .println("Field separator can only be a single character (exception being '\t'), " + "defaulting back to '" + m_FieldSeparator + "'!"); } }
/** * unquotes are previously quoted string (but only if necessary), i.e., it * removes the single quotes around it. Inverse to quote(String). * * @param string the string to process * @return the unquoted string * @see #quote(String) */ public static String unquote(String string) { if (string.startsWith("'") && string.endsWith("'")) { string = string.substring(1, string.length() - 1); if ((string.indexOf("\\n") != -1) || (string.indexOf("\\r") != -1) || (string.indexOf("\\'") != -1) || (string.indexOf("\\\"") != -1) || (string.indexOf("\\\\") != -1) || (string.indexOf("\\t") != -1) || (string.indexOf("\\%") != -1) || (string.indexOf("\\u001E") != -1)) { string = unbackQuoteChars(string); } } return string; }
/** * unquotes are previously quoted string (but only if necessary), i.e., it * removes the single quotes around it. Inverse to quote(String). * * @param string the string to process * @return the unquoted string * @see #quote(String) */ public static String unquote(String string) { if (string.startsWith("'") && string.endsWith("'")) { string = string.substring(1, string.length() - 1); if ((string.indexOf("\\n") != -1) || (string.indexOf("\\r") != -1) || (string.indexOf("\\'") != -1) || (string.indexOf("\\\"") != -1) || (string.indexOf("\\\\") != -1) || (string.indexOf("\\t") != -1) || (string.indexOf("\\%") != -1) || (string.indexOf("\\u001E") != -1)) { string = unbackQuoteChars(string); } } return string; }
optStr = replaceStrings(optStr, toReplace, replacements); } else { optStr = unbackQuoteChars(optStr);
optStr = replaceStrings(optStr, toReplace, replacements); } else { optStr = unbackQuoteChars(optStr);
/** * tests backQuoteChars and unbackQuoteChars * * @see Utils#backQuoteChars(String) * @see Utils#unbackQuoteChars(String) */ public void testBackQuoting() { String input; String output; input = "blahblah"; output = Utils.backQuoteChars(input); assertTrue("No backquoting necessary", input.equals(output)); input = "\r\n\t'\"%"; output = Utils.backQuoteChars(input); assertTrue(">" + input + "< restored", input.equals(Utils.unbackQuoteChars(output))); input = "\\r\\n\\t\\'\\\"\\%"; output = Utils.backQuoteChars(input); assertTrue(">" + input + "< restored", input.equals(Utils.unbackQuoteChars(output))); input = Utils.joinOptions(new StringToWordVector().getOptions()); output = Utils.backQuoteChars(input); assertTrue(">" + input + "< restored", input.equals(Utils.unbackQuoteChars(output))); }
/** * tests backQuoteChars and unbackQuoteChars * * @see Utils#backQuoteChars(String) * @see Utils#unbackQuoteChars(String) */ public void testBackQuoting() { String input; String output; input = "blahblah"; output = Utils.backQuoteChars(input); assertTrue("No backquoting necessary", input.equals(output)); input = "\r\n\t'\"%"; output = Utils.backQuoteChars(input); assertTrue(">" + input + "< restored", input.equals(Utils.unbackQuoteChars(output))); input = "\\r\\n\\t\\'\\\"\\%"; output = Utils.backQuoteChars(input); assertTrue(">" + input + "< restored", input.equals(Utils.unbackQuoteChars(output))); input = Utils.joinOptions(new StringToWordVector().getOptions()); output = Utils.backQuoteChars(input); assertTrue(">" + input + "< restored", input.equals(Utils.unbackQuoteChars(output))); }
vals[index] = data.attribute(index).indexOfValue(Utils.unbackQuoteChars(Utils.unquote(value))); if (vals[index] == -1) { System.err.println("Unknown label '" + value + "' for attribute #" + (index+1) + "!");
vals[index] = data.attribute(index).indexOfValue(Utils.unbackQuoteChars(Utils.unquote(value))); if (vals[index] == -1) { System.err.println("Unknown label '" + value + "' for attribute #" + (index+1) + "!");
setAttributeName(Utils.unbackQuoteChars(Utils.getOption('N', options)));
setAttributeName(Utils.unbackQuoteChars(Utils.getOption('N', options)));
/** * Sets the options. * * @param options the options * @throws Exception if parsing fails */ @Override public void setOptions(String[] options) throws Exception { setNotes(Utils.unbackQuoteChars(OptionUtils.parse(options, "notes", ""))); setClassifiers(OptionUtils.parse(options, 'C', MultiLabelClassifier.class)); setDatasetProvider((DatasetProvider) OptionUtils.parse(options, 'D', getDefaultDatasetProvider())); setEvaluator((Evaluator) OptionUtils.parse(options, 'E', getDefaultEvaluator())); setStatisticsHandler((EvaluationStatisticsHandler) OptionUtils.parse(options, 'S', getDefaultStatisticsHandler())); }
/** * Sets the options. * * @param options the options * @throws Exception if parsing fails */ @Override public void setOptions(String[] options) throws Exception { setNotes(Utils.unbackQuoteChars(OptionUtils.parse(options, "notes", ""))); setClassifiers(OptionUtils.parse(options, 'C', MultiLabelClassifier.class)); setDatasetProvider((DatasetProvider) OptionUtils.parse(options, 'D', getDefaultDatasetProvider())); setEvaluator((Evaluator) OptionUtils.parse(options, 'E', getDefaultEvaluator())); setStatisticsHandler((EvaluationStatisticsHandler) OptionUtils.parse(options, 'S', getDefaultStatisticsHandler())); }