All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.deeplearning4j.word2vec.viterbi.CounterUtil Maven / Gradle / Ivy

The newest version!
package org.deeplearning4j.word2vec.viterbi;

import java.util.*;

import org.deeplearning4j.berkeley.CounterMap;
import org.deeplearning4j.berkeley.Pair;
import org.jblas.DoubleMatrix;


public class CounterUtil {
	
	public static DoubleMatrix convert(CounterMap counter) {
		DoubleMatrix ret = new DoubleMatrix(counter.size(),counter.keySet().size());
		Iterator> iter = counter.getPairIterator();
		
		for(Pair next = iter.next(); iter.hasNext(); next = iter.next()) {
			int firstInt = next.getFirst();
			int secondInt = next.getSecond();
			ret.put(firstInt, secondInt,counter.getCount(next.getFirst(),next.getSecond()));
		}
		
		return ret;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy