public Counter(TObjectHashingStrategy<T> hs) { m_map = new TObjectDoubleHashMap<T>(hs); }
public Counter() { m_map = new TObjectDoubleHashMap<T>(); }
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; }
public static TObjectDoubleHashMap<String> readModel(Collection<String> featureLines) { final TObjectDoubleHashMap<String> model = new TObjectDoubleHashMap<String>(featureLines.size()); int count = 0; for (String line : featureLines) { String[] fields = line.split("\t"); final String featureName = fields[0].trim(); final Double featureValue = Double.parseDouble(fields[1].trim()); model.put(featureName, featureValue); count++; if (count % 100000 == 0) System.err.print(count + " "); } return model; }
public static TObjectDoubleHashMap<String> readOldModel(String idParamsFile) throws IOException { TObjectDoubleHashMap<String> params = new TObjectDoubleHashMap<String>(); int count = 0; String line; final BufferedReader input = Files.newReader(new File(idParamsFile), Charsets.UTF_8); try { while ((line = input.readLine()) != null) { final String[] nameAndVal = line.split("\t"); final String[] logAndSign = nameAndVal[1].split(", "); final double value = exp(Double.parseDouble(logAndSign[0])); final double sign = Boolean.parseBoolean(logAndSign[1]) ? 1.0 : -1.0; params.put(nameAndVal[0], value * sign); count++; if (count % 100000 == 0) System.err.print(count + " "); } } finally { closeQuietly(input); } return params; }
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); } protected void initializeParameter(int paramIndex)
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); } protected void initializeParameter(int paramIndex)
map.put(nbr, count + 1); TObjectDoubleHashMap<String> valMap = new TObjectDoubleHashMap<String>(); for (int j = 1; j < toks.length; j = j + 2) { String nbr = toks[j];
/** * @param _m le table a copier * @return la table copiee */ public static TObjectDoubleHashMap copy(final TObjectDoubleHashMap _m) { final TObjectDoubleHashMap r = new TObjectDoubleHashMap(_m); final TObjectDoubleIterator it = _m.iterator(); for (int i = _m.size(); i-- > 0;) { it.advance(); r.put(it.key(), it.value()); } return r; }
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; } }
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); }
public Instance pipe (Instance carrier) { TokenSequence seq = (TokenSequence)carrier.getData(); TObjectDoubleHashMap[] original = new TObjectDoubleHashMap[seq.size()]; for (int i=0; i<seq.size(); i++) { Token t = seq.get(i); original[i] = new TObjectDoubleHashMap(); PropertyList.Iterator pl = t.getFeatures().iterator(); while (pl.hasNext()) { pl.nextProperty(); original[i].put(pl.getKey(), pl.getNumericValue()); } } for (int i=0; i<original.length; i++) { // add to features of token i... for (int j = -1 * left; j <= right; j++) { int index = i + j; //...the features of token index String append = (j < 0) ? "/"+j : "/+"+j; if (index<0 || index==i || index>=original.length) continue; Token t = seq.get(i); Object[] features = original[index].keys(); for (int k=0; k<features.length; k++) t.setFeatureValue((String)features[k]+append, original[index].get(features[k])); } } return carrier; } }
public Instance pipe (Instance carrier) { TokenSequence seq = (TokenSequence)carrier.getData(); TObjectDoubleHashMap[] original = new TObjectDoubleHashMap[seq.size()]; for (int i=0; i<seq.size(); i++) { Token t = seq.get(i); original[i] = new TObjectDoubleHashMap(); PropertyList.Iterator pl = t.getFeatures().iterator(); while (pl.hasNext()) { pl.nextProperty(); original[i].put(pl.getKey(), pl.getNumericValue()); } } for (int i=0; i<original.length; i++) { // add to features of token i... for (int j = -1 * left; j <= right; j++) { int index = i + j; //...the features of token index String append = (j < 0) ? "/"+j : "/+"+j; if (index<0 || index==i || index>=original.length) continue; Token t = seq.get(i); Object[] features = original[index].keys(); for (int k=0; k<features.length; k++) t.setFeatureValue((String)features[k]+append, original[index].get(features[k])); } } return carrier; } }
public Instance pipe (Instance carrier) { TokenSequence seq = (TokenSequence)carrier.getData(); TObjectDoubleHashMap[] original = new TObjectDoubleHashMap[seq.size()]; for (int i=0; i<seq.size(); i++) { Token t = seq.get(i); original[i] = new TObjectDoubleHashMap(); PropertyList.Iterator pl = t.getFeatures().iterator(); while (pl.hasNext()) { pl.nextProperty(); original[i].put(pl.getKey(), pl.getNumericValue()); } } for (int i=0; i<original.length; i++) { // add to features of token i... for (int j = -1 * left; j <= right; j++) { int index = i + j; //...the features of token index String append = (j < 0) ? "/"+j : "/+"+j; if (index<0 || index==i || index>=original.length) continue; Token t = seq.get(i); Object[] features = original[index].keys(); for (int k=0; k<features.length; k++) t.setFeatureValue((String)features[k]+append, original[index].get(features[k])); } } return carrier; } }
public Instance pipe (Instance carrier) { TokenSequence seq = (TokenSequence)carrier.getData(); TObjectDoubleHashMap[] original = new TObjectDoubleHashMap[seq.size()]; for (int i=0; i<seq.size(); i++) { Token t = seq.getToken(i); original[i] = new TObjectDoubleHashMap(); PropertyList.Iterator pl = t.getFeatures().iterator(); while (pl.hasNext()) { pl.nextProperty(); original[i].put(pl.getKey(), pl.getNumericValue()); } } for (int i=0; i<original.length; i++) { // add to features of token i... for (int j = -1 * left; j <= right; j++) { int index = i + j; //...the features of token index String append = (j < 0) ? "/"+j : "/+"+j; if (index<0 || index==i || index>=original.length) continue; Token t = seq.getToken(i); Object[] features = original[index].keys(); for (int k=0; k<features.length; k++) t.setFeatureValue((String)features[k]+append, original[index].get(features[k])); } } return carrier; } }
new TObjectDoubleHashMap<NCRPNode>();
new TObjectDoubleHashMap<NCRPNode>();
new TObjectDoubleHashMap<NCRPNode>();