📄 utils.html
字号:
<DD><DL><DT><B>Parameters:</B><DD><CODE>flag</CODE> - the character indicating the option.<DD><CODE>options</CODE> - the array of strings containing all the options.<DT><B>Returns:</B><DD>the indicated option or an empty string<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if the option indicated by the flag can't be found</DL></DD></DL><HR><A NAME="getOption(java.lang.String, java.lang.String[])"><!-- --></A><H3>getOption</H3><PRE>public static java.lang.String <B>getOption</B>(java.lang.String flag, java.lang.String[] options) throws java.lang.Exception</PRE><DL><DD>Gets an option indicated by a flag "-String" from the given array of strings. Stops searching at the first marker "--". Replaces flag and option with empty strings.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>flag</CODE> - the String indicating the option.<DD><CODE>options</CODE> - the array of strings containing all the options.<DT><B>Returns:</B><DD>the indicated option or an empty string<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if the option indicated by the flag can't be found</DL></DD></DL><HR><A NAME="getOptionPos(char, java.lang.String[])"><!-- --></A><H3>getOptionPos</H3><PRE>public static int <B>getOptionPos</B>(char flag, java.lang.String[] options)</PRE><DL><DD>Gets the index of an option or flag indicated by a flag "-Char" from the given array of strings. Stops searching at the first marker "--".<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>flag</CODE> - the character indicating the option.<DD><CODE>options</CODE> - the array of strings containing all the options.<DT><B>Returns:</B><DD>the position if found, or -1 otherwise</DL></DD></DL><HR><A NAME="getOptionPos(java.lang.String, java.lang.String[])"><!-- --></A><H3>getOptionPos</H3><PRE>public static int <B>getOptionPos</B>(java.lang.String flag, java.lang.String[] options)</PRE><DL><DD>Gets the index of an option or flag indicated by a flag "-String" from the given array of strings. Stops searching at the first marker "--".<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>flag</CODE> - the String indicating the option.<DD><CODE>options</CODE> - the array of strings containing all the options.<DT><B>Returns:</B><DD>the position if found, or -1 otherwise</DL></DD></DL><HR><A NAME="quote(java.lang.String)"><!-- --></A><H3>quote</H3><PRE>public static java.lang.String <B>quote</B>(java.lang.String string)</PRE><DL><DD>Quotes a string if it contains special characters. The following rules are applied: A character is backquoted version of it is one of <tt>" ' % \ \n \r \t</tt>. A string is enclosed within single quotes if a character has been backquoted using the previous rule above or contains <tt>{ }</tt> or is exactly equal to the strings <tt>, ? space or ""</tt> (empty string). A quoted question mark distinguishes it from the missing value which is represented as an unquoted question mark in arff files.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the string to be quoted<DT><B>Returns:</B><DD>the string (possibly quoted)<DT><B>See Also:</B><DD><A HREF="../../weka/core/Utils.html#unquote(java.lang.String)"><CODE>unquote(String)</CODE></A></DL></DD></DL><HR><A NAME="unquote(java.lang.String)"><!-- --></A><H3>unquote</H3><PRE>public static java.lang.String <B>unquote</B>(java.lang.String string)</PRE><DL><DD>unquotes are previously quoted string (but only if necessary), i.e., it removes the single quotes around it. Inverse to quote(String).<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the string to process<DT><B>Returns:</B><DD>the unquoted string<DT><B>See Also:</B><DD><A HREF="../../weka/core/Utils.html#quote(java.lang.String)"><CODE>quote(String)</CODE></A></DL></DD></DL><HR><A NAME="backQuoteChars(java.lang.String)"><!-- --></A><H3>backQuoteChars</H3><PRE>public static java.lang.String <B>backQuoteChars</B>(java.lang.String string)</PRE><DL><DD>Converts carriage returns and new lines in a string into \r and \n. Backquotes the following characters: ` " \ \t and %<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the string<DT><B>Returns:</B><DD>the converted string<DT><B>See Also:</B><DD><A HREF="../../weka/core/Utils.html#unbackQuoteChars(java.lang.String)"><CODE>unbackQuoteChars(String)</CODE></A></DL></DD></DL><HR><A NAME="convertNewLines(java.lang.String)"><!-- --></A><H3>convertNewLines</H3><PRE>public static java.lang.String <B>convertNewLines</B>(java.lang.String string)</PRE><DL><DD>Converts carriage returns and new lines in a string into \r and \n.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the string<DT><B>Returns:</B><DD>the converted string</DL></DD></DL><HR><A NAME="revertNewLines(java.lang.String)"><!-- --></A><H3>revertNewLines</H3><PRE>public static java.lang.String <B>revertNewLines</B>(java.lang.String string)</PRE><DL><DD>Reverts \r and \n in a string into carriage returns and new lines.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the string<DT><B>Returns:</B><DD>the converted string</DL></DD></DL><HR><A NAME="partitionOptions(java.lang.String[])"><!-- --></A><H3>partitionOptions</H3><PRE>public static java.lang.String[] <B>partitionOptions</B>(java.lang.String[] options)</PRE><DL><DD>Returns the secondary set of options (if any) contained in the supplied options array. The secondary set is defined to be any options after the first "--". These options are removed from the original options array.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>options</CODE> - the input array of options<DT><B>Returns:</B><DD>the array of secondary options</DL></DD></DL><HR><A NAME="unbackQuoteChars(java.lang.String)"><!-- --></A><H3>unbackQuoteChars</H3><PRE>public static java.lang.String <B>unbackQuoteChars</B>(java.lang.String string)</PRE><DL><DD>The inverse operation of backQuoteChars(). Converts back-quoted carriage returns and new lines in a string to the corresponding character ('\r' and '\n'). Also "un"-back-quotes the following characters: ` " \ \t and %<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the string<DT><B>Returns:</B><DD>the converted string<DT><B>See Also:</B><DD><A HREF="../../weka/core/Utils.html#backQuoteChars(java.lang.String)"><CODE>backQuoteChars(String)</CODE></A></DL></DD></DL><HR><A NAME="splitOptions(java.lang.String)"><!-- --></A><H3>splitOptions</H3><PRE>public static java.lang.String[] <B>splitOptions</B>(java.lang.String quotedOptionString) throws java.lang.Exception</PRE><DL><DD>Split up a string containing options into an array of strings, one for each option.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>quotedOptionString</CODE> - the string containing the options<DT><B>Returns:</B><DD>the array of options<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - in case of an unterminated string, unknown character or a parse error</DL></DD></DL><HR><A NAME="joinOptions(java.lang.String[])"><!-- --></A><H3>joinOptions</H3><PRE>public static java.lang.String <B>joinOptions</B>(java.lang.String[] optionArray)</PRE><DL><DD>Joins all the options in an option array into a single string, as might be used on the command line.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>optionArray</CODE> - the array of options<DT><B>Returns:</B><DD>the string containing all options.</DL></DD></DL><HR><A NAME="forName(java.lang.Class, java.lang.String, java.lang.String[])"><!-- --></A><H3>forName</H3><PRE>public static java.lang.Object <B>forName</B>(java.lang.Class classType, java.lang.String className, java.lang.String[] options) throws java.lang.Exception</PRE><DL><DD>Creates a new instance of an object given it's class name and (optional) arguments to pass to it's setOptions method. If the object implements OptionHandler and the options parameter is non-null, the object will have it's options set. Example use:<p> <code> <pre> String classifierName = Utils.getOption('W', options); Classifier c = (Classifier)Utils.forName(Classifier.class, classifierName, options); setClassifier(c); </pre></code><P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>classType</CODE> - the class that the instantiated object should be assignable to -- an exception is thrown if this is not the case<DD><CODE>className</CODE> - the fully qualified class name of the object<DD><CODE>options</CODE> - an array of options suitable for passing to setOptions. May be null. Any options accepted by the object will be removed from the array.<DT><B>Returns:</B><DD>the newly created object, ready for use.<DT><B>Throws:</B><DD><CODE>java.lang.Exception</CODE> - if the class name is invalid, or if the class is not assignable to the desired class type, or the options supplied are not acceptable to the object</DL></DD></DL><HR><A NAME="info(int[])"><!-- --></A><H3>info</H3><PRE>public static double <B>info</B>(int[] counts)</PRE><DL><DD>Computes entropy for an array of integers.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>counts</CODE> - array of counts<DT><B>Returns:</B><DD>- a log2 a - b log2 b - c log2 c + (a+b+c) log2 (a+b+c) when given array [a b c]</DL></DD></DL><HR><A NAME="smOrEq(double, double)"><!-- --></A><H3>smOrEq</H3><PRE>public static boolean <B>smOrEq</B>(double a, double b)</PRE><DL><DD>Tests if a is smaller or equal to b.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a double<DD><CODE>b</CODE> - a double</DL></DD></DL><HR><A NAME="grOrEq(double, double)"><!-- --></A><H3>grOrEq</H3><PRE>public static boolean <B>grOrEq</B>(double a, double b)</PRE><DL><DD>Tests if a is greater or equal to b.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a double<DD><CODE>b</CODE> - a double</DL></DD></DL><HR><A NAME="sm(double, double)"><!-- --></A><H3>sm</H3><PRE>public static boolean <B>sm</B>(double a, double b)</PRE><DL><DD>Tests if a is smaller than b.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a double<DD><CODE>b</CODE> - a double</DL></DD></DL><HR><A NAME="gr(double, double)"><!-- --></A><H3>gr</H3><PRE>public static boolean <B>gr</B>(double a, double b)</PRE><DL><DD>Tests if a is greater than b.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a double<DD><CODE>b</CODE> - a double</DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -