Java Code Examples for org.apache.uima.cas.Feature#getShortName()
The following examples show how to use
org.apache.uima.cas.Feature#getShortName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FeatureTableModel.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Gets the value at. * * @param rowIndex the row index * @param columnIndex the column index * @return the value at * @see javax.swing.table.TableModel#getValueAt(int, int) */ @Override public Object getValueAt(int rowIndex, int columnIndex) { if (this.type == null) { return null; } List<?> feats = this.type.getFeatures(); if (rowIndex < 0 || rowIndex >= feats.size()) { return null; } Feature feat = (Feature) feats.get(rowIndex); switch (columnIndex) { case 0: { return feat.getShortName(); } case 1: { return feat.getRange().getName(); } case 2: { return feat.getDomain().getName(); } default: { return null; } } }
Example 2
Source File: AnnotationFeaturesViewer.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Gets the feature names for type. * * @param aTypeName the a type name * @param cas the cas * @return the feature names for type */ // untimely ripped from UIMA since it does not work with a taeDescription private String[] getFeatureNamesForType(String aTypeName, CAS cas) { TypeSystem ts = cas.getTypeSystem(); Type t = ts.getType(aTypeName); if (t != null) { List features = t.getFeatures(); String[] featNames = new String[features.size()]; for (int i = 0; i < features.size(); i++) { Feature f = (Feature) features.get(i); featNames[i] = f.getShortName(); } return featNames; } else { return null; } }
Example 3
Source File: FeaturePathImpl.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Override public void addFeature(Feature feat) { // check if currently feature path ends with a built-in function if (this.builtInFunction > 0) { throw new CASRuntimeException(MESSAGE_DIGEST, "INVALID_FEATURE_PATH_SYNTAX_ADD", new Object[] { getFeaturePathString(), feat.getShortName() }); } // add feature to feature path this.featurePathElementNames.add(feat.getShortName()); this.boundFeatures.add((FeatureImpl) feat); // if current featurePath was already initialized we cannot guarantee that // the path is still ever valid so we have to evaluate the path on the // fly. if (this.boundBaseType != null && PathValid.NEVER == TypeSystemUtils.isPathValid(this.boundBaseType, this.featurePathElementNames)) { this.boundBaseType = null; // can't be used for this path } }
Example 4
Source File: CasCompare.java From uima-uimaj with Apache License 2.0 | 5 votes |
private void mismatchFs(TOP fs1, TOP fs2, Feature fi, Feature fi2) { if (isSkipMismatch) return; Pair<TOP, TOP> pair = new Pair<>(fs1, fs2); if (prevReport.contains(pair)) { if (leafErrorReported == null) { leafErrorReported = pair; } return; // already reported } prevReport.add(pair); if (leafErrorReported == null) { leafErrorReported = pair; String mapmsg = fi.equals(fi2) ? "" : "which mapped to target feature " + fi2.getShortName() + " "; mismatchSb.append(String.format("Mismatched Feature Structures in feature %s %s%n %s%n %s%n", fi.getShortName(), mapmsg, ps(fs1), ps(fs2))); } else { TOP ofs1 = leafErrorReported.t; TOP ofs2 = leafErrorReported.u; String s1 = String.format(" from: %s:%d, %s:%d", fs1.getType().getShortName(), fs1._id, fs2.getType().getShortName(), fs2._id); s1maxLen = Math.max(s1.length() + 4, s1maxLen); mismatchSb.append(String.format("%-"+s1maxLen+"s original mismatch: %s:%d, %s, %d%n", s1, ofs1.getType().getShortName(), ofs1._id, ofs2.getType().getShortName(), ofs2._id)); } }
Example 5
Source File: CASMgrSerializer.java From uima-uimaj with Apache License 2.0 | 5 votes |
private void encodeFeatureDecls(TypeSystemImpl ts) { final int max = ts.getSmallestFeature() + ts.getNumberOfFeatures(); this.featureNames = new String[max]; this.featDecls = new int[max * 3]; Feature f; for (int i = ts.getSmallestFeature(); i < max; i++) { f = ts.ll_getFeatureForCode(i); this.featureNames[i] = f.getShortName(); this.featDecls[i * 3] = ((TypeImpl) f.getDomain()).getCode(); this.featDecls[(i * 3) + 1] = ((TypeImpl) f.getRange()).getCode(); this.featDecls[(i * 3) + 2] = f.isMultipleReferencesAllowed() ? 1 : 0; } }
Example 6
Source File: DebugFSLogicalStructure.java From uima-uimaj with Apache License 2.0 | 5 votes |
private static void fillFeatures(DebugNameValuePair[] result, int startOffset, FeatureStructure fs, List<Feature> features) { int nbrFeats = features.size(); int i = startOffset; for (int j = 0; j < nbrFeats; j++) { Feature feat = features.get(j); DebugNameValuePair nv = new DebugNameValuePair(feat.getShortName(), null); String rangeTypeName = feat.getRange().getName(); if ("uima.cas.Integer".equals(rangeTypeName)) nv.setValue(fs.getIntValue(feat)); else if ("uima.cas.Float".equals(rangeTypeName)) nv.setValue(fs.getFloatValue(feat)); else if ("uima.cas.Boolean".equals(rangeTypeName)) nv.setValue(fs.getBooleanValue(feat)); else if ("uima.cas.Byte".equals(rangeTypeName)) nv.setValue(fs.getByteValue(feat)); else if ("uima.cas.Short".equals(rangeTypeName)) nv.setValue(fs.getShortValue(feat)); else if ("uima.cas.Long".equals(rangeTypeName)) nv.setValue(fs.getLongValue(feat)); else if ("uima.cas.Double".equals(rangeTypeName)) nv.setValue(fs.getDoubleValue(feat)); else if ("uima.cas.String".equals(rangeTypeName)) nv.setValue(fs.getStringValue(feat)); else nv.setValue(fs.getFeatureValue(feat)); if (nv.getValue() == null) { nv.setValue("null"); } result[i++] = nv; } }
Example 7
Source File: CasAnnotationViewer.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Check if an annotation matches the filters set by the user. If true, the * annotation will be added to the annotation tree display panel. * * @param annotation the annotation * @return true, if is match */ private boolean isMatch(Annotation annotation) { Type type = annotation.getType(); switch (this.viewMode) { case MODE_ANNOTATIONS: if (this.typeToCheckBoxMap.size() == 0) { return false; } JCheckBox typeCheckBox = this.typeToCheckBoxMap.get(type); return typeCheckBox != null && typeCheckBox.isSelected(); case MODE_ENTITIES: if (this.entityToCheckBoxMap.size() == 0) { return false; } Entity entity = this.entityResolver.getEntity(annotation); if (entity == null) { return false; } JCheckBox entityCheckBox = this.entityToCheckBoxMap.get(entity); return entityCheckBox != null && entityCheckBox.isSelected(); case MODE_FEATURES: JRadioButton typeRadioButton = this.typeRadioButtonMap.get(type); if (typeRadioButton == null || !typeRadioButton.isSelected()) { return false; } List<Feature> features = type.getFeatures(); if (features == null || features.size() == 0) { return false; } for (Feature feature : features) { String featureName = feature.getShortName(); if (featureName == null || featureName.length() == 0) { continue; } JRadioButton featureRadioButton = this.featureRadioButtonMap.get(featureName); if (featureRadioButton == null || !featureRadioButton.isSelected()) { continue; } String featureValue = this.getFeatureValueInString(annotation, feature); if (featureValue == null || featureValue.length() == 0) { continue; } JCheckBox featureValueCheckBox = this.featureValueCheckBoxMap.get(featureValue); return featureValueCheckBox != null && featureValueCheckBox.isSelected(); } break; default: break; } return false; }
Example 8
Source File: AddCapabilityFeatureDialog.java From uima-uimaj with Apache License 2.0 | 2 votes |
/** * return the actual type name : short-feature-name. * * @param feature the feature * @return the actual type name : short-feature-name */ protected String getTypeFeature(Feature feature) { return selectedType.getName() + ':' + feature.getShortName(); }