BratUimaStructureMapping(BT bratType, Type uimaType, Map<Feature, String> featureRoles, BratNoteMapper noteMapper) { super(bratType, uimaType, noteMapper); this.featureRoles = ImmutableMap.copyOf(featureRoles); // sanity check List<Feature> utFeatures = uimaType.getFeatures(); for (Feature f : featureRoles.keySet()) { if (!utFeatures.contains(f)) { throw new IllegalArgumentException(String.format( "Feature %s does not belong to type %s", f, uimaType)); } } }
/** * returns the Features for a type in a result spec * @param ts The type system, may be null * @return list of features for a type in a result spec */ List<Feature> getAllAppropriateFeatures(final TypeSystem ts) { if (null == ts) { return EMPTY_FEATURE_LIST; } Type t = ts.getType(typeName); return (null == t) ? EMPTY_FEATURE_LIST : t.getFeatures(); }
public Vector<Feature> getIntroFeatures(Type type) { Vector<Feature> feats = new Vector<Feature>(); List<Feature> appropFeats = type.getFeatures(); final int max = appropFeats.size(); Feature feat; for (int i = 0; i < max; i++) { feat = appropFeats.get(i); if (feat.getDomain() == type) { feats.add(feat); } } return feats; }
private boolean isSpanLayer(TypeSystem aTS, Type aType) { // A UIMA type can be a span layer if... // ... there are only primitive features or slot features List<Feature> nonPrimitiveFeatures = aType.getFeatures().stream() .filter(f -> !isBuiltInFeature(f)) .filter(f -> !(f.getRange().isPrimitive() || isSlotFeature(aTS, f))) .collect(Collectors.toList()); return nonPrimitiveFeatures.isEmpty(); }
private boolean isSpanLayer(TypeSystem aTS, Type aType) { // A UIMA type can be a span layer if... // ... there are only primitive features or slot features List<Feature> nonPrimitiveFeatures = aType.getFeatures().stream() .filter(f -> !isBuiltInFeature(f)) .filter(f -> !(f.getRange().isPrimitive() || isSlotFeature(aTS, f))) .collect(Collectors.toList()); return nonPrimitiveFeatures.isEmpty(); }
public FSTreeNode(CAS cas, ITreeNode parent, FeatureStructure annotation, Stack<Type> parentTypes) { super(cas, parent); this.fs = annotation; parentTypes.push(fs.getType()); for (Feature f : annotation.getType().getFeatures()) { addFeatures(this, f, annotation, cas, parentTypes); } parentTypes.pop(); }
private void fillFeatures(FeatureStructure oldFS, FeatureStructure newFS, Type newType, Map<Integer, Integer> new2oldBegin, Map<Integer, Integer> new2oldEnd, RutaStream stream, RuleMatch match) { for (Object obj : newType.getFeatures()) { Feature feature = (Feature) obj; String sn = feature.getShortName(); if (!"sofa".equals(sn) && !"begin".equals(sn) && !"end".equals(sn)) { Feature oldFeature = oldFS.getType().getFeatureByBaseName(sn); fillFeature(oldFS, oldFeature, newFS, feature, new2oldBegin, new2oldEnd, stream, match); } } }
/** * The default method for copying the features of one {@code FeatureStructure} to another of the * same type. * * @param from the {@code FeatureStructure} to copy from. * @param to the {@code FeatureStructure} to copy to. */ private void defaultCopy(FeatureStructure from, FeatureStructure to) { List<Feature> features = from.getType().getFeatures(); for (Feature feature : features) { featureCopiers.copyFeature(feature, from, to); } }
private void fillFeatures(FeatureStructure oldFS, FeatureStructure newFS, Type newType, Map<Integer, Integer> new2oldBegin, Map<Integer, Integer> new2oldEnd, TextMarkerStream stream, RuleMatch match) { for (Object obj : newType.getFeatures()) { Feature feature = (Feature) obj; String sn = feature.getShortName(); if (!"sofa".equals(sn) && !"begin".equals(sn) && !"end".equals(sn)) { Feature oldFeature = oldFS.getType().getFeatureByBaseName(sn); fillFeature(oldFS, oldFeature, newFS, feature, new2oldBegin, new2oldEnd, stream, match); } } }
private void convertFeatures(Map<String, Object> map, Base base) { for (Feature f : base.getType().getFeatures()) { processFeature(map, base, f); } map.put(fields.getType(), base.getType().getShortName()); if (map.get(FIELD_VALUE) == null || Strings.isNullOrEmpty(map.get(FIELD_VALUE).toString())) { map.put(FIELD_VALUE, base.getCoveredText()); } }
public FSTreeNode(ITreeNode parent, FeatureStructure annotation, List<Type> parentTypes) { super(parent); this.fs = annotation; parentTypes.add(fs.getType()); for (Feature f : annotation.getType().getFeatures()) { addFeatures(this, f, annotation, parentTypes); } }
public static boolean isSpanLayer(Type aType) { boolean compatible = true; for (Feature feat : aType.getFeatures()) { if (CAS.FEATURE_BASE_NAME_SOFA.equals(feat.getShortName())) { continue; } if (!(isPrimitiveFeature(feat) || isSlotFeature(feat))) { compatible = false; //LOG.debug("Incompatible feature in type [" + aType + "]: " + feat); break; } } return compatible; }
public static void collect(Set<FeatureStructure> aFSes, FeatureStructure aFS) { if (aFS != null && !aFSes.contains(aFS)) { aFSes.add(aFS); for (Feature f : aFS.getType().getFeatures()) { if (!f.getRange().isPrimitive() && !CAS.FEATURE_BASE_NAME_SOFA.equals(f.getShortName())) { collect(aFSes, aFS.getFeatureValue(f)); } } } }
public static Feature[] getAllFeatures(FeatureStructure aFS) { Feature[] cachedSortedFeatures = new Feature[aFS.getType().getNumberOfFeatures()]; int i = 0; for (Feature f : aFS.getType().getFeatures()) { cachedSortedFeatures[i] = f; i++; } return cachedSortedFeatures; }
private int getExpectedSize(BaleenAnnotation r) { if (r instanceof Relation) { // Number of Features - sofa - internalId + _id + externalId + type + history return r.getType().getFeatures().size() - 2 + 4; } // Number of Features - sofa - internalId - referent + externalId + type + history return r.getType().getFeatures().size() - 3 + 3; } }
public static void collect(Set<FeatureStructure> aFSes, FeatureStructure aFS) { if (aFS != null && !aFSes.contains(aFS)) { aFSes.add(aFS); for (Feature f : aFS.getType().getFeatures()) { if (!f.getRange().isPrimitive() && !CAS.FEATURE_BASE_NAME_SOFA.equals(f.getShortName())) { collect(aFSes, aFS.getFeatureValue(f)); } } } }
public static void collect(Set<FeatureStructure> aFSes, FeatureStructure aFS) { if (aFS != null && !aFSes.contains(aFS)) { aFSes.add(aFS); for (Feature f : aFS.getType().getFeatures()) { if (!f.getRange().isPrimitive() && !CAS.FEATURE_BASE_NAME_SOFA.equals(f.getShortName())) { collect(aFSes, aFS.getFeatureValue(f)); } } } }
public static Feature[] getAllFeatures(FeatureStructure aFS) { Feature[] cachedSortedFeatures = new Feature[aFS.getType().getNumberOfFeatures()]; int i = 0; for (Feature f : aFS.getType().getFeatures()) { cachedSortedFeatures[i] = f; i++; } return cachedSortedFeatures; }
private int getExpectedSize(Relation r) { // Number of Features - sofa - internalId - referent // + _id + externalId + sentence + docId + 3*normalised distances // + 2*sourceType + sourceValue + 2*targetType + targetValue return r.getType().getFeatures().size() - 3 + 13; } }
public static void testType(JCas jcas, TOP top) throws Exception { Class<?> cls = top.getClass(); if (top instanceof Annotation) { testAnnotationType(jcas, (Annotation) top); } Type type = jcas.getTypeSystem().getType(cls.getName()); for (Object obj : type.getFeatures()) { Feature feature = (Feature) obj; if (feature.getDomain().equals(type)) { invokeMethods(cls, type, top, jcas, feature.getShortName()); } } }