本文整理汇总了Java中gnu.trove.TObjectDoubleHashMap类的典型用法代码示例。如果您正苦于以下问题:Java TObjectDoubleHashMap类的具体用法?Java TObjectDoubleHashMap怎么用?Java TObjectDoubleHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TObjectDoubleHashMap类属于gnu.trove包,在下文中一共展示了TObjectDoubleHashMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: argmax
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
/** Returns the key in map that has the greatest score */
public static Object argmax (TObjectDoubleHashMap map)
{
// A local class! Yes, Virginia, this is legal Java.
class Accumulator implements TObjectDoubleProcedure {
double bestVal = Double.NEGATIVE_INFINITY;
Object bestObj = null;
public boolean execute (Object a, double b)
{
if (b > bestVal) {
bestVal = b;
bestObj = a;
}
return true;
}
}
Accumulator procedure = new Accumulator ();
map.forEachEntry (procedure);
return procedure.bestObj;
}
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:22,代码来源:CollectionUtils.java
示例2: LRIdentificationModelSingleNode
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public LRIdentificationModelSingleNode(TObjectDoubleHashMap<String> paramList, ArrayList<String> frameLines, ArrayList<String> parseLines, String reg, double l, String initParamFile, WordNetRelations mWNR,THashMap<String,THashSet<String>> frameMap, String modelFile, String trainOrTest)
{
mParamList = paramList;
initializeParameterIndexes();
this.mFrameLines = frameLines;
mNumExamples = mFrameLines.size();
mFrameMap = frameMap;
initializeParameters();
totalNumberOfParams=paramList.size();
this.mParseLines = parseLines;
mReg=reg;
mLambda=l/mNumExamples;
mInitParamFile=initParamFile;
this.mWNR=mWNR;
resetAllGradients();
mFeatureCache = new THashMap<String,THashMap<String,Double>>();
mModelFile=modelFile;
mLookupChart = new TIntObjectHashMap<LogFormula>();
mTrainOrTest = ""+trainOrTest;
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:21,代码来源:LRIdentificationModelSingleNode.java
示例3: parseParamFile
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public static TObjectDoubleHashMap<String> parseParamFile(String paramsFile)
{
TObjectDoubleHashMap<String> startParamList = new TObjectDoubleHashMap<String>();
try {
BufferedReader fis = new BufferedReader(new FileReader(paramsFile));
String pattern = null;
int count = 0;
while ((pattern = fis.readLine()) != null)
{
StringTokenizer st = new StringTokenizer(pattern.trim(),"\t");
String paramName = st.nextToken().trim();
String rest = st.nextToken().trim();
String[] arr = rest.split(",");
double value = new Double(arr[0].trim());
boolean sign = new Boolean(arr[1].trim());
LDouble val = new LDouble(value,sign);
startParamList.put(paramName, val.exponentiate());
if(count%100000==0)
System.out.println("Processed param number:"+count);
count++;
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
return startParamList;
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:27,代码来源:FrameIdentificationGoldTargetsGoldFrames.java
示例4: train
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public static void train(ArrayList<String> trainFrameLines, ArrayList<String> trainParseLines, FNModelOptions opts)
{
WordNetRelations wnr = new WordNetRelations(opts.stopWordsFile.get(), opts.wnConfigFile.get());
TObjectDoubleHashMap<String> paramList = parseParamFile(opts.modelFile.get());
THashMap<String,THashSet<String>> frameMap = (THashMap<String,THashSet<String>>)SerializedObjects.readSerializedObject(opts.frameNetMapFile.get());
LRIdentificationModelSingleNode lrModel = new LRIdentificationModelSingleNode(paramList,
trainFrameLines,
trainParseLines,
opts.reg.get(),
opts.lambda.get(),
null,
wnr,
frameMap,
opts.modelFile.get(),
"train");
System.out.println(new Date());
LogFormula f = lrModel.getFormula(7000);
System.out.println("Value:"+f.evaluate(lrModel));
System.out.println("Taking derivatives...."+new Date());
System.out.println("Finished taking derivatives...."+new Date());
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:22,代码来源:FrameIdentifier.java
示例5: parseParamFile
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
private static TObjectDoubleHashMap<String> parseParamFile(String paramsFile)
{
TObjectDoubleHashMap<String> startParamList = new TObjectDoubleHashMap<String>();
try {
BufferedReader fis = new BufferedReader(new FileReader(paramsFile));
String pattern = null;
int count = 0;
while ((pattern = fis.readLine()) != null)
{
StringTokenizer st = new StringTokenizer(pattern.trim(),"\t");
String paramName = st.nextToken().trim();
String rest = st.nextToken().trim();
String[] arr = rest.split(",");
double value = new Double(arr[0].trim());
boolean sign = new Boolean(arr[1].trim());
LDouble val = new LDouble(value,sign);
startParamList.put(paramName, val.exponentiate());
if(count%100000==0)
System.out.println("Processed param number:"+count);
count++;
}
} catch (IOException ioe) {
System.err.println("Caught exception while parsing the cached file '" + paramsFile + "' : " + StringUtils.stringifyException(ioe));
}
return startParamList;
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:27,代码来源:FrameIdentifier.java
示例6: FrameIdentificationDecoder
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public FrameIdentificationDecoder(TObjectDoubleHashMap<String> paramList,
String reg,
double l,
WordNetRelations mwnr,
THashMap<String, THashSet<String>> frameMap,
THashMap<String, THashSet<String>> wnRelationCache)
{
super(paramList,reg,l,mwnr,frameMap);
initializeParameterIndexes();
this.mParamList=paramList;
mReg=reg;
mLambda=l;
mWNR=mwnr;
mFrameMap=frameMap;
totalNumberOfParams=paramList.size();
initializeParameters();
mLookupChart = new TIntObjectHashMap<LogFormula>();
mWnRelationsCache = wnRelationCache;
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:20,代码来源:FrameIdentificationDecoder.java
示例7: add
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public static TObjectDoubleHashMap<String> add(TObjectDoubleHashMap<String> vector,
TObjectDoubleHashMap<String> oldVector, int count) {
TObjectDoubleHashMap<String> res = new TObjectDoubleHashMap<String>();
if (oldVector == null) {
oldVector = new TObjectDoubleHashMap<String>();
}
String[] vKeys = new String[vector.size()];
vector.keys(vKeys);
for (int i = 0; i < vKeys.length; i++) {
double value = vector.get(vKeys[i]) / (double)count;
if (oldVector.contains(vKeys[i])) {
res.put(vKeys[i], value + oldVector.get(vKeys[i]));
oldVector.remove(vKeys[i]);
} else {
res.put(vKeys[i], value);
}
}
String[] oldKeys = new String[oldVector.size()];
oldVector.keys(oldKeys);
for (int i = 0; i < oldKeys.length; i++) {
res.put(oldKeys[i], oldVector.get(oldKeys[i]));
}
return res;
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:25,代码来源:NormalizeLinDekNeighbors.java
示例8: FastFrameIdentifier
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public FastFrameIdentifier(TObjectDoubleHashMap<String> paramList,
String reg,
double l,
THashMap<String, THashSet<String>> frameMap,
THashMap<String, THashSet<String>> wnRelationCache,
THashMap<String,THashSet<String>> hvCorrespondenceMap,
Map<String, Set<String>> relatedWordsForWord,
Map<String, Map<String, Set<String>>> revisedRelationsMap,
Map<String, String> hvLemmas)
{
super(paramList,reg,l,null,frameMap);
initializeParameterIndexes();
this.mParamList=paramList;
mReg=reg;
mLambda=l;
mFrameMap=frameMap;
totalNumberOfParams=paramList.size();
initializeParameters();
mLookupChart = new TIntObjectHashMap<LogFormula>();
mHvCorrespondenceMap = hvCorrespondenceMap;
mRelatedWordsForWord = relatedWordsForWord;
mRevisedRelationsMap = revisedRelationsMap;
mHVLemmas = hvLemmas;
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:25,代码来源:FastFrameIdentifier.java
示例9: parseParamFile
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
private static TObjectDoubleHashMap<String> parseParamFile(String paramsFile)
{
TObjectDoubleHashMap<String> startParamList = new TObjectDoubleHashMap<String>();
try {
BufferedReader fis = new BufferedReader(new FileReader(paramsFile));
String pattern = null;
int count = 0;
while ((pattern = fis.readLine()) != null)
{
StringTokenizer st = new StringTokenizer(pattern.trim(),"\t");
String paramName = st.nextToken().trim();
String rest = st.nextToken().trim();
String[] arr = rest.split(",");
double value = new Double(arr[0].trim());
boolean sign = new Boolean(arr[1].trim());
LDouble val = new LDouble(value,sign);
startParamList.put(paramName, val.exponentiate());
if(count%100000==0)
System.out.println("Processed param number:"+count);
count++;
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
return startParamList;
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:27,代码来源:FastFrameIdentifier.java
示例10: initializeParameterIndexes
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
protected void initializeParameterIndexes() {
A = new Alphabet();
V = new LDouble[PARAMETER_TABLE_INITIAL_CAPACITY];
G = new LDouble[PARAMETER_TABLE_INITIAL_CAPACITY];
m_trainingData = new ArrayList<TDoubleArrayList>(1000);
m_trainingLabels = new TIntArrayList(1000);
m_testData = new ArrayList<TDoubleArrayList>(100);
m_testLabels = new TIntArrayList(100);
m_devData = new ArrayList<TDoubleArrayList>(100);
m_devLabels = new TIntArrayList(100);
savedValues = new TObjectDoubleHashMap<String>(1000);
m_savedFormulas = new ArrayList<LogFormula>(FORMULA_LIST_INITIAL_CAPACITY);
m_current = 0;
m_savedLLFormulas = new ArrayList<LazyLookupLogFormula>(LLFORMULA_LIST_INITIAL_CAPACITY);
m_llcurrent = 0;
mLookupChart = new THashMap<Integer,LogFormula>(PARAMETER_TABLE_INITIAL_CAPACITY);
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:18,代码来源:LogLogisticRegressionModel.java
示例11: initializeParameterIndexes
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public void initializeParameterIndexes()
{
V = new LDouble[PARAMETER_TABLE_INITIAL_CAPACITY];
G = new LDouble[PARAMETER_TABLE_INITIAL_CAPACITY];
savedValues = new TObjectDoubleHashMap<String>(1000);
m_savedFormulas = new ArrayList<LogFormula>(FORMULA_LIST_INITIAL_CAPACITY);
m_current = 0;
m_savedLLFormulas = new ArrayList<LazyLookupLogFormula>(LLFORMULA_LIST_INITIAL_CAPACITY);
m_llcurrent = 0;
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:11,代码来源:LRIdentificationModelSingleNode.java
示例12: getAllGradients
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public THashMap<String,LDouble> getAllGradients(TObjectDoubleHashMap<String> paramMap)
{
THashMap<String,LDouble> gradientMap = new THashMap<String,LDouble>();
String[] keys = new String[paramMap.size()];
paramMap.keys(keys);
int len = keys.length;
for(int i = 0; i < len; i ++)
{
int paramIndex = localA.get(keys[i]);
LDouble gradient = G[paramIndex];
gradientMap.put(keys[i], gradient);
}
return gradientMap;
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:15,代码来源:LRIdentificationModelSingleNode.java
示例13: LRIdentificationModelHadoop
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public LRIdentificationModelHadoop(TObjectDoubleHashMap<String> paramList, String reg, double l, WordNetRelations mwnr, THashMap<String, THashSet<String>> frameMap, String trainOrTest, THashMap<String, THashSet<String>> wnRelationCache)
{
super(paramList,reg,l,mwnr,frameMap);
initializeParameterIndexes();
this.mParamList=paramList;
mReg=reg;
mLambda=l;
mWNR=mwnr;
mFrameMap=frameMap;
totalNumberOfParams=paramList.size();
initializeParameters();
mLookupChart = new TIntObjectHashMap<LogFormula>();
mTrainOrTest=""+trainOrTest;
mWnRelationsCache = wnRelationCache;
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:16,代码来源:LRIdentificationModelHadoop.java
示例14: printFinalMap
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public static void printFinalMap(THashMap<String, TObjectDoubleHashMap<String>> finalMap, String outFile) {
Set<String> keySet = finalMap.keySet();
String[] arr = new String[keySet.size()];
keySet.toArray(arr);
Arrays.sort(arr);
ArrayList<String> finalLines = new ArrayList<String>();
Comparator<Pair<String, Double>> c = new Comparator<Pair<String, Double>> () {
public int compare(Pair<String, Double> o1, Pair<String, Double> o2) {
if (o1.getSecond() > o2.getSecond())
return -1;
else if (o1.getSecond() == o2.getSecond()) {
return 0;
} else
return 1;
}
};
for (String unit: arr) {
String line = unit + "\t";
TObjectDoubleHashMap<String> map = finalMap.get(unit);
String[] keys = new String[map.size()];
map.keys(keys);
Pair<String, Double>[] pArray = new Pair[map.size()];
for (int i = 0; i < keys.length; i++) {
pArray[i] = new Pair<String, Double>(keys[i], map.get(keys[i]));
}
Arrays.sort(pArray, c);
for (int i = 0; i < keys.length; i++) {
line += pArray[i].getFirst() + "\t" + pArray[i].getSecond() + "\t";
}
line = line.trim();
finalLines.add(line);
}
ParsePreparation.writeSentencesToTempFile(outFile, finalLines);
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:35,代码来源:NormalizeLinDekNeighbors.java
示例15: Counter
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public Counter(TObjectDoubleHashMap<T> map) {
m_map = map;
double vals[] = map.getValues();
for (double val : vals) {
m_sum += val;
}
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:9,代码来源:Counter.java
示例16: toCounter
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public Counter<T> toCounter() {
TObjectDoubleHashMap<T> map = new TObjectDoubleHashMap<T>();
for (TObjectIntIterator<T> iter = getIterator();
iter.hasNext();) {
iter.advance();
map.put(iter.key(), (double)iter.value());
}
if (containsKey(null))
map.put(null, (double)getT(null));
return new Counter<T>(map);
}
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:12,代码来源:IntCounter.java
示例17: clone
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
/**
* Clones the underlying trove collection and returns the clone wrapped in a new
* decorator instance. This is a shallow clone except where primitives are
* concerned.
*
* @return a copy of the receiver
*/
public TObjectDoubleHashMapDecorator clone() {
try {
TObjectDoubleHashMapDecorator copy = (TObjectDoubleHashMapDecorator) super.clone();
copy._map = (TObjectDoubleHashMap)_map.clone();
return copy;
} catch (CloneNotSupportedException e) {
// assert(false);
throw new InternalError(); // we are cloneable, so this does not happen
}
}
开发者ID:jgaltidor,项目名称:VarJ,代码行数:18,代码来源:TObjectDoubleHashMapDecorator.java
示例18: readExternal
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = (TObjectDoubleHashMap<V>) in.readObject();
}
开发者ID:jgaltidor,项目名称:VarJ,代码行数:10,代码来源:TObjectDoubleHashMapDecorator.java
示例19: ModelConstants
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
public ModelConstants(TObjectIntHashMap<String> intStr,
TObjectDoubleHashMap<String> doubleStr,
TObjectLongHashMap<String> longStr,
TObjectFloatHashMap<String> floatStr) {
super();
this.intStr = intStr;
this.doubleStr = doubleStr;
this.longStr = longStr;
this.floatStr =floatStr;
}
开发者ID:kaituo,项目名称:sedge,代码行数:11,代码来源:ModelConstants.java
示例20: TObjectDoubleHashMapDecorator
import gnu.trove.TObjectDoubleHashMap; //导入依赖的package包/类
/**
* Creates a wrapper that decorates the specified primitive map.
*/
public TObjectDoubleHashMapDecorator(TObjectDoubleHashMap<V> map) {
super();
this._map = map;
}
开发者ID:jgaltidor,项目名称:VarJ,代码行数:8,代码来源:TObjectDoubleHashMapDecorator.java
注:本文中的gnu.trove.TObjectDoubleHashMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论