本文整理汇总了Java中gnu.trove.TObjectDoubleHashMap类的典型用法代码示例。如果您正苦于以下问题:Java TObjectDoubleHashMap类的具体用法?Java TObjectDoubleHashMap怎么用?Java TObjectDoubleHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TObjectDoubleHashMap类属于gnu.trove包,在下文中一共展示了TObjectDoubleHashMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}