/** * Returns the components of the recall. * * @return A {@link Pair} with the numerator of the recall in the first element * and the denominator of the recall in the second element. */ public Pair<Double,Double> getRFractionals() { return new Pair<>(recalls2, rnums2); }
private static long getMentionHash(int m) { Pair<Integer, Integer> pair = new Pair<>(m, currentDocId); Long hash = MENTION_HASHES.get(pair); if (hash == null) { hash = RANDOM.nextLong(); MENTION_HASHES.put(pair, hash); } return hash; } }
/** * Returns the set cross product of s1 and s2, as <code>Pair</code>s */ public static <E,F> Set<Pair<E,F>> cross(Set<E> s1, Set<F> s2) { Set<Pair<E,F>> s = Generics.newHashSet(); for (E o1 : s1) { for (F o2 : s2) { s.add(new Pair<>(o1, o2)); } } return s; }
public DepPattern(Token token, GrammaticalRelation relation) { super(PatternFactory.PatternType.DEP); this.relations = new ArrayList<>(); relations.add(new Pair<>(token, relation)); hashCode = this.toString().hashCode(); }
/** * Get the selected tree and its corresponding matched parts * @return a tree that matches the tregex expression */ public Pair<TreeFromFile, List<Tree>> getSelectedMatch() { if(!isEmpty()) { TreeFromFile selectedTree = (TreeFromFile) list.getSelectedValue(); return new Pair<>(selectedTree, matchedParts.get(selectedTree)); } else return null; }
public static List<Pair<Integer, Integer>> getMentionPairs(Document document) { List<Pair<Integer, Integer>> pairs = new ArrayList<>(); List<Mention> mentions = getSortedMentions(document); for (int i = 0; i < mentions.size(); i++) { for (int j = 0; j < i; j++) { pairs.add(new Pair<>(mentions.get(j).mentionID, mentions.get(i).mentionID)); } } return pairs; }
private void addChildBid(int i, int bid, int pos) { if (reachableChildBids[i] == null) { reachableChildBids[i] = new ArraySet<>(); } reachableChildBids[i].add(new Pair<>(bid, pos) ); }
protected void startMatchedCountInc(int bid, SequencePattern.State node, int initialValue, int delta) { Map<SequencePattern.State,Object> matchStateCount = getMatchStateInfo(bid, true); Pair<Integer,Boolean> p = (Pair<Integer,Boolean>) matchStateCount.get(node); if (p == null) { matchStateCount.put(node, new Pair<>(initialValue, false)); } else { matchStateCount.put(node, new Pair<>(p.first() + delta, false)); } }
@Override public List<Pair<Integer, Integer>> process(List<Integer> posList) { List<Pair<Integer, Integer>> allPos = new ArrayList<>(posList.size()); Pair<Integer, Double> newPosProb = null; for (int pos : posList) { newPosProb = samplePositionHelper(model, sequence, pos, temperature); // returns the position to sample in first place and new label in second place allPos.add(new Pair<>(pos, newPosProb.first())); } return allPos; }
public void initScorers() { linksCountInPass = new ArrayList<>(); scorePairwise = new ArrayList<>(); scoreBcubed = new ArrayList<>(); scoreMUC = new ArrayList<>(); for (String sieveClassName : sieveClassNames) { scorePairwise.add(new ScorerPairwise()); scoreBcubed.add(new ScorerBCubed(BCubedType.Bconll)); scoreMUC.add(new ScorerMUC()); linksCountInPass.add(new Pair<>(0, 0)); } }
public static <E> List<Pair<E, Double>> toDescendingMagnitudeSortedListWithCounts(Counter<E> c) { List<E> keys = new ArrayList<>(c.keySet()); Collections.sort(keys, toComparator(c, false, true)); List<Pair<E, Double>> l = new ArrayList<>(keys.size()); for (E key : keys) { l.add(new Pair<>(key, c.getCount(key))); } return l; }
/** char offsets of mention **/ public Pair<Integer,Integer> charOffsets() { int beginCharOffset = this.sentenceCoreMap.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class); int endCharOffset = this.sentenceCoreMap.get(CoreAnnotations.CharacterOffsetEndAnnotation.class); return new Pair<>(beginCharOffset,endCharOffset); }
/** char offsets of quote **/ public Pair<Integer,Integer> quoteCharOffsets() { int beginCharOffset = this.quoteCoreMap.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class); int endCharOffset = this.quoteCoreMap.get(CoreAnnotations.CharacterOffsetEndAnnotation.class); return new Pair<>(beginCharOffset,endCharOffset); }
public Pair <Integer,Double> tune(Function function, double[] initial,long msPerTest,double gainLow,double gainHigh){ this.quiet = true; gain = tuneGain(function, initial, msPerTest, gainLow,gainHigh); bSize = tuneBatch(function,initial,msPerTest,1); return new Pair<>(bSize, gain); }
/** char offsets of mention **/ public Pair<Integer,Integer> charOffsets() { int beginCharOffset = this.entityMentionCoreMap.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class); int endCharOffset = this.entityMentionCoreMap.get(CoreAnnotations.CharacterOffsetEndAnnotation.class); return new Pair<>(beginCharOffset,endCharOffset); }
private static List<Pair<TregexPattern, TsurgeonPattern>> compilePatterns(Pair<String, String>[] patterns) { List<Pair<TregexPattern, TsurgeonPattern>> ret = new ArrayList<>(patterns.length); for (Pair<String, String> pattern : patterns) ret.add(new Pair<>(TregexPattern.compile(pattern.first()), Tsurgeon.parseOperation(pattern.second()))); return ret; }
public List<Pair<Double, Double>> toListPairDouble() { List<Pair<Double, Double>> list = new ArrayList<>(); for (int i = 0; i < size(); i++) { double x = (domain() != null ? domain().get(i) : (double) i); double y = get(i); list.add(new Pair<>(x, y)); } return list; }
@Override public Pair<Integer,Double> tune( edu.stanford.nlp.optimization.Function function,double[] initial, long msPerTest){ this.quiet = true; for(int i =0;i<2; i++){ this.fixedGain = tuneDouble(function,initial,msPerTest,new setFixedGain(this),0.1,1.0); gain = tuneGain(function,initial,msPerTest,1e-7,1.0); bSize = tuneBatch(function,initial,msPerTest,1); log.info("Results: fixedGain: " + nf.format(this.fixedGain) + " gain: " + nf.format(gain) + " batch " + bSize ); } return new Pair<>(bSize, gain); }
public ClassicCounter<Pair<K1, K2>> flatten() { ClassicCounter<Pair<K1, K2>> result = new ClassicCounter<>(); result.setDefaultReturnValue(defaultValue); for (K1 key1 : firstKeySet()) { ClassicCounter<K2> inner = getCounter(key1); for (K2 key2 : inner.keySet()) { result.setCount(new Pair<>(key1, key2), inner.getCount(key2)); } } return result; }