private static Object getFeatureValue(Feature feature, Class<? extends Object> class1, Annotation annotation) throws ResourceProcessException { if(class1 == Integer.class){ return annotation.getIntValue(feature); }else if(class1 == String.class){ return annotation.getStringValue(feature); }else if(class1 == Boolean.class){ return annotation.getBooleanValue(feature); }else{ throw new ResourceProcessException("Received a class type that I'm not familiar with: ", new Object[]{class1}); } }
private static Object getFeatureValue(Feature feature, Class<? extends Object> class1, Annotation annotation) throws ResourceProcessException { if(class1 == Integer.class){ return annotation.getIntValue(feature); }else if(class1 == String.class){ return annotation.getStringValue(feature); }else if(class1 == Boolean.class){ return annotation.getBooleanValue(feature); }else{ throw new ResourceProcessException("Received a class type that I'm not familiar with: ", new Object[]{class1}); } }
/** * add a concept to the map of concepts for the current named entity. * * @param jcas * @param concepts * @param annoCandidate * @param cuiFeature * @param tuiFeature * @param bMedication * @return is this concept a medication concept? only check if * checkMedications is true */ private boolean addConcept(JCas jcas, Map<String, OntologyConcept> concepts, Annotation annoCandidate, Feature cuiFeature, Feature tuiFeature, boolean bMedication) { String cui = annoCandidate.getStringValue(cuiFeature); if (concepts.containsKey(cui)) return bMedication; OntologyConcept oc = new OntologyConcept(jcas); oc.setCode(cui); oc.setCodingScheme("METAMAP"); StringArray tuiArr = (StringArray) annoCandidate .getFeatureValue(tuiFeature); List<String> tuis = null; if (tuiArr != null) tuis = Arrays.asList(tuiArr.toStringArray()); concepts.put(cui, oc); return checkMedications && tuis != null ? !Collections.disjoint( setMedicationAbrs, tuis) : false; }
/** * add a concept to the map of concepts for the current named entity. * * @param jcas * @param concepts * @param annoCandidate * @param cuiFeature * @param tuiFeature * @param bMedication * @return is this concept a medication concept? only check if * checkMedications is true */ private boolean addConcept(JCas jcas, Map<String, OntologyConcept> concepts, Annotation annoCandidate, Feature cuiFeature, Feature tuiFeature, boolean bMedication) { String cui = annoCandidate.getStringValue(cuiFeature); if (concepts.containsKey(cui)) return bMedication; OntologyConcept oc = new OntologyConcept(jcas); oc.setCode(cui); oc.setCodingScheme("METAMAP"); StringArray tuiArr = (StringArray) annoCandidate .getFeatureValue(tuiFeature); List<String> tuis = null; if (tuiArr != null) tuis = Arrays.asList(tuiArr.toStringArray()); concepts.put(cui, oc); return checkMedications && tuis != null ? !Collections.disjoint( setMedicationAbrs, tuis) : false; }
static void writeFieldToDb(String range, BasicDBObject o, Annotation a, String dbKey, Feature f) { if (range.equals("String")) { o.put(dbKey, a.getStringValue(f)); } else if (range.equals("StringArray")) { StringArray sa = (StringArray) a.getFeatureValue(f); if (sa != null) { String[] vals = sa.toArray(); o.put(dbKey, Lists.newArrayList(vals)); } } else if (range.equals("Integer")) { o.put(dbKey, a.getIntValue(f)); } else if (range.equals("Float")) { o.put(dbKey, a.getFloatValue(f)); } else if (range.equals("Boolean")) { o.put(dbKey, a.getBooleanValue(f)); } else { LOG.warn("range not supported " + range); } }
String rangeName = f.getRange().getName(); if (rangeName.equals("uima.cas.String")) { newAnnotation.setStringValue(f, a.getStringValue(f)); } else if (rangeName.equals("uima.cas.Integer")) { newAnnotation.setIntValue(f, a.getIntValue(f));
tokenTmp.pos = token.getStringValue(featPOS); if (tokenTmp.pos != null) { c++;
ret = StringToObject.convertStringToObject(a.getStringValue(f)); break; case CAS.TYPE_NAME_INTEGER:
ret = StringToObject.convertStringToObject(a.getStringValue(f)); break; case CAS.TYPE_NAME_INTEGER: