/** * Gets the local feature definition. * * @param td the td * @param fd the fd * @return the local feature definition */ protected FeatureDescription getLocalFeatureDefinition(TypeDescription td, FeatureDescription fd) { return getLocalFeatureDefinition(td, fd.getName()); }
protected String makeAttribute(FeatureDescription fd) { String rangeTypeName = fd.getRangeTypeName(); Attribute attr = null; if (rangeTypeName.equals("uima.cas.String")) { attr = new Attribute(fd.getName()); return fd.getName(); } else if (rangeTypeName.equals("uima.cas.Integer")) { attr = new Attribute(fd.getName()); return fd.getName(); } else if (rangeTypeName.equals("uima.cas.Double")) { attr = new Attribute(fd.getName()); return fd.getName(); } else if (rangeTypeName.equals("uima.cas.Boolean")) { attr = new Attribute(fd.getName()); return fd.getName(); } // return attr; return null; }
/** * Checks if is same feature description. * * @param f1 the f 1 * @param f2 the f 2 * @return true, if is same feature description */ private boolean isSameFeatureDescription(FeatureDescription f1, FeatureDescription f2) { if (!f2.getName().equals(f1.getName())) return false; if (!f2.getRangeTypeName().equals(f1.getRangeTypeName())) return false; return true; }
/** * returns null if no feature by this name. * * @param name the name * @param td the td * @return the feature from type description */ public FeatureDescription getFeatureFromTypeDescription(String name, TypeDescription td) { FeatureDescription[] fds = td.getFeatures(); if (fds == null) return null; for (int i = 0; i < fds.length; i++) { if (name.equals(fds[i].getName())) return fds[i]; } return null; }
/** * Sets the named feature description range. * * @param localFds the local fds * @param featureName the feature name * @param rangeName the range name */ // this function to set the corresponding feature in the "local" type's fd array private void setNamedFeatureDescriptionRange(FeatureDescription[] localFds, String featureName, final String rangeName) { if (null != localFds) { for (int i = 0; i < localFds.length; i++) { FeatureDescription fd = localFds[i]; if (fd.getName().equals(featureName)) { fd.setRangeTypeName(rangeName); return; } } } }
private void inferFeatureMap(TypeDescription type) { // 1 - Recursively add features of the super type TypeDescription superType = typeSystemDescription.getType(type.getSupertypeName()); if(superType != null) inferFeatureMap(superType); // 2 - Add features of this type for(FeatureDescription feature:type.getFeatures()) { String featureFQN = type.getName() + ":" + feature.getName(); featureMap.put(feature.getName(), featureFQN); featureMap.put(featureFQN, featureFQN); } }
/** * Sets the feature value. * * @param fd the fd * @param td the td * @return the string */ String setFeatureValue(FeatureDescription fd, TypeDescription td) { return simpleCore("set", getGetSetNamePart(fd), fd.getName()); }
/** * Sets the array feature value. * * @param fd the fd * @param td the td * @return the string */ String setArrayFeatureValue(FeatureDescription fd, TypeDescription td) { return arrayCore("set", getGetSetArrayNamePart(fd), getJavaRangeType(fd), fd.getName()); }
String setFeatureValue(FeatureDescription fd, TypeDescription td) { return simpleCore("set", getGetSetNamePart(fd), fd.getName(), getJavaName(td) + "_Type"); }
String setArrayFeatureValue(FeatureDescription fd, TypeDescription td) { return arrayCore("set", getGetSetArrayNamePart(fd), fd.getName(), getJavaName(td) + "_Type"); }
private void addFeature(OntModel ontModel, OntClass ontClass, FeatureDescription feature) { if (ontModel.getDatatypeProperty(namespace + feature.getName()) == null) { DatatypeProperty property = ontModel.createDatatypeProperty(namespace + feature.getName()); String propertyComment = feature.getDescription(); if (propertyComment != null) { property.addComment(propertyComment, EN); } property.addDomain(ontClass); property.addRange(getRange(feature)); } }
/** * gets a feature description for a type, including supertypes. * * @param td the td * @param featureName the feature name * @return a feature description for a type, including supertypes */ public FeatureDescription getFeature(TypeDescription td, String featureName) { FeatureDescription[] features = td.getFeatures(); String supertypeName; if (null != features) for (int i = 0; i < features.length; i++) { if (featureName.equals(features[i].getName())) return features[i]; } if (null != (supertypeName = td.getSupertypeName())) if (!CAS.TYPE_NAME_TOP.equals(supertypeName)) { TypeDescription supertype = getMergedTypeSystemDescription().getType(supertypeName); if (null == supertype) supertype = (TypeDescription) BuiltInTypes.typeDescriptions.get(supertypeName); return getFeature(supertype, featureName); } return null; }
private void addFeature(OntModel ontModel, OntClass ontClass, FeatureDescription feature) { if (ontModel.getDatatypeProperty(namespace + feature.getName()) == null) { DatatypeProperty property = ontModel.createDatatypeProperty(namespace + feature.getName()); String propertyComment = feature.getDescription(); if (propertyComment != null) { property.addComment(propertyComment, EN); } property.addDomain(ontClass); property.addRange(getRange(feature)); } }
/** * Gets the feature value. * * @param fd the fd * @param td the td * @return the feature value */ String getFeatureValue(FeatureDescription fd, TypeDescription td) { String getSetNamePart = getGetSetNamePart(fd); String core = simpleCore("get", getSetNamePart, fd.getName()); return castResult(getJavaRangeType(fd), core); }
/** * Gets the array feature value. * * @param fd the fd * @param td the td * @return the array feature value */ String getArrayFeatureValue(FeatureDescription fd, TypeDescription td) { String getSetArrayNamePart = getGetSetArrayNamePart(fd); String core = arrayCore("get", getSetArrayNamePart, getJavaRangeType(fd), fd.getName()); return castResult(getJavaRangeArrayElementType(fd), core); }
String getArrayFeatureValue(FeatureDescription fd, TypeDescription td) { String getSetArrayNamePart = getGetSetArrayNamePart(fd); String core = wrapToGetFS(arrayCore("get", getSetArrayNamePart, fd.getName(), getJavaName(td) + "_Type"), getSetArrayNamePart); return castResult(getJavaRangeArrayElementType(fd), core); }
String getFeatureValue(FeatureDescription fd, TypeDescription td) { String getSetNamePart = getGetSetNamePart(fd); String core = wrapToGetFS(simpleCore("get", getSetNamePart, fd.getName(), getJavaName(td) + "_Type"), getSetNamePart); return castResult(getJavaRangeType(fd), core); }
private void analyzeFeatures(AnnotationLayer aLayer, TypeSystem aTS, TypeDescription aTD, Optional<? extends LayerDetails> aDetails) { Type type = aTS.getType(aTD.getName()); for (FeatureDescription fd : aTD.getFeatures()) { Feature feat = type.getFeatureByBaseName(fd.getName()); // We do not need to set up built-in features if (isBuiltInFeature(feat)) { continue; } if (aDetails.isPresent() && aDetails.get().isHiddenFeature(feat)) { continue; } AnnotationFeature f = analyzeFeature(aTS, fd, feat); features.put(aLayer.getName(), f); } }
private void analyzeFeatures(AnnotationLayer aLayer, TypeSystem aTS, TypeDescription aTD, Optional<? extends LayerDetails> aDetails) { Type type = aTS.getType(aTD.getName()); for (FeatureDescription fd : aTD.getFeatures()) { Feature feat = type.getFeatureByBaseName(fd.getName()); // We do not need to set up built-in features if (isBuiltInFeature(feat)) { continue; } if (aDetails.isPresent() && aDetails.get().isHiddenFeature(feat)) { continue; } AnnotationFeature f = analyzeFeature(aTS, fd, feat); features.put(aLayer.getName(), f); } }