Package edu.udo.cs.wvtool.main

Examples of edu.udo.cs.wvtool.main.WVTWordVector


        // Close the output file
        wvw.close();
        outFile.close();

        // Just for demonstration: Create a vector from a String
        WVTWordVector q = wvt.createVector("cmu harvard net", wordList);

    }
View Full Code Here


        // Obtain the total number of documents and the document frequencies
        int numDocuments = wordList.getNumDocuments();
        int[] docFrequencies = wordList.getDocumentFrequencies();

        // Create the result structure
        WVTWordVector result = new WVTWordVector();
        double[] wv = new double[docFrequencies.length];

        // Create the vector

        // If the document contains at least one term
        if (numTermOccurences > 0) {
            double length = 0.0;
            for (int i = 0; i < wv.length; i++) {

                // Note: docFrequencies[i] is always > 0 as otherwise the word
                // would not be in the word list, it is also always smaller as
                // the total number of documents

                double idf = Math.log(((double) numDocuments) / ((double) docFrequencies[i]));

                wv[i] = (((double) frequencies[i]) / ((double) numTermOccurences)) * idf;

                length = length + wv[i] * wv[i];
            }

            length = Math.sqrt(length);

            // Normalize the vector
            if (length > 0.0)
                for (int i = 0; i < wv.length; i++)
                    wv[i] = wv[i] / length;

        } else
            for (int i = 0; i < wv.length; i++)
                wv[i] = 0.0;

        result.setDocumentInfo(d);
        result.setValues(wv);

        return result;

    }
View Full Code Here

    public WVTWordVector createVector(int[] frequencies, int numTermOccurences, WVTWordList wordList, WVTDocumentInfo d) {

        int numTerms = wordList.getNumWords();

        // Create the result structure
        WVTWordVector result = new WVTWordVector();
        double[] wv = new double[numTerms];

        // If document contains at least one term
        if (numTermOccurences > 0) {
            // Create the vector
            double length = 0.0;
            for (int i = 0; i < wv.length; i++) {
                wv[i] = ((double) frequencies[i]) / ((double) numTermOccurences);
                length += wv[i] * wv[i];
            }

            length = Math.sqrt(length);

            // Normalize the vector
            if (length > 0.0)
                for (int i = 0; i < wv.length; i++)
                    wv[i] = wv[i] / length;
        } else {
            for (int i = 0; i < wv.length; i++)
                wv[i] = 0.0;
        }
        result.setDocumentInfo(d);
        result.setValues(wv);

        return result;

    }
View Full Code Here

    int[] frequencies, int numTermOccurences, WVTWordList wordList, WVTDocumentInfo d) {

        int numTerms = wordList.getNumWords();

        // Create the result structure
        WVTWordVector result = new WVTWordVector();
        double[] wv = new double[numTerms];

        // Create the vector
        for (int i = 0; i < wv.length; i++)
            if (frequencies[i] > 0)
                wv[i] = 1;
            else
                wv[i] = 0;

        result.setDocumentInfo(d);
        result.setValues(wv);

        return result;

    }
View Full Code Here

    int[] frequencies, int numTermOccurences, WVTWordList wordList, WVTDocumentInfo d) {

        int numTerms = wordList.getNumWords();

        // Create the result structure
        WVTWordVector result = new WVTWordVector();
        double[] wv = new double[numTerms];

        // Create the vector
        for (int i = 0; i < wv.length; i++)
            wv[i] = frequencies[i];

        result.setDocumentInfo(d);
        result.setValues(wv);

        return result;

    }
View Full Code Here

        // Close the output file
        wvw.close();
        outFile.close();

        // Just for demonstration: Create a vector from a String
        WVTWordVector q = wvt.createVector("cmu harvard net", wordList);

    }
View Full Code Here

        // Close the output file
        wvw.close();
        outFile.close();

        // Just for demonstration: Create a vector from a String
        WVTWordVector q = wvt.createVector("cmu harvard net", wordList);

    }
View Full Code Here

TOP

Related Classes of edu.udo.cs.wvtool.main.WVTWordVector

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.