@Override public Class<List<String>> getType() { return ErasureUtils.uncheckedCast(List.class); } }
@Override public Class<Integer> getType() { return ErasureUtils.uncheckedCast(Integer.class); } }
@Override public Class<Pair<String, Double>> getType() { return ErasureUtils.uncheckedCast(Pair.class); } }
@Override public Class<List<? extends CoreMap>> getType() { return ErasureUtils.uncheckedCast(List.class); } }
@Override public Class<List<CoreMap>> getType() { return ErasureUtils.uncheckedCast(List.class); } }
@Override public Class<List<CoreMap>> getType() { return ErasureUtils.uncheckedCast(List.class); } }
@Override public Class<List<Pair<WordLemmaTag, String>>> getType() { return ErasureUtils.uncheckedCast(List.class); } }
@Override public Class<Map<Integer, CorefChain>> getType() { return ErasureUtils.uncheckedCast(Map.class); } }
@Override public Class<List<Mention>> getType() { return ErasureUtils.uncheckedCast(List.class); } }
@Override public Class<String> getType() { return ErasureUtils.uncheckedCast(String.class); } }
@Override public Class<Set<Integer>> getType() { return ErasureUtils.uncheckedCast(Set.class); } }
public static <T> T readObjectFromObjectStream(ObjectInputStream ois) throws IOException, ClassNotFoundException { Object o = ois.readObject(); return ErasureUtils.uncheckedCast(o); }
@Override public Collection<V> remove(Object key) { Collection<V> result = get(key); deltaMap.put(ErasureUtils.uncheckedCast(key), ErasureUtils.uncheckedCast(removedValue)); return result; }
private static <LL,FF> MultinomialLogisticClassifier<LL,FF> load(String path) throws IOException, ClassNotFoundException { System.err.print("Loading classifier from " + path + "... "); ObjectInputStream in = new ObjectInputStream(new FileInputStream(path)); double[][] myWeights = ErasureUtils.uncheckedCast(in.readObject()); Index<FF> myFeatureIndex = ErasureUtils.uncheckedCast(in.readObject()); Index<LL> myLabelIndex = ErasureUtils.uncheckedCast(in.readObject()); in.close(); System.err.println("done."); return new MultinomialLogisticClassifier<>(myWeights, myFeatureIndex, myLabelIndex); }
/** * Read an object from a stored file. * * @param filename The filename of the object to be retrieved * @throws IOException If file cannot be read * @throws ClassNotFoundException If reading serialized object fails * @return The object read from the file. */ public static <T> T readObjectFromFile(String filename) throws IOException, ClassNotFoundException { return ErasureUtils.uncheckedCast(readObjectFromFile(new File(filename))); }
public static <K,V> Map<K,V> newHashMap(int initialCapacity) { if (HASH_MAP_SIZE_CONSTRUCTOR == null) { return newHashMap(); } try { return ErasureUtils.uncheckedCast(HASH_MAP_SIZE_CONSTRUCTOR.newInstance(initialCapacity)); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Adds the value to the collection given by map.get(key). A new collection is created using the supplied CollectionFactory. * */ public static <K, V, C extends Collection<V>> void putIntoValueCollection(Map<K, C> map, K key, V value, CollectionFactory<V> cf) { C c = map.get(key); if (c == null) { c = ErasureUtils.<C>uncheckedCast(cf.newCollection()); map.put(key, c); } c.add(value); }
private int compare(Entry<E> entryA, Entry<E> entryB) { int result = compare(entryA.priority, entryB.priority); if (result != 0) { return result; } if ((entryA.key instanceof Comparable) && (entryB.key instanceof Comparable)) { Comparable<E> key = ErasureUtils.uncheckedCast(entryA.key); return key.compareTo(entryB.key); } return result; }
/** * Finds and returns the key in this Counter with the largest count. * Ties are broken according to the natural ordering of the objects. * This will prefer smaller numeric keys and lexicographically earlier * String keys. To use a different tie-breaking Comparator, use * {@link #argmax(Comparator)}. Returns null if this Counter is empty. */ public E argmax() { return argmax(ErasureUtils.<Comparator<E>>uncheckedCast(naturalComparator)); }
/** Returns a 0-based index of the right leaf of the tree. Assumes the leaves had been indexed from 1 */ static int rightIndex(Tree tree) { if (tree.isLeaf()) { CoreLabel label = ErasureUtils.uncheckedCast(tree.label()); return label.index() - 1; } return rightIndex(tree.children()[tree.children().length - 1]); }