Package edu.ucla.sspace.vector

Examples of edu.ucla.sspace.vector.IntegerVector


     * @param word a word
     *
     * @return the {@code SemanticVector} for the provide word.
     */
    private IntegerVector getSemanticVector(String word) {
        IntegerVector v = wordToMeaning.get(word);
        if (v == null) {
            // lock on the word in case multiple threads attempt to add it at
            // once
            synchronized(this) {
                // recheck in case another thread added it while we were waiting
View Full Code Here


   /**
     * {@inheritDoc}
     */
    public Vector getVector(String word) {
        IntegerVector v = wordToMeaning.get(word);
        if (v == null) {
            return null;
        }
        return Vectors.immutable(v);
    }
View Full Code Here

            boolean calculateSemantics =
                semanticFilter.isEmpty() || semanticFilter.contains(focusWord)
                && !focusWord.equals(IteratorFactory.EMPTY_TOKEN);
           
            if (calculateSemantics) {
                IntegerVector focusMeaning = getSemanticVector(focusWord);

                // Sum up the index vector for all the surrounding words.  If
                // permutations are enabled, permute the index vector based on
                // its relative position to the focus word.
                int permutations = -(prevWords.size());       
View Full Code Here

                // Skip words that are rejected by the semantic filter.
                if (!acceptWord(focusWord))
                    continue;

                // Acquire the semantic vector for the focus word.
                IntegerVector focusMeaning = getSemanticVector(focusWord);

                // Create the path iterator for all acceptable paths rooted at
                // the focus word in the sentence.
                Iterator<DependencyPath> pathIter =
                    new DependencyIterator(nodes[i], acceptor, pathLength);
View Full Code Here

     * @param word a word that requires a semantic vector
     *
     * @return the {@code SemanticVector} representing {@code word}
     */
    private IntegerVector getSemanticVector(String word) {
        IntegerVector v = wordSpace.get(word);
        if (v == null) {
            // lock on the word in case multiple threads attempt to add it at
            // once
            synchronized(this) {
                // recheck in case another thread added it while we were waiting
View Full Code Here

            // Choose the smaller of the two to use in computing the dot
            // product.  Because it would be more expensive to compute the
            // intersection of the two sets, we assume that any potential
            // misses would be less of a performance hit.
            if (useA) {
                IntegerVector t = a;
                a = b;
                b = t;
            }

            for (IntegerEntry e : ((Iterable<IntegerEntry>)b)) {
View Full Code Here

                for (int i = 0; i < length - 1; ++i)
                    sb.append(dv.get(i)).append(" ");
                sb.append(dv.get(length - 1));
            }
            else if (vector instanceof IntegerVector) {
                IntegerVector iv = (IntegerVector)vector;
                for (int i = 0; i < length - 1; ++i)
                    sb.append(iv.get(i)).append(" ");
                sb.append(iv.get(length - 1));
            }
            else {
                for (int i = 0; i < length - 1; ++i)
                    sb.append(vector.getValue(i).doubleValue()).append(" ");
                sb.append(vector.getValue(length - 1).doubleValue());
View Full Code Here

   /**
     * {@inheritDoc}
     */
    public IntegerVector getVector(String word) {
        IntegerVector v = termToReflectiveSemantics.get(word);
        if (v == null) {
            return null;
        }
        return Vectors.immutable(v);
    }
View Full Code Here

            new ByteArrayOutputStream(4096);
        DataOutputStream dos = new DataOutputStream(compressedDocument);
        int tokens = 0; // count how many are in this document
        int unfilteredTokens = 0; // how many tokens remained after filtering

        IntegerVector docVector = createVector();
        docToVector.put(docIndex, docVector);

        while (documentTokens.hasNext()) {
            tokens++;
            String focusWord = documentTokens.next();
View Full Code Here

     */
    private void processIntDocument(IntegerVector docVector, int[] document) {

        // Make one pass through the document to build the document vector.
        for (int termIndex : document) {
            IntegerVector reflectiveVector =
                termToReflectiveSemantics.get(indexToTerm[termIndex]);
            // Lock on the term's vector to prevent another thread from updating
            // it concurrently
            synchronized(reflectiveVector) {
                VectorMath.add(reflectiveVector, docVector);
View Full Code Here

TOP

Related Classes of edu.ucla.sspace.vector.IntegerVector

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.