@Override public Set<Class<?>> keySet() { return label.keySet(); }
@SuppressWarnings({"unchecked", "SuspiciousMethodCalls"}) private void makeGenericKeyCache(CoreLabel c) { genericAnnotationKeys = Generics.newHashSet(); for (Class<?> key : c.keySet()) { if (CoreLabel.genericValues.containsKey(key)) { Class<? extends GenericAnnotation<?>> genKey = (Class<? extends GenericAnnotation<?>>) key; genericAnnotationKeys.add(genKey); } } }
/** * see merge(CoreMap base, CoreMap toBeMerged) */ public static CoreLabel merge(CoreLabel base, CoreLabel toBeMerged){ //(variables) CoreLabel rtn = new CoreLabel(base.size()); //(copy base) for(Class key : base.keySet()){ rtn.set(key,base.get(key)); } //(merge) for(Class key : toBeMerged.keySet()){ rtn.set(key,toBeMerged.get(key)); } //(return) return rtn; }
case MAP: { Map map2 = new TreeMap(); for(Class key : this.keySet()) { map2.put(key.getName(), get(key)); buf.append(value()); Map map2 = new TreeMap(asClassComparator); for(Class key : this.keySet()) { map2.put(key, get(key)); for(Class key : this.keySet()) { String cls = key.getName(); for(Class en: this.keySet()){ buf.append(';').append(en).append(':').append(this.get(en));
assert l.get(PatternsAnnotations.MatchedPatterns.class) != null : "How come MatchedPatterns class is null for the token. The classes in the key set are " + l.keySet(); l.get(PatternsAnnotations.MatchedPatterns.class).add(pSur);
assert l.get(PatternsAnnotations.MatchedPatterns.class) != null : "How come MatchedPatterns class is null for the token. The classes in the key set are " + l.keySet(); l.get(PatternsAnnotations.MatchedPatterns.class).add(pSur);
for (Class key : newNode.backingLabel().keySet()) { newNode.set(key, rootNode.get(key));
@Override public Set<Class<?>> keySet() { return label.keySet(); }
@Override public Set<Class<?>> keySet() { return label.keySet(); }
@SuppressWarnings({"unchecked", "SuspiciousMethodCalls"}) private void makeGenericKeyCache(CoreLabel c) { genericAnnotationKeys = new HashSet<Class<? extends GenericAnnotation<?>>>(); for (Class<?> key : c.keySet()) { if (CoreLabel.genericValues.containsKey(key)) { Class<? extends GenericAnnotation<?>> genKey = (Class<? extends GenericAnnotation<?>>) key; genericAnnotationKeys.add(genKey); } } }
@SuppressWarnings({"unchecked", "SuspiciousMethodCalls"}) private void makeGenericKeyCache(CoreLabel c) { genericAnnotationKeys = Generics.newHashSet(); for (Class<?> key : c.keySet()) { if (CoreLabel.genericValues.containsKey(key)) { Class<? extends GenericAnnotation<?>> genKey = (Class<? extends GenericAnnotation<?>>) key; genericAnnotationKeys.add(genKey); } } }
@SuppressWarnings({"unchecked", "SuspiciousMethodCalls"}) private void makeGenericKeyCache(CoreLabel c) { genericAnnotationKeys = Generics.newHashSet(); for (Class<?> key : c.keySet()) { if (CoreLabel.genericValues.containsKey(key)) { Class<? extends GenericAnnotation<?>> genKey = (Class<? extends GenericAnnotation<?>>) key; genericAnnotationKeys.add(genKey); } } }
/** * Returns all the dependencies of a certain node. * * @param node The node to return dependents for * @return map of dependencies */ private static <GR extends GrammaticalRelationAnnotation> // separating this out helps some compilers 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<GR> typedKey = ErasureUtils.uncheckedCast(o); newMap.put(typedKey, node.label.get(typedKey)); } } return newMap; }
/** * Finds all arcs between this node and <code>destNode</code>, * and returns the <code>Set</code> of <code>Object</code>s which * label those arcs. If no such arcs exist, returns an empty * <code>Set</code>. * * @param destNode the destination node * @return the <code>Set</code> of <code>Object</code>s which * label arcs between this node and <code>destNode</code> */ public Set<Class<? extends GrammaticalRelationAnnotation>> arcLabelsToNode(TreeGraphNode destNode) { Set<Class<? extends GrammaticalRelationAnnotation>> arcLabels = Generics.newHashSet(); CoreLabel cl = label(); for (Class key : cl.keySet()) { if (key == null || !GrammaticalRelationAnnotation.class.isAssignableFrom(key)) { continue; } Class<? extends GrammaticalRelationAnnotation> typedKey = ErasureUtils.uncheckedCast(key); Set<TreeGraphNode> val = cl.get(typedKey); if (val != null && val.contains(destNode)) { arcLabels.add(typedKey); } } return arcLabels; }
public CoreLabelMapMatrix(CoreLabel coreLabel) { for (Class c : coreLabel.keySet()) { if (CoreAnnotations.ValueAnnotation.class == c) { map.put("Value", coreLabel.getString(CoreAnnotations.ValueAnnotation.class)); } else if (CoreAnnotations.TextAnnotation.class == c) { map.put("Token", coreLabel.getString(CoreAnnotations.TextAnnotation.class)); } else if (CoreAnnotations.OriginalTextAnnotation.class == c) { map.put("OriginalText", coreLabel.getString(CoreAnnotations.OriginalTextAnnotation.class)); } else if (CoreAnnotations.CharacterOffsetBeginAnnotation.class == c) { map.put("CharacterOffsetBegin", String.valueOf(coreLabel.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class))); } else if (CoreAnnotations.CharacterOffsetEndAnnotation.class == c) { map.put("CharacterOffsetEnd", String.valueOf(coreLabel.get(CoreAnnotations.CharacterOffsetEndAnnotation.class))); } else if (CoreAnnotations.PositionAnnotation.class == c) { map.put("CharacterOffsetEnd", coreLabel.getString(CoreAnnotations.PositionAnnotation.class)); } else if (CoreAnnotations.BeforeAnnotation.class == c) { map.put("Before", coreLabel.getString(CoreAnnotations.BeforeAnnotation.class)); } else if (CoreAnnotations.ShapeAnnotation.class == c) { map.put("Shape", coreLabel.getString(CoreAnnotations.ShapeAnnotation.class)); } else if (CoreAnnotations.GoldAnswerAnnotation.class == c) { map.put("GoldAnswer", coreLabel.getString(CoreAnnotations.GoldAnswerAnnotation.class)); } else if (CoreAnnotations.AnswerAnnotation.class == c) { map.put("Answer", coreLabel.getString(CoreAnnotations.AnswerAnnotation.class)); } else if (CoreAnnotations.AfterAnnotation.class == c) { map.put("After", coreLabel.getString(CoreAnnotations.AfterAnnotation.class)); } else { throw new RuntimeException("unknown key class: " + c); } } }
} else if (format.equals("{map}")) { Map map2 = new TreeMap(); for(Class key : this.keySet()) { map2.put(key.getName(), get(key)); buf.append(value()); Map map2 = new TreeMap(asClassComparator); for(Class key : this.keySet()) { map2.put(key, get(key)); for(Class key : this.keySet()) { String cls = key.getName();
/** * Two CoreMaps are equal iff all keys and values are equal (really, ==). * This equals method that is well defined even if there * are cycles in keys/values. Checks for object address * equality for key-value pairs. */ @SuppressWarnings({"unchecked"}) @Override public boolean equals(Object obj) { if (!(obj instanceof CoreLabel)) { return false; } CoreLabel other = (CoreLabel) obj; if (!this.keySet().equals(other.keySet())) { return false; } for (Class key : this.keySet()) { if (this.get(key) != other.get(key)) { return false; } } return true; }
case MAP: { Map map2 = new TreeMap(); for(Class key : this.keySet()) { map2.put(key.getName(), get(key)); buf.append(value()); Map map2 = new TreeMap(asClassComparator); for(Class key : this.keySet()) { map2.put(key, get(key)); for(Class key : this.keySet()) { String cls = key.getName(); for(Class en: this.keySet()){ buf.append(';').append(en).append(':').append(this.get(en));
assert l.get(PatternsAnnotations.MatchedPatterns.class) != null : "How come MatchedPatterns class is null for the token. The classes in the key set are " + l.keySet(); l.get(PatternsAnnotations.MatchedPatterns.class).add(pSur);
assert l.get(PatternsAnnotations.MatchedPatterns.class) != null : "How come MatchedPatterns class is null for the token. The classes in the key set are " + l.keySet(); l.get(PatternsAnnotations.MatchedPatterns.class).add(pSur);