org.apache.uima.jcas.tcas.Annotation.getFeatureValue()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.apache.uima.jcas.tcas.Annotation.getFeatureValue()方法的一些代码示例,展示了Annotation.getFeatureValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getFeatureValue()方法的具体详情如下:
包路径:org.apache.uima.jcas.tcas.Annotation
类名称:Annotation
方法名:getFeatureValue

Annotation.getFeatureValue介绍

暂无

代码示例

代码示例来源:origin: dstl/baleen

/**
 * Convert a UIMA feature array to a List of Java objects of the correct type, parsing Strings to
 * objects where possible
 *
 * @param f UIMA CAS Feature
 * @param a UIMA CAS Annotation
 * @return List of Java objects, or empty if unable to convert
 */
public static List<Object> featureToList(Feature f, Annotation a) {
 if (a.getFeatureValue(f) == null) {
  return Collections.emptyList();
 }
 return Arrays.asList(toArray(f, a));
}

代码示例来源:origin: uk.gov.dstl.baleen/baleen-uima

/**
 * Convert a UIMA feature array to a List of Java objects of the correct type, parsing Strings to
 * objects where possible
 *
 * @param f UIMA CAS Feature
 * @param a UIMA CAS Annotation
 * @return List of Java objects, or empty if unable to convert
 */
public static List<Object> featureToList(Feature f, Annotation a) {
 if (a.getFeatureValue(f) == null) {
  return Collections.emptyList();
 }
 return Arrays.asList(toArray(f, a));
}

代码示例来源:origin: dstl/baleen

/**
 * Convert a UIMA feature array to an array of Java objects of the correct type, parsing Strings
 * to objects where possible
 *
 * @param f UIMA CAS Feature
 * @param a UIMA CAS Annotation
 * @return Array of Java objects, or null if unable to convert
 */
public static Object[] featureToArray(Feature f, Annotation a) {
 Object[] ret;
 if (a.getFeatureValue(f) == null) {
  ret = new Object[0];
 } else {
  ret = toArray(f, a);
 }
 return ret;
}

代码示例来源:origin: uk.gov.dstl.baleen/baleen-uima

/**
 * Convert a UIMA feature array to an array of Java objects of the correct type, parsing Strings
 * to objects where possible
 *
 * @param f UIMA CAS Feature
 * @param a UIMA CAS Annotation
 * @return Array of Java objects, or null if unable to convert
 */
public static Object[] featureToArray(Feature f, Annotation a) {
 Object[] ret;
 if (a.getFeatureValue(f) == null) {
  ret = new Object[0];
 } else {
  ret = toArray(f, a);
 }
 return ret;
}

代码示例来源:origin: uk.gov.dstl.baleen/baleen-uima

private static Object[] toArray(Feature f, Annotation a) {
  Object[] ret;

  try {
   CommonArrayFS array = (CommonArrayFS) a.getFeatureValue(f);
   ret = new Object[array.size()];
   int index = 0;
   for (String s : array.toStringArray()) {
    ret[index] = StringToObject.convertStringToObject(s);
    index++;
   }

   return ret;
  } catch (ClassCastException cce) {
   LoggerFactory.getLogger(FeatureUtils.class)
     .debug("Couldn't cast feature value to array", cce);
   return new Object[0];
  }
 }
}

代码示例来源:origin: dstl/baleen

private static Object[] toArray(Feature f, Annotation a) {
  Object[] ret;

  try {
   CommonArrayFS array = (CommonArrayFS) a.getFeatureValue(f);
   ret = new Object[array.size()];
   int index = 0;
   for (String s : array.toStringArray()) {
    ret[index] = StringToObject.convertStringToObject(s);
    index++;
   }

   return ret;
  } catch (ClassCastException cce) {
   LoggerFactory.getLogger(FeatureUtils.class)
     .debug("Couldn't cast feature value to array", cce);
   return new Object[0];
  }
 }
}

代码示例来源:origin: org.apache.ctakes/ctakes-ytex-uima

/**
 * 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;
}

代码示例来源:origin: apache/ctakes

/**
 * 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;
}

代码示例来源:origin: ch.epfl.bbp.nlp/bluima_mongodb

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);
  }
}

代码示例来源:origin: org.apache.ctakes/ctakes-ytex-uima

.getFeatureValue(feat);
if (fsCol != null
    && (fsCol instanceof FSArray || fsCol instanceof FSList)) {
    feat.getRange().getName(),
    new AnnoFSAttribute(annoId, anno
        .getFeatureValue(feat), null));

代码示例来源:origin: apache/ctakes

.getFeatureValue(feat);
if (fsCol != null
    && (fsCol instanceof FSArray || fsCol instanceof FSList)) {
    feat.getRange().getName(),
    new AnnoFSAttribute(annoId, anno
        .getFeatureValue(feat), null));

代码示例来源:origin: org.apache.ctakes/ctakes-ytex-uima

Annotation negAnno = negIter.next();
FSArray spanArr = (FSArray) negAnno
    .getFeatureValue(spanFeature);
if (spanArr != null) {
  for (int i = 0; i < spanArr.size(); i++) {

代码示例来源:origin: apache/ctakes

Annotation negAnno = negIter.next();
FSArray spanArr = (FSArray) negAnno
    .getFeatureValue(spanFeature);
if (spanArr != null) {
  for (int i = 0; i < spanArr.size(); i++) {

相关文章