@Override public boolean execute(String word, int count) { TweetCountWordMap.this.wordMap.adjustOrPutValue(word, count, count); return true; } });
@Override public boolean execute(String word, int count) { TweetCountWordMap.this.wordMap.adjustOrPutValue(word, count, count); return true; } });
@Override public boolean execute(String a, int b) { if (b >= 1) results.adjustOrPutValue(a, b, b); return true; } });
/** See {@link gnu.trove.map.hash.TObjectIntHashMap#adjustOrPutValue(Object, int, int)} */ /* argument names non-compliant to match original */ @SuppressWarnings("squid:S00117") public int adjustOrPutValue(K key, int adjust_amount, int put_amount) { return delegate.adjustOrPutValue(key, adjust_amount, put_amount); }
@Override public boolean execute(String a, int b) { if (b >= 1) results.adjustOrPutValue(a, b, b); return true; } });
/** See {@link gnu.trove.map.hash.TObjectIntHashMap#adjustOrPutValue(Object, int, int)} */ /* argument names non-compliant to match original */ @SuppressWarnings("squid:S00117") public int adjustOrPutValue(K key, int adjust_amount, int put_amount) { return delegate.adjustOrPutValue(key, adjust_amount, put_amount); }
private void handleEntity (OSMEntity entity) { if (entity.hasNoTags()) { return; } for (Tag tag : entity.tags) { stringWeights.adjustOrPutValue(tag.key, tag.key.length(), tag.key.length()); stringWeights.adjustOrPutValue(tag.value, tag.value.length(), tag.value.length()); String kv = tag.toString(); stringWeights.adjustOrPutValue(kv, kv.length(), kv.length()); } }
/** * Counting helper for kNN classification. * * @param counters Counter storage * @param l Object labels * @return Maximum count */ public int countkNN(TObjectIntHashMap<Object> counters, Object l) { // Count each label, return maximum. if(l instanceof LabelList) { LabelList ll = (LabelList) l; int m = 0; for(int i = 0, e = ll.size(); i < e; i++) { m = Math.max(m, counters.adjustOrPutValue(ll.get(i), 1, 1)); } return m; } return counters.adjustOrPutValue(l, 1, 1); } }
if (int1 > 0 && int2 == 0) { if (!evidenceForClBr) { votes.adjustOrPutValue(Cl, -10, -10); votes.adjustOrPutValue(Br, -10, -10); votes.adjustOrPutValue(Cl, 10, 10); votes.adjustOrPutValue(Br, 3, 3); } else if ((int2 / int1) > 3) { votes.adjustOrPutValue(Cl, 5, 5); votes.adjustOrPutValue(Br, 6, 6); votes.adjustOrPutValue(Cl, -10, -10); votes.adjustOrPutValue(Br, -10, -10);
if (s != null) { for (final T key : s) { counter.adjustOrPutValue(key, 1, 1);
if (s != null) { for (final T key : s) { counter.adjustOrPutValue(key, 1, 1);
/** * Factor decomposition with specified factors and exponents * * @param factors factors */ public static <Poly extends IPolynomial<Poly>> PolynomialFactorDecomposition<Poly> of(Collection<Poly> factors) { TObjectIntHashMap<Poly> map = new TObjectIntHashMap<>(); for (Poly e : factors) map.adjustOrPutValue(e, 1, 1); List<Poly> l = new ArrayList<>(); TIntArrayList e = new TIntArrayList(); map.forEachEntry((a, b) -> { l.add(a); e.add(b); return true; }); return of(factors.iterator().next().createOne(), l, e); } }
@Override public boolean findMatches(List<T> queryfeatures) { matches = new ArrayList<Pair<T>>(); final TObjectIntHashMap<T> targets = new TObjectIntHashMap<T>(); for (final T query : queryfeatures) { final T modeltarget = findMatch(query, modelKeypoints); if (modeltarget == null) continue; final T querytarget = findMatch(modeltarget, queryfeatures); if (querytarget == query) { matches.add(new Pair<T>(query, modeltarget)); targets.adjustOrPutValue(modeltarget, 1, 1); } } final ArrayList<Pair<T>> matchesToRemove = new ArrayList<Pair<T>>(); targets.forEachEntry(new TObjectIntProcedure<T>() { @Override public boolean execute(T a, int b) { if (b > 1) { for (final Pair<T> p : matches) { if (p.secondObject() == a) matchesToRemove.add(p); } } return true; } }); matches.removeAll(matchesToRemove); return matches.size() > 0; }
@Override public boolean findMatches(List<T> queryfeatures) { matches = new ArrayList<Pair<T>>(); final TObjectIntHashMap<T> targets = new TObjectIntHashMap<T>(); for (final T query : queryfeatures) { final T modeltarget = findMatch(query, modelKeypoints); if (modeltarget == null) continue; final T querytarget = findMatch(modeltarget, queryfeatures); if (querytarget == query) { matches.add(new Pair<T>(query, modeltarget)); targets.adjustOrPutValue(modeltarget, 1, 1); } } final ArrayList<Pair<T>> matchesToRemove = new ArrayList<Pair<T>>(); targets.forEachEntry(new TObjectIntProcedure<T>() { @Override public boolean execute(T a, int b) { if (b > 1) { for (final Pair<T> p : matches) { if (p.secondObject() == a) matchesToRemove.add(p); } } return true; } }); matches.removeAll(matchesToRemove); return matches.size() > 0; }
/** * Factor decomposition with specified factors and exponents * * @param ring the ring * @param factors factors */ public static <E> FactorDecomposition<E> of(Ring<E> ring, Collection<E> factors) { TObjectIntHashMap<E> map = new TObjectIntHashMap<>(); for (E e : factors) map.adjustOrPutValue(e, 1, 1); List<E> l = new ArrayList<>(); TIntArrayList e = new TIntArrayList(); map.forEachEntry((a, b) -> { l.add(a); e.add(b); return true; }); return of(ring, ring.getOne(), l, e); } }
@Override public List<ScoredAnnotation<ANNOTATION>> annotate(final OBJECT object) { if (this.nn == null) this.nn = new ObjectNearestNeighboursExact<FEATURE>(this.features, this.comparator); final TObjectIntHashMap<ANNOTATION> selected = new TObjectIntHashMap<ANNOTATION>(); final List<FEATURE> queryfv = new ArrayList<FEATURE>(1); queryfv.add(this.extractor.extractFeature(object)); final int[][] indices = new int[1][this.k]; final float[][] distances = new float[1][this.k]; this.nn.searchKNN(queryfv, this.k, indices, distances); int count = 0; for (int i = 0; i < this.k; i++) { // Distance check if (distances[0][i] > this.threshold) { continue; } final Collection<ANNOTATION> anns = this.annotations.get(indices[0][i]); for (final ANNOTATION ann : anns) { selected.adjustOrPutValue(ann, 1, 1); count++; } } final TObjectIntIterator<ANNOTATION> iterator = selected.iterator(); final List<ScoredAnnotation<ANNOTATION>> result = new ArrayList<ScoredAnnotation<ANNOTATION>>(selected.size()); while (iterator.hasNext()) { iterator.advance(); result.add(new ScoredAnnotation<ANNOTATION>(iterator.key(), (float) iterator.value() / (float) count)); } return result; }
@Override public void train(List<? extends Annotated<OBJECT, ANNOTATION>> data) { final TIntIntHashMap nAnnotationCounts = new TIntIntHashMap(); final TObjectIntHashMap<ANNOTATION> annotationCounts = new TObjectIntHashMap<ANNOTATION>(); int maxVal = 0; for (final Annotated<OBJECT, ANNOTATION> sample : data) { final Collection<ANNOTATION> annos = sample.getAnnotations(); for (final ANNOTATION s : annos) { annotationCounts.adjustOrPutValue(s, 1, 1); } nAnnotationCounts.adjustOrPutValue(annos.size(), 1, 1); if (annos.size() > maxVal) maxVal = annos.size(); } // build distribution and rng for each annotation annotations = new ArrayList<ANNOTATION>(); final TDoubleArrayList probs = new TDoubleArrayList(); annotationCounts.forEachEntry(new TObjectIntProcedure<ANNOTATION>() { @Override public boolean execute(ANNOTATION a, int b) { annotations.add(a); probs.add(b); return true; } }); annotationProbability = new EmpiricalWalker(probs.toArray(), Empirical.NO_INTERPOLATION, new MersenneTwister()); numAnnotations.train(data); }
if (r != null) { for (final String file : r) { featResults.adjustOrPutValue(file, 1, 1);
if (r != null) { for (final String file : r) { featResults.adjustOrPutValue(file, 1, 1);
private void plotXYHeatmap() { DataEntry xDataEntry = dataEntryHolder.getEntry(x); DataEntry yDataEntry = dataEntryHolder.getEntry(y); double discreteX = 0.09; double discreteY = 0.3; for (int i = graphIndicesHolder.getInPoint(); i < graphIndicesHolder.getIndex(); i++) { double roundedX = MathTools.roundToPrecision(xDataEntry.getData()[i], discreteX); double roundedY = MathTools.roundToPrecision(yDataEntry.getData()[i], discreteY); plotPencil.set(roundedX, roundedY); heatmap.adjustOrPutValue(plotPencil, 1, 1); int heat = heatmap.get(plotPencil); adjustViewRange(plotPencil.getX(), plotPencil.getY()); transformToCanvasSpace.transform(plotPencil); graphicsContext.setFill(getHeatColor(heat)); fillRect(plotPencil.getX(), plotPencil.getY(), discreteX * transformToCanvasSpace.getScaleX(), discreteY * transformToCanvasSpace.getScaleY()); } heatmap.clear(); }