Package org.integratedmodelling.riskwiz.learning.data

Examples of org.integratedmodelling.riskwiz.learning.data.FastVector


        readStructure(st);
   
        st.ordinaryChar(',');
        st.ordinaryChar('\t');
   
        m_cumulativeStructure = new FastVector(m_structure.numAttributes());
        for (int i = 0; i < m_structure.numAttributes(); i++) {
            m_cumulativeStructure.addElement(new Hashtable());
        }
   
        // Instances result = new Instances(m_structure);
        m_cumulativeInstances = new FastVector();
        FastVector current;

        while ((current = getInstance(st)) != null) {
            m_cumulativeInstances.addElement(current);
        }
        br.close();
        // now determine the true structure of the data set
        FastVector atts = new FastVector(m_structure.numAttributes());

        for (int i = 0; i < m_structure.numAttributes(); i++) {
            String attname = m_structure.attribute(i).name();
            Hashtable tempHash = ((Hashtable) m_cumulativeStructure.elementAt(i));

            if (tempHash.size() == 0) {
                atts.addElement(new Attribute(attname));
            } else {
                FastVector values = new FastVector(tempHash.size());

                // add dummy objects in order to make the FastVector's size == capacity
                for (int z = 0; z < tempHash.size(); z++) {
                    values.addElement("dummy");
                }
                Enumeration e = tempHash.keys();

                while (e.hasMoreElements()) {
                    Object ob = e.nextElement();
                    // if (ob instanceof Double) {
                    int index = ((Integer) tempHash.get(ob)).intValue();

                    values.setElementAt(new String(ob.toString()), index);
                    // }
                }
                atts.addElement(new Attribute(attname, values));
            }
        }
View Full Code Here


     * </jml></pre>
     */
    private FastVector getInstance(StreamTokenizer tokenizer)
        throws IOException {

        FastVector current = new FastVector();

        // Check if end of file reached.
        ConverterUtils.getFirstToken(tokenizer);
        if (tokenizer.ttype == StreamTokenizer.TT_EOF) {
            return null;
        }
        boolean first = true;
        boolean wasSep;

        while (tokenizer.ttype != StreamTokenizer.TT_EOL
                && tokenizer.ttype != StreamTokenizer.TT_EOF) {
     
            // Get next token
            if (!first) {
                ConverterUtils.getToken(tokenizer);
            }

            if (tokenizer.ttype == ',' || tokenizer.ttype == '\t'
                    || tokenizer.ttype == StreamTokenizer.TT_EOL) {
                current.addElement("?");
                wasSep = true;
            } else if (tokenizer.ttype == '?') {
                wasSep = false;
                current.addElement(new String("'?'"));
            } else {
                wasSep = false;
                // try to parse as a number
                try {
                    double val = Double.valueOf(tokenizer.sval).doubleValue();

                    current.addElement(new Double(val));
                } catch (NumberFormatException e) {
                    // otherwise assume its an enumerated value
                    current.addElement(new String(tokenizer.sval));
                }
            }
     
            if (!wasSep) {
                ConverterUtils.getToken(tokenizer);
            }
            first = false;
        }
   
        // check number of values read
        if (current.size() != m_structure.numAttributes()) {
            ConverterUtils.errms(tokenizer,
                    "wrong number of values. Read " + current.size()
                    + ", expected " + m_structure.numAttributes());
        }

        // check for structure update
        try {
View Full Code Here

                    if (!tempHash.containsKey(ob)) {
                        // may have found a nominal value in what was previously thought to
                        // be a numeric variable.
                        if (tempHash.size() == 0) {
                            for (int j = 0; j < m_cumulativeInstances.size(); j++) {
                                FastVector tempUpdate = ((FastVector) m_cumulativeInstances.elementAt(
                                        j));
                                Object tempO = tempUpdate.elementAt(i);

                                if (tempO instanceof String) {// must have been a missing value
                                } else {
                                    if (!tempHash.containsKey(tempO)) {
                                        tempHash.put(
View Full Code Here

     *      signals: (IOException);
     * </jml></pre>
     */
    private void readHeader(StreamTokenizer tokenizer) throws IOException {
  
        FastVector attribNames = new FastVector();

        ConverterUtils.getFirstToken(tokenizer);
        if (tokenizer.ttype == StreamTokenizer.TT_EOF) {
            ConverterUtils.errms(tokenizer, "premature end of file");
        }

        while (tokenizer.ttype != StreamTokenizer.TT_EOL) {
            attribNames.addElement(new Attribute(tokenizer.sval));
            ConverterUtils.getToken(tokenizer);
        }
        String relationName;

        if (m_sourceFile != null) {
View Full Code Here

TOP

Related Classes of org.integratedmodelling.riskwiz.learning.data.FastVector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.