/** Find relative pronouns */ public void addRelativePronoun(Mention m) { if(relativePronouns == null) relativePronouns = Generics.newHashSet(); relativePronouns.add(m); }
@Override public List<E> objectsList() { return Generics.newArrayList(item2Index.keySet()); }
TRegexGUITreeVisitor(TregexPattern p) { //String[] handles) { this.p = p; //this.handles = handles; matchedTrees = new ArrayList<>(); matchedParts = Generics.newHashMap(); }
public Lattice() { edges = new ArrayList<>(); nodes = Generics.newHashSet(); constraints = new ArrayList<>(); edgeStartsAt = Generics.newHashMap(); }
public TransducerGraph minimizeFA(TransducerGraph unminimizedFA) { this.unminimizedFA = unminimizedFA; this.activePairs = Generics.newLinkedList(); this.memberToBlock = Generics.newHashMap(); minimize(); return buildMinimizedFA(); }
/** * Can only be one because automaton is deterministic. */ public Arc getArcBySourceAndInput(Object node, Object input) { return arcsBySourceAndInput.get(Generics.newPair(node, input)); }
/** * Constructor. * * @param r * @param tf * @param lexerProperties * @param splitCompounds */ public FrenchTokenizer(Reader r, LexedTokenFactory<T> tf, Properties lexerProperties, boolean splitCompounds, boolean splitContractions) { lexer = new FrenchLexer(r, tf, lexerProperties); this.splitCompounds = splitCompounds; this.splitContractions = splitContractions; if (splitCompounds || splitContractions) compoundBuffer = Generics.newLinkedList(); }
Pair<ClassicCounter<OUT>, ClassicCounter<OUT>> evalPrecision(Collection<IN> guesses, Collection<IN> golds) { Collection<IN> internalGuesses = null; Collection<IN> internalGolds = null; if(bagEval) { internalGuesses = new ArrayList<>(guesses.size()); internalGolds = new ArrayList<>(golds.size()); } else { internalGuesses = Generics.newHashSet(guesses.size()); internalGolds = Generics.newHashSet(golds.size()); } internalGuesses.addAll(guesses); internalGolds.addAll(golds); ClassicCounter<OUT> thisGuessed = new ClassicCounter<>(); ClassicCounter<OUT> thisCorrect = new ClassicCounter<>(); for (IN o : internalGuesses) { OUT equivalenceClass = eq.equivalenceClass(o); thisGuessed.incrementCount(equivalenceClass); if (checker.contained(o, internalGolds)) { thisCorrect.incrementCount(equivalenceClass); removeItem(o,internalGolds,checker); } else { if (verbose) { System.out.println("Eval missed " + o); } } } return Generics.newPair(thisGuessed, thisCorrect); }
Set<IndexedWord> visitedNodes = Generics.newHashSet(); Queue<IndexedWord> queue = Generics.newLinkedList();
List<IndexedWord> newConjDeps = Generics.newLinkedList(); for (IndexedWord conjDep : conjDeps) { List<IndexedWord> caseMarkers = Generics.newArrayList(); caseMarkers.add(conjDep);
public static <K> Set<K> newIdentityHashSet() { return Collections.newSetFromMap(Generics.<K, Boolean>newIdentityHashMap()); }
/** * For supplying a new instance for the global methods to use. * * @return the previous global interner. */ public static SynchronizedInterner<Object> setGlobal(Interner<Object> delegate) { synchronized(globalMutex) { SynchronizedInterner<Object> oldInterner = SynchronizedInterner.interner; SynchronizedInterner.interner = Generics.newSynchronizedInterner(delegate); return oldInterner; } }
public void clear() { map = Generics.newWeakHashMap(); }
/** * Returns a unique object o' that .equals the argument o. If o * itself is returned, this is the first request for an object * .equals to o. */ public synchronized T intern(T o) { WeakReference<T> ref = map.get(o); if (ref == null) { ref = Generics.newWeakReference(o); map.put(o, ref); } // else { // log.info("Found dup for " + o); // } return ref.get(); }
public Classifier<L, F> trainClassifier(Iterable<Datum<L, F>> dataIterable) { Minimizer<DiffFunction> minimizer = getMinimizer(); Index<F> featureIndex = Generics.newIndex(); Index<L> labelIndex = Generics.newIndex(); for (Datum<L, F> d : dataIterable) { labelIndex.add(d.label()); featureIndex.addAll(d.asFeatures());//If there are duplicates, it doesn't add them again. } logger.info(String.format("Training linear classifier with %d features and %d labels", featureIndex.size(), labelIndex.size())); LogConditionalObjectiveFunction<L, F> objective = new LogConditionalObjectiveFunction<>(dataIterable, logPrior, featureIndex, labelIndex); // [cdm 2014] Commented out next line. Why not use the logPrior set up previously and used at creation??? // objective.setPrior(new LogPrior(LogPrior.LogPriorType.QUADRATIC)); double[] initial = objective.initial(); double[] weights = minimizer.minimize(objective, TOL, initial); LinearClassifier<L, F> classifier = new LinearClassifier<>(objective.to2D(weights), featureIndex, labelIndex); return classifier; }
/** * Returns a Set of type TransducerGraph.Arc. */ public Set<Arc> getArcsByTargetAndInput(Object node, Object input) { return ensure(arcsByTargetAndInput.get(Generics.newPair(node, input))); }
/** * Returns all nodes reachable from {@code root}. * * @param root the root node of the subgraph * @return all nodes in subgraph */ public Set<IndexedWord> getSubgraphVertices(IndexedWord root) { Set<IndexedWord> result = wordMapFactory.newSet(); result.add(root); List<IndexedWord> queue = Generics.newLinkedList(); queue.add(root); while (! queue.isEmpty()) { IndexedWord current = queue.remove(0); for (IndexedWord child : this.getChildren(current)) { if ( ! result.contains(child)) { result.add(child); queue.add(child); } } } return result; }
List<IndexedWord> uncompressedList = Generics.newLinkedList(vertexSet()); List<Pair<String, IndexedWord>> specifics = Generics.newArrayList();
static IdentityHashMap<Tree, Tree> buildParentMap(Tree tree) { IdentityHashMap<Tree, Tree> map = Generics.newIdentityHashMap(); buildParentMapHelper(tree, null, map); return map; }
/** * For supplying a new instance for the global methods to use. * * @return the previous global interner. */ public static SynchronizedInterner<Object> setGlobal(Interner<Object> delegate) { synchronized(globalMutex) { SynchronizedInterner<Object> oldInterner = SynchronizedInterner.interner; SynchronizedInterner.interner = Generics.newSynchronizedInterner(delegate); return oldInterner; } }