/** * Returns the value of the maximum entry in this counter. This is also the * L_infinity norm. An empty counter is given a max value of * Double.NEGATIVE_INFINITY. * * @param c The Counter to find the max of * @return The maximum value of the Counter */ public static <E> double max(Counter<E> c) { return max(c, Double.NEGATIVE_INFINITY); // note[gabor]: Should the default actually be 0 rather than negative_infinity? }
newscores.addAll(scores); minScore = Counters.min(newscores); maxScore = Counters.max(newscores);
public float score(IntTaggedWord iTW, int loc, String word, String featureSpec) { ensureProbs(iTW.word()); double max = Counters.max(logProbs); double score = logProbs.getCount(iTW.tagString(tagIndex)); if (score > max - iteratorCutoffFactor) { return (float) score; } else { return Float.NEGATIVE_INFINITY; } }
public Iterator<IntTaggedWord> ruleIteratorByWord(int word, int loc, String featureSpec) { ensureProbs(word); List<IntTaggedWord> rules = new ArrayList<>(); if (seenTagsOnly) { String wordString = wordIndex.get(word); Collection<String> tags = tagsForWord.get(wordString); for (String tag : tags) { rules.add(new IntTaggedWord(wordString, tag, wordIndex, tagIndex)); } } else { double max = Counters.max(logProbs); for (int tag = 0; tag < tagIndex.size(); tag++) { IntTaggedWord iTW = new IntTaggedWord(word, tag); double score = logProbs.getCount(tagIndex.get(tag)); if (score > max - iteratorCutoffFactor) { rules.add(iTW); } } } return rules.iterator(); }
/** * Creates a Distribution from the given counter, ie makes an internal * copy of the counter and divides all counts by the total count. * * @return a new Distribution */ public static <E> Distribution<E> getDistributionFromLogValues(Counter<E> counter) { Counter<E> c = new ClassicCounter<>(); // go through once to get the max // shift all by max so as to minimize the possibility of underflow double max = Counters.max(counter); // Thang 17Feb12: max should operate on counter instead of c, fixed! for (E key : counter.keySet()) { double count = Math.exp(counter.getCount(key) - max); c.setCount(key, count); } return getDistribution(c); }
/** * Mostly just an alias, but make sure our featurizer is serializable! */ public interface Featurizer extends Function<Triple<ClauseSplitterSearchProblem.State, ClauseSplitterSearchProblem.Action, ClauseSplitterSearchProblem.State>, Counter<String>>, Serializable { boolean isSimpleSplit(Counter<String> feats); }
boolean foundCorefAnt = (probs.size() > 0 && Counters.max(probs) > sieve.thresMerge); boolean correctDecision = ( (isFirstMention && !foundCorefAnt) || (foundCorefAnt && Sieve.isReallyCoref(document, m.mentionID, Counters.argmax(probs))) );
/** * TODO(gabor) JavaDoc * * @param tokens * @param span * @return */ public static String guessNER(List<CoreLabel> tokens, Span span) { Counter<String> nerGuesses = new ClassicCounter<>(); for (int i : span) { nerGuesses.incrementCount(tokens.get(i).ner()); } nerGuesses.remove("O"); nerGuesses.remove(null); if (nerGuesses.size() > 0 && Counters.max(nerGuesses) >= span.size() / 2) { return Counters.argmax(nerGuesses); } else { return "O"; } }
if(probs.size() > 0 && Counters.max(probs) > this.thresMerge) {
for (E k : en.getValue().keySet()) weights.setCount(k, patternsLearnedThisIter.getCount(k)); maxPatWeightTerms.setCount(en.getKey(), Counters.max(weights)); wordMaxPat.put(en.getKey(), Counters.argmax(weights)); double maxvalue = Counters.max(maxPatWeightTerms); Set<CandidatePhrase> words = Counters.keysAbove(maxPatWeightTerms, maxvalue - 1e-10);
Counters.retainNonZeros(finalPat); Counters.retainTop(finalPat, constVars.numPatterns); if (Double.isNaN(Counters.max(finalPat))) throw new RuntimeException("how is the value NaN"); Redwood.log(ConstantsAndVariables.minimaldebug, "Selected Patterns: " + finalPat);
/** * Returns the value of the maximum entry in this counter. This is also the * L_infinity norm. An empty counter is given a max value of * Double.NEGATIVE_INFINITY. * * @param c The Counter to find the max of * @return The maximum value of the Counter */ public static <E> double max(Counter<E> c) { return max(c, Double.NEGATIVE_INFINITY); // note[gabor]: Should the default actually be 0 rather than negative_infinity? }
/** * Returns the value of the maximum entry in this counter. This is also the * L_infinity norm. An empty counter is given a max value of * Double.NEGATIVE_INFINITY. * * @param c The Counter to find the max of * @return The maximum value of the Counter */ public static <E> double max(Counter<E> c) { return max(c, Double.NEGATIVE_INFINITY); // note[gabor]: Should the default actually be 0 rather than negative_infinity? }
newscores.addAll(scores); minScore = Counters.min(newscores); maxScore = Counters.max(newscores);
/** * Creates a Distribution from the given counter, ie makes an internal * copy of the counter and divides all counts by the total count. * * @return a new Distribution */ public static <E> Distribution<E> getDistributionFromLogValues(Counter<E> counter) { Counter<E> c = new ClassicCounter<E>(); // go through once to get the max // shift all by max so as to minimize the possibility of underflow double max = Counters.max(counter); // Thang 17Feb12: max should operate on counter instead of c, fixed! for (E key : counter.keySet()) { double count = Math.exp(counter.getCount(key) - max); c.setCount(key, count); } return getDistribution(c); }
/** * Creates a Distribution from the given counter, ie makes an internal * copy of the counter and divides all counts by the total count. * * @return a new Distribution */ public static <E> Distribution<E> getDistributionFromLogValues(Counter<E> counter) { ClassicCounter<E> c = new ClassicCounter<E>(); // go through once to get the max // shift all by max so as to minimize the possibility of underflow double max = Counters.max(c); for (E key : counter.keySet()) { double count = Math.exp(counter.getCount(key) - max); c.setCount(key, count); } return getDistribution(c); }
/** * Creates a Distribution from the given counter, ie makes an internal * copy of the counter and divides all counts by the total count. * * @return a new Distribution */ public static <E> Distribution<E> getDistributionFromLogValues(Counter<E> counter) { Counter<E> c = new ClassicCounter<>(); // go through once to get the max // shift all by max so as to minimize the possibility of underflow double max = Counters.max(counter); // Thang 17Feb12: max should operate on counter instead of c, fixed! for (E key : counter.keySet()) { double count = Math.exp(counter.getCount(key) - max); c.setCount(key, count); } return getDistribution(c); }
/** * Mostly just an alias, but make sure our featurizer is serializable! */ public interface Featurizer extends Function<Triple<ClauseSplitterSearchProblem.State, ClauseSplitterSearchProblem.Action, ClauseSplitterSearchProblem.State>, Counter<String>>, Serializable { boolean isSimpleSplit(Counter<String> feats); }
/** * Creates a Distribution from the given counter, ie makes an internal * copy of the counter and divides all counts by the total count. * * @return a new Distribution */ public static <E> Distribution<E> getDistributionFromLogValues(Counter<E> counter) { Counter<E> c = new ClassicCounter<>(); // go through once to get the max // shift all by max so as to minimize the possibility of underflow double max = Counters.max(counter); // Thang 17Feb12: max should operate on counter instead of c, fixed! for (E key : counter.keySet()) { double count = Math.exp(counter.getCount(key) - max); c.setCount(key, count); } return getDistribution(c); }
/** * TODO(gabor) JavaDoc * * @param tokens * @param span * @return */ public static String guessNER(List<CoreLabel> tokens, Span span) { Counter<String> nerGuesses = new ClassicCounter<>(); for (int i : span) { nerGuesses.incrementCount(tokens.get(i).ner()); } nerGuesses.remove("O"); nerGuesses.remove(null); if (nerGuesses.size() > 0 && Counters.max(nerGuesses) >= span.size() / 2) { return Counters.argmax(nerGuesses); } else { return "O"; } }