本文整理汇总了Java中edu.stanford.nlp.util.ErasureUtils.uncheckedCast方法的典型用法代码示例。如果您正苦于以下问题:Java ErasureUtils.uncheckedCast方法的具体用法?Java ErasureUtils.uncheckedCast怎么用?Java ErasureUtils.uncheckedCast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.util.ErasureUtils
的用法示例。
在下文中一共展示了ErasureUtils.uncheckedCast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equals
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Entry)) {
return false;
}
Entry<K,V> e = ErasureUtils.<Entry<K,V>>uncheckedCast(o);
Object key1 = e.getKey();
if (!(key != null && key.equals(key1))) {
return false;
}
Object value1 = e.getValue();
if (!(value != null && value.equals(value1))) {
return false;
}
return true;
}
示例2: train
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
public void train(Collection<Tree> trees) {
Numberer tagNumberer = Numberer.getGlobalNumberer("tags");
lex.train(trees);
ClassicCounter<String> initial = new ClassicCounter<String>();
GeneralizedCounter ruleCounter = new GeneralizedCounter(2);
for (Tree tree : trees) {
List<Label> tags = tree.preTerminalYield();
String last = null;
for (Label tagLabel : tags) {
String tag = tagLabel.value();
tagNumberer.number(tag);
if (last == null) {
initial.incrementCount(tag);
} else {
ruleCounter.incrementCount2D(last, tag);
}
last = tag;
}
}
int numTags = tagNumberer.total();
POSes = new HashSet<String>(ErasureUtils.<Collection<String>>uncheckedCast(tagNumberer.objects()));
initialPOSDist = Distribution.laplaceSmoothedDistribution(initial, numTags, 0.5);
markovPOSDists = new HashMap<String, Distribution>();
Set entries = ruleCounter.lowestLevelCounterEntrySet();
for (Iterator iter = entries.iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
// Map.Entry<List<String>, Counter> entry = (Map.Entry<List<String>, Counter>) iter.next();
Distribution d = Distribution.laplaceSmoothedDistribution((ClassicCounter) entry.getValue(), numTags, 0.5);
markovPOSDists.put(((List<String>) entry.getKey()).get(0), d);
}
}
示例3: dumpNumberer
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static void dumpNumberer(Numberer num, String name, PrintWriter pw) {
pw.println("### Sorted contents of " + name);
List<Comparable> lis = new ArrayList<Comparable>(ErasureUtils.<Collection<Comparable>>uncheckedCast(num.objects()));
Collections.sort(lis);
for (Object obj : lis) {
pw.println(obj);
}
pw.println("### End sorted contents of " + name);
pw.flush();
}
示例4: equalsIgnoreName
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
public boolean equalsIgnoreName(Object o) {
if (this == o) {
return true;
}
if (o instanceof Dependency) {
Dependency<Label, Label, Object> d = ErasureUtils.<Dependency<Label, Label, Object>>uncheckedCast(o);
return governor().equals(d.governor()) && dependent().equals(d.dependent());
}
return false;
}
示例5: getCount
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
/**
* A convenience method equivalent to <code>{@link
* #getCounts}({o1,o2})</code>; works only for depth 2
* GeneralizedCounters
*/
public double getCount(K o1, K o2) {
if (depth != 2) {
wrongDepth();
}
GeneralizedCounter<K> gc1 = ErasureUtils.<GeneralizedCounter<K>>uncheckedCast(map.get(o1));
if (gc1 == null) {
return 0.0;
} else {
return gc1.getCount(o2);
}
}
示例6: conditionalizeHelper
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
private GeneralizedCounter<K> conditionalizeHelper(K o) {
if (depth > 1) {
GeneralizedCounter<K> next = ErasureUtils.<GeneralizedCounter<K>>uncheckedCast(map.get(o));
if (next == null) // adds a new GeneralizedCounter if needed
{
map.put(o, (next = new GeneralizedCounter<K>(depth - 1)));
}
return next;
} else {
throw new RuntimeException("Error -- can't conditionalize a distribution of depth 1");
}
}
示例7: deserializeCounter
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
public static <T> ClassicCounter<T> deserializeCounter(String filename) throws Exception {
// reconstitute
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(filename)));
ClassicCounter<T> c = ErasureUtils.<ClassicCounter<T>>uncheckedCast(in.readObject());
in.close();
return c;
}
示例8: getAllDependents
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
/**
* Returns all the dependencies of a certain node.
*
* @param node The node to return dependents for
* @return map of dependencies
*/
private static Map<Class<? extends GrammaticalRelationAnnotation>, Set<TreeGraphNode>> getAllDependents(TreeGraphNode node) {
Map<Class<? extends GrammaticalRelationAnnotation>, Set<TreeGraphNode>> newMap = Generics.newHashMap();
for (Class<?> o : node.label.keySet()) {
if (GrammaticalRelationAnnotation.class.isAssignableFrom(o)) {
// ignore any non-GrammaticalRelationAnnotation element
Class<? extends GrammaticalRelationAnnotation> typedKey = ErasureUtils.uncheckedCast(o);
newMap.put(typedKey, node.label.get(typedKey));
}
}
return newMap;
}
示例9: getType
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
public Class<List<String>> getType() {
return ErasureUtils.uncheckedCast(List.class);
}
示例10: getType
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
public Class<List<VerbMultiToken>> getType() {
return ErasureUtils.uncheckedCast(List.class);
}
示例11: getType
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
public Class<List<HeidelTimeAnnotator.TimexObject>> getType() {
return ErasureUtils.uncheckedCast(List.class);
}
示例12: getType
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
public Class<List<IMWE<IToken>>> getType() {
return ErasureUtils.uncheckedCast(List.class);
}
示例13: getType
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
@Override public Class<List<LinkingTag>> getType() {
return ErasureUtils.<Class<List<LinkingTag>>>uncheckedCast(List.class);
}
示例14: getType
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
public Class<List<CyberEntityMention>> getType() {
return ErasureUtils.uncheckedCast(List.class);
}
示例15: blankDocument
import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
/**
* Returns a new empty BasicDocument with the same title, labels, and
* tokenizer as this Document. This is useful when you want to make a
* new Document that's like the old document but
* can be filled with new text (e.g. if you're transforming
* the contents non-destructively).
* <p/>
* <p>Subclasses that want to preserve extra state should
* override this method and add the extra state to the new document before
* returning it. The new BasicDocument is created by calling
* <tt>getClass().newInstance()</tt> so it should be of the correct subclass,
* and thus you should be able to cast it down and add extra meta data directly.
* Note however that in the event an Exception is thrown on instantiation
* (e.g. if your subclass doesn't have a public empty constructor--it should btw!)
* then a new <tt>BasicDocument</tt> is used instead. Thus if you want to be paranoid
* (or some would say "correct") you should check that your instance is of
* the correct sub-type as follows (this example assumes the subclass is called
* <tt>NumberedDocument</tt> and it has the additional <tt>number</tt>property):
* <pre>Document blankDocument=super.blankDocument();
* if(blankDocument instanceof NumberedDocument) {
* ((NumberedDocument)blankDocument).setNumber(getNumber());</pre>
*/
public <OUT> Document<L, Word, OUT> blankDocument() {
BasicDocument<L> bd;
// tries to instantiate by reflection, settles for direct instantiation
try {
bd = ErasureUtils.<BasicDocument<L>>uncheckedCast(getClass().newInstance());
} catch (Exception e) {
bd = new BasicDocument<L>();
}
// copies over basic meta-data
bd.setTitle(title());
bd.setLabels(labels());
bd.setTokenizerFactory(tokenizerFactory);
// cast to the new output type
return ErasureUtils.<Document<L, Word, OUT>>uncheckedCast(bd);
}