public HashSparseVector(HashSparseVector v) { data = new TIntFloatHashMap(v.data); }
private void setweight(int c1, int c2, float w) { if(w==0.0f) return; int max,min; if(c1<=c2){ max = c2; min = c1; }else{ max = c1; min = c2; } TIntFloatHashMap map2 = wcc.get(min); if(map2==null){ map2 = new TIntFloatHashMap(); wcc.put(min, map2); } map2.put(max, w); }
map = new TIntFloatHashMap(); pcc.put(prechar, map);
heads.put(c1, newid); heads.put(c2, newid); TIntFloatHashMap newpcc = new TIntFloatHashMap(); TIntFloatHashMap inewpcc = new TIntFloatHashMap(); TIntFloatHashMap newwcc = new TIntFloatHashMap(); float pc1 = wordProb.get(c1); float pc2 = wordProb.get(c2); wcc.put(newid, new TIntFloatHashMap()); wcc.remove(c1); wcc.remove(c2);
public void onAttached(String vkey) { caches.put(vkey, new TIntFloatHashMap()); caches.put("length:" + vkey, new TIntFloatHashMap()); }
public void onAttached(String vkey) { caches.put(vkey, new TIntFloatHashMap()); }
/** * Construct the array with the given length and expected density * @param length the length * @param density the density */ public SparseHashedFloatArray(int length, float density) { if (length < 0) throw new IllegalArgumentException("length must be >= 0"); if (density <= 0 || density > 1) throw new IllegalArgumentException("density must be > 0 and < 1"); this.length = length; int capacity = (int) (density * length); this.data = new TIntFloatHashMap(capacity); }
/** * Construct the array with the given length and capacity for non-zero elements * @param length the length * @param capacity the capacity */ public SparseHashedFloatArray(int length, int capacity) { if (length < 0) throw new IllegalArgumentException("length must be >= 0"); if (capacity <= 0) throw new IllegalArgumentException("capacity must be > 0"); this.length = length; this.data = new TIntFloatHashMap(capacity); }
@Override public boolean execute(long k, float v) { invertedIndex.putIfAbsent(k, new TIntFloatHashMap()); TIntFloatMap index = invertedIndex.get(k); synchronized (index) { invertedIndex.get(k).put(id, v); } return true; } });
/** * Put data in a scoreDoc into a TIntDoubleHashMap * * @param wikibrainScoreDocs * @return */ private TIntFloatMap expandScores(WikiBrainScoreDoc[] wikibrainScoreDocs) { TIntFloatMap expanded = new TIntFloatHashMap(); for (WikiBrainScoreDoc wikibrainScoreDoc : wikibrainScoreDocs) { expanded.put(wikibrainScoreDoc.luceneId, wikibrainScoreDoc.score); } return expanded; }
@Override public SparseFloatArray copy() { SparseHashedFloatArray copy = new SparseHashedFloatArray(length); copy.data = new TIntFloatHashMap(data); return copy; }
/** * Returns this list as a TIntFloatMap. * Note that this does not maintain any order. * @return */ public TIntFloatMap asTroveMap() { TIntFloatHashMap map = new TIntFloatHashMap(); for (int i = 0; i < numDocs; i++) { map.put(results[i].id, (float) results[i].getScore()); } return map; }
public ItemEdible() { super(0, 0, false); this.setHasSubtypes(true); dynamic = new ItemMetaDynamic(); foodLevels = new TIntIntHashMap(); saturations = new TIntFloatHashMap(); potionEffects = new TIntObjectHashMap<PotionEffect[]>(); alwaysEdible = new BitSet(); displayEffectsTooltip = true; }
private TIntFloatMap makeOutlinkVector(TIntSet links) throws DaoException { TIntFloatMap vector = new TIntFloatHashMap(); for (int wpId : links.toArray()) { vector.put(wpId, (float) Math.log(1.0 * numArticles / getNumLinks(wpId))); } return vector; }
@Override public SparseFloatArray reverse() { //TODO: this could be more efficient and avoid the copy TIntFloatHashMap tmp = new TIntFloatHashMap(data.size()); for (Entry e : entries()) tmp.put(length - e.index, e.value); this.data = tmp; return this; } }
/** * Normalize a vector to unit length. * @param X * @return */ public static TIntFloatMap normalizeVector(TIntFloatMap X) { TIntFloatHashMap Y = new TIntFloatHashMap(); double sumSquares = 0.0; for (double x : X.values()) { sumSquares += x * x; } if (sumSquares != 0.0) { double norm = Math.sqrt(sumSquares); for (int id : X.keys()) { Y.put(id, (float) (X.get(id) / norm)); } return Y; } return X; }
@Override public TIntFloatHashMap asTroveMap() { TIntFloatHashMap result = new TIntFloatHashMap(getNumCols()*2); for (int i = 0; i < getNumCols(); i++) { result.put(getColIndex(i), getColValue(i)); } return result; }
@Override public TIntFloatHashMap asTroveMap() { TIntFloatHashMap result = new TIntFloatHashMap(getNumCols()*2); for (int i = 0; i < getNumCols(); i++) { result.put(getColIndex(i), getColValue(i)); } return result; }
@Override public TIntFloatMap getVector(int pageId) throws DaoException { int luceneId = searcher.getDocIdFromLocalId(pageId, language); if (luceneId < 0) { LOG.warn("Unindexed document " + pageId + " in " + language.getEnLangName()); return new TIntFloatHashMap(); } WikiBrainScoreDoc[] wikibrainScoreDocs = getQueryBuilder() .setMoreLikeThisQuery(luceneId) .search(); wikibrainScoreDocs = pruneSimilar(wikibrainScoreDocs); return SimUtils.normalizeVector(expandScores(wikibrainScoreDocs)); }
/** * Normalizes the probability values in a vector so that to sum to 1.0 * @param vector * @return */ public static TIntFloatMap normalizeVector(TIntFloatMap vector) { float total = 0; TFloatIterator iter = vector.valueCollection().iterator(); while (iter.hasNext()) total += iter.next(); TIntFloatMap normalized = new TIntFloatHashMap(vector.size()); TIntFloatIterator iter2 = vector.iterator(); while (iter2.hasNext()) { iter2.advance(); normalized.put(iter2.key(), iter2.value() / total); } return normalized; }