Class ConvertToARFF


  • public class ConvertToARFF
    extends java.lang.Object
    Convert a BugCollection into ARFF format. See Witten and Frank, Data Mining, ISBN 1-55860-552-5.
    Author:
    David Hovemeyer
    See Also:
    BugCollection, BugInstance
    • Constructor Detail

      • ConvertToARFF

        public ConvertToARFF()
    • Method Detail

      • collectionToRange

        public static java.lang.String collectionToRange​(java.util.Collection<java.lang.String> collection)
      • setAppName

        public void setAppName​(java.lang.String appName)
      • setNodeSelectionXpath

        public void setNodeSelectionXpath​(java.lang.String nodeSelectionXpath)
        Set the xpath expression used to select BugInstance nodes.
        Parameters:
        nodeSelectionXpath - the node selection xpath expression
      • getNumAttributes

        public int getNumAttributes()
      • dropUnclassifiedWarnings

        public void dropUnclassifiedWarnings()
      • addNominalAttribute

        public void addNominalAttribute​(java.lang.String name,
                                        java.lang.String xpath)
      • addBooleanAttribute

        public void addBooleanAttribute​(java.lang.String name,
                                        java.lang.String xpath)
      • addClassificationAttribute

        public void addClassificationAttribute()
      • addNumericAttribute

        public void addNumericAttribute​(java.lang.String name,
                                        java.lang.String xpath)
      • addPriorityAttribute

        public void addPriorityAttribute()
      • addIdAttribute

        public void addIdAttribute()
      • addAppNameAttribute

        public void addAppNameAttribute()
      • convert

        public void convert​(java.lang.String relationName,
                            org.dom4j.Document document,
                            java.lang.String appName,
                            java.io.Writer out)
                     throws java.io.IOException,
                            edu.umd.cs.findbugs.ml.ConvertToARFF.MissingNodeException
        Convert a single Document to ARFF format.
        Parameters:
        relationName - the relation name
        document - the Document
        appName - the application name
        out - Writer to write the ARFF output to
        Throws:
        java.io.IOException
        edu.umd.cs.findbugs.ml.ConvertToARFF.MissingNodeException
      • scan

        public void scan​(org.dom4j.Document document,
                         java.lang.String appName)
                  throws edu.umd.cs.findbugs.ml.ConvertToARFF.MissingNodeException,
                         java.io.IOException
        Scan a Document to find out the ranges of attributes. All Documents must be scanned before generating the ARFF header and instances.
        Parameters:
        document - the Document
        appName - the application name
        Throws:
        edu.umd.cs.findbugs.ml.ConvertToARFF.MissingNodeException
        java.io.IOException
      • generateHeader

        public void generateHeader​(java.lang.String relationName,
                                   java.io.Writer out)
                            throws edu.umd.cs.findbugs.ml.ConvertToARFF.MissingNodeException,
                                   java.io.IOException
        Generate ARFF header. Documents must have already been scanned.
        Parameters:
        relationName - the relation name
        out - Writer to write the ARFF output to
        Throws:
        edu.umd.cs.findbugs.ml.ConvertToARFF.MissingNodeException
        java.io.IOException
      • generateInstances

        public void generateInstances​(org.dom4j.Document document,
                                      java.lang.String appName,
                                      java.io.Writer out)
                               throws edu.umd.cs.findbugs.ml.ConvertToARFF.MissingNodeException,
                                      java.io.IOException
        Generate instances from given Document. Document should already have been scanned, and the ARFF header generated.
        Parameters:
        document - the Document
        appName - the application name
        out - Writer to write the ARFF output to
        Throws:
        edu.umd.cs.findbugs.ml.ConvertToARFF.MissingNodeException
        java.io.IOException
      • scanAttributeList

        public void scanAttributeList​(ConvertToARFF.AttributeCallback callback)
                               throws edu.umd.cs.findbugs.ml.ConvertToARFF.MissingNodeException,
                                      java.io.IOException
        Apply a callback to all Attributes.
        Parameters:
        callback - the callback
        Throws:
        edu.umd.cs.findbugs.ml.ConvertToARFF.MissingNodeException
        java.io.IOException
      • toAppName

        public java.lang.String toAppName​(java.lang.String fileName)
      • main

        public static void main​(java.lang.String[] argv)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception