本文整理汇总了Java中gnu.trove.TObjectDoubleHashMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java TObjectDoubleHashMap.put方法的具体用法?Java TObjectDoubleHashMap.put怎么用?Java TObjectDoubleHashMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.TObjectDoubleHashMap
的用法示例。
在下文中一共展示了TObjectDoubleHashMap.put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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);
}
示例6: parse1AryVariables
import gnu.trove.TObjectDoubleHashMap; //导入方法依赖的package包/类
/**
* Parse simple variables: int, reference, etc.
* I.e., variables that are not maps.
*
* @return variable name --> value that the model assigns to variable
*/
public ModelConstants parse1AryVariables(SWIGTYPE_p__Z3_model model) {
TObjectIntHashMap<String> intStr = new TObjectIntHashMap<String>();
TObjectDoubleHashMap<String> doubleStr = new TObjectDoubleHashMap<String>();
TObjectFloatHashMap<String> floatStr = new TObjectFloatHashMap<String>();
TObjectLongHashMap<String> longStr = new TObjectLongHashMap<String>();
long nrValues = // may be less than #vars
z3.get_model_num_constants(model);
for (int i=0; i<nrValues; i++) {
SWIGTYPE_p__Z3_func_decl decl = z3.get_model_constant(model, i);
SWIGTYPE_p__Z3_ast value = z3.eval_func_decl(model, decl);
if (z3.get_ast_kind(value) != Z3_ast_kind.Z3_NUMERAL_AST)
continue; // Process numeral values only
if(decl == null) {
System.err.println("Z3_func_decl cannot be null!");
System.exit(1);
}
final String varName = z3.get_symbol_string(z3.get_decl_name(decl));
SWIGTYPE_p__Z3_sort ty = z3.get_sort(value);
// final int valueInt = asInt(value);
// loglnIf(LOG_MODEL, varName+": "+valueInt);
switch (z3.get_sort_kind(ty)) {
case Z3_INT_SORT:
int valueInt = asInt(value);
intStr.put(varName, valueInt);
break;
case Z3_REAL_SORT:
double valueDouble = asDouble(value);
doubleStr.put(varName, valueDouble);
float valueFloat = asFloat(value);
floatStr.put(varName, valueFloat);
break;
case Z3_BV_SORT:
long s = z3.get_bv_sort_size(ty);
if(s == 32) {
int valueInt2 = asInt(value);
intStr.put(varName, valueInt2);
} else if(s == 64) {
long valueLong = asLong(value);
longStr.put(varName, valueLong);
}
break;
default:
System.out.print("unsupported sort");
break;
}
}
ModelConstants res = new ModelConstants(intStr, doubleStr, longStr, floatStr);
return res;
}