private void addTypedFeature(String featName, char featChar, boolean isPrefix) { Pair<Set<Character>, Set<Character>> p = affixFeatures.get(featName); if (p == null) { affixFeatures.put(featName, p = new Pair<>()); } Set<Character> feature; if (isPrefix) { feature = p.first(); if (feature == null) { p.setFirst(feature = Generics.newHashSet()); } } else { feature = p.second(); if (feature == null) { p.setSecond(feature = Generics.newHashSet()); } } feature.add(featChar); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } Interval interval = (Interval) o; if (flags != interval.flags) { return false; } return true; }
@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; }
private void findSpeakersInArticle(Dictionaries dict) { List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class); Pair<Integer, Integer> beginQuotation = new Pair<>(); Pair<Integer, Integer> endQuotation = new Pair<>(); boolean insideQuotation = false; int utterNum = -1; for (int i = 0 ; i < sentences.size(); i++) { List<CoreLabel> sent = sentences.get(i).get(CoreAnnotations.TokensAnnotation.class); for(int j = 0 ; j < sent.size() ; j++) { int utterIndex = sent.get(j).get(CoreAnnotations.UtteranceAnnotation.class); if(utterIndex != 0 && !insideQuotation) { utterNum = utterIndex; insideQuotation = true; beginQuotation.setFirst(i); beginQuotation.setSecond(j); } else if (utterIndex == 0 && insideQuotation) { insideQuotation = false; endQuotation.setFirst(i); endQuotation.setSecond(j); findQuotationSpeaker(utterNum, sentences, beginQuotation, endQuotation, dict); } } } }
/** * 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 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; }
private static Pair<IndexedWord, String> findDependentVerb(Mention m) { if (m.enhancedDependency.getRoots().size() == 0) { return new Pair<>(); } // would be nice to condense this pattern, but sadly =reln // always uses the last relation in the sequence, not the first SemgrexPattern pattern = SemgrexPattern.compile("{idx:" + (m.headIndex+1) + "} [ <=reln {tag:/^V.*/}=verb | <=reln ({} << {tag:/^V.*/}=verb) ]"); SemgrexMatcher matcher = pattern.matcher(m.enhancedDependency); while (matcher.find()) { return Pair.makePair(matcher.getNode("verb"), matcher.getRelnString("reln")); } return new Pair<>(); }
this.speakerTokens.get().get( speakerTokens.get().size() - 1).get(CoreAnnotations.CharacterOffsetEndAnnotation.class); this.speakerCharOffsets = Optional.of(new Pair<>(speakerCharOffsetBegin, speakerCharOffsetEnd)); for (CoreEntityMention candidateEntityMention : this.document.entityMentions()) { Pair<Integer,Integer> entityMentionOffsets = candidateEntityMention.charOffsets(); if (entityMentionOffsets.equals(this.speakerCharOffsets.get())) { this.speakerEntityMention = Optional.of(candidateEntityMention); break; this.canonicalSpeakerTokens.get().get( canonicalSpeakerTokens.get().size() - 1).get(CoreAnnotations.CharacterOffsetEndAnnotation.class); this.canonicalSpeakerCharOffsets = Optional.of(new Pair<>(canonicalSpeakerCharOffsetBegin, canonicalSpeakerCharOffsetEnd)); for (CoreEntityMention candidateEntityMention : this.document.entityMentions()) { Pair<Integer,Integer> entityMentionOffsets = candidateEntityMention.charOffsets(); if (entityMentionOffsets.equals(this.canonicalSpeakerCharOffsets.get())) { this.canonicalSpeakerEntityMention = Optional.of(candidateEntityMention); break;
public ComplexNodePattern(BiFunction<M,K, Object> getter, K key, NodePattern pattern) { this(getter, Pair.makePair(key,pattern)); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + flags; return result; }
private void decommitVariableGroups() { if (committedVariables) { for (Pair<Integer, String> varGroup : myNode.variableGroups) { variableStrings.unsetVar(varGroup.second()); } } committedVariables = false; }
/** * {@inheritDoc} */ public void prettyLog(RedwoodChannels channels, String description) { PrettyLogger.log(channels, description, this.asList()); }
Pair<Set<Character>, Set<Character>> p = affixFeatures.get(singleFeatIndexString); if (p == null) { affixFeatures.put(singleFeatIndexString, p = new Pair<>()); p.setFirst(featureSet); } else { p.setSecond(featureSet); Pair<Set<Character>, Set<Character>> p = affixFeatures.get(singleFeatIndexString); if (p == null) { affixFeatures.put(singleFeatIndexString, p = new Pair<>()); p.setFirst(featureSet); } else { p.setSecond(featureSet);