public static Feature getOptionalFeature(Type type, String featureName, String rangeType) throws AnalysisEngineProcessException { Feature feature = type.getFeatureByBaseName(featureName); checkFeatureType(feature, rangeType); return feature; }
public static Feature getRequiredFeature(Type type, String featureName) throws AnalysisEngineProcessException { Feature feature = type.getFeatureByBaseName(featureName); if (feature == null) { throw new OpenNlpAnnotatorProcessException( ExceptionMessages.FEATURE_NOT_FOUND, new Object[] {type.getName(), featureName}); } return feature; }
private static Feature getMandatoryFeature(FeatureStructure aFS, String aFeature) { Feature feat = aFS.getType().getFeatureByBaseName(aFeature); if (feat == null) { throw new IllegalArgumentException("Type [" + aFS.getType() + "] has no feature with name [" + aFeature + "]"); } return feat; }
@Override public void init(JCas aJCas) { sentences = select(aJCas, Sentence.class).iterator(); CAS cas = aJCas.getCas(); Type chunkType = CasUtil.getType(cas, Chunk.class); Feature chunkTagFeature = chunkType.getFeatureByBaseName("chunkValue"); chunkEncoder = new IobEncoder(cas, chunkType, chunkTagFeature); }
public static Feature getRequiredFeature(Type type, String featureName) throws AnalysisEngineProcessException { Feature feature = type.getFeatureByBaseName(featureName); if (feature == null) { throw new OpenNlpAnnotatorProcessException( ExceptionMessages.FEATURE_NOT_FOUND, new Object[] {type.getName(), featureName}); } return feature; }
/** * Get the link following the current link. */ private AnnotationFS getNextLink(AnnotationFS aLink) { return (AnnotationFS) aLink.getFeatureValue(aLink.getType().getFeatureByBaseName( linkNextFeatureName)); }
public static Feature getRequiredFeature(Type type, String featureName) throws AnalysisEngineProcessException { Feature feature = type.getFeatureByBaseName(featureName); if (feature == null) { throw new OpenNlpAnnotatorProcessException( ExceptionMessages.FEATURE_NOT_FOUND, new Object[] { type.getName(), featureName}); } return feature; }
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); } } }
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 List<AnnotationFS> collectLinks(FeatureStructure aChain) { List<AnnotationFS> links = new ArrayList<>(); // Now we seek the link within the current chain AnnotationFS linkFs = (AnnotationFS) aChain.getFeatureValue(aChain.getType() .getFeatureByBaseName(getChainFirstFeatureName())); while (linkFs != null) { links.add(linkFs); linkFs = getNextLink(linkFs); } return links; }
private static List<AnnotationFS> getRelAnnosOnPosition(AnnotationFS aFs, AnnotationFS aOriginFs, AnnotationFS aTargetFs, JCas aJcas) { Type type = aFs.getType(); Feature sourceFeat = type.getFeatureByBaseName(WebAnnoConst.FEAT_REL_SOURCE); Feature targetFeat = type.getFeatureByBaseName(WebAnnoConst.FEAT_REL_TARGET); return selectCovered(aJcas.getCas(), type, aFs.getBegin(), aFs.getEnd()).stream() .filter(fs -> fs.getFeatureValue(sourceFeat).equals(aOriginFs) && fs.getFeatureValue(targetFeat).equals(aTargetFs)) .collect(Collectors.toList()); }
/** * Get the first link of a chain from the chain head feature structure. */ private AnnotationFS getFirstLink(FeatureStructure aChain) { return (AnnotationFS) aChain.getFeatureValue(aChain.getType().getFeatureByBaseName( getChainFirstFeatureName())); }
/** * Set the first link of a chain in the chain head feature structure. */ private void setFirstLink(FeatureStructure aChain, AnnotationFS aLink) { aChain.setFeatureValue(aChain.getType().getFeatureByBaseName(getChainFirstFeatureName()), aLink); }
/** * Set the link following the current link. */ private void setNextLink(AnnotationFS aLink, AnnotationFS aNext) { aLink.setFeatureValue( aLink.getType().getFeatureByBaseName(getLinkNextFeatureName()), aNext); }
/** * Set the first link of a chain in the chain head feature structure. */ private void setFirstLink(FeatureStructure aChain, AnnotationFS aLink) { aChain.setFeatureValue(aChain.getType().getFeatureByBaseName(getChainFirstFeatureName()), aLink); }
/** * Get the first link of a chain from the chain head feature structure. */ private AnnotationFS getFirstLink(FeatureStructure aChain) { return (AnnotationFS) aChain.getFeatureValue(aChain.getType().getFeatureByBaseName( getChainFirstFeatureName())); }
/** * Set the link following the current link. */ private void setNextLink(AnnotationFS aLink, AnnotationFS aNext) { aLink.setFeatureValue( aLink.getType().getFeatureByBaseName(getLinkNextFeatureName()), aNext); }
/** * Get the link following the current link. */ private AnnotationFS getNextLink(AnnotationFS aLink) { return (AnnotationFS) aLink.getFeatureValue(aLink.getType().getFeatureByBaseName( getLinkNextFeatureName())); }
@Override public List<String> getAnnotation(JCas aJcas, AnnotationFeature aFeature, int begin, int end) { Type type = getType(aJcas.getCas(), getAnnotationTypeName()); List<String> annotations = new ArrayList<String>(); for (AnnotationFS fs : selectCovered(aJcas.getCas(), type, begin, end)) { Feature labelFeature = fs.getType().getFeatureByBaseName(aFeature.getName()); annotations.add(fs.getFeatureValueAsString(labelFeature)); } return annotations; }
/** * Create a new chain head feature structure. Already adds the chain to the CAS. */ private FeatureStructure newChain(JCas aJCas, AnnotationFS aFirstLink) { Type chainType = getAnnotationType(aJCas.getCas()); FeatureStructure newChain = aJCas.getCas().createFS(chainType); newChain.setFeatureValue(chainType.getFeatureByBaseName(chainFirstFeatureName), aFirstLink); aJCas.addFsToIndexes(newChain); return newChain; }