Package org.apache.uima.cas_data

Examples of org.apache.uima.cas_data.FeatureStructure


    TypeSystemDescription result = UIMAFramework.getResourceSpecifierFactory()
            .createTypeSystemDescription();
    Iterator iter = aCasData.getFeatureStructures();
    ArrayList typesArr = new ArrayList();
    while (iter.hasNext()) {
      FeatureStructure casFS = (FeatureStructure) iter.next();
      TypeDescription newType = UIMAFramework.getResourceSpecifierFactory().createTypeDescription();
      newType.setName(casFS.getType());
      newType.setSupertypeName("uima.tcas.annotation");
      newType.setDescription("CasData Type");
      String features[] = casFS.getFeatureNames();
      if (features != null) {
        for (int i = 0; i < features.length; i++) {
          String featName = features[i];
          String rangeName = "";
          String description = "";
          PrimitiveValue pVal = (PrimitiveValue) casFS.getFeatureValue(featName);
          if (pVal.get().getClass().getName().equals("java.lang.String")) {
            System.out.println(" the feature is a String ");
            rangeName = "uima.cas.String";
            description = " featue of the casDataType";
          }
View Full Code Here


  private static final Class<CasDataUtils> CLASS_NAME = CasDataUtils.class;

  public static boolean hasFeature(CasData aCAS, String featureName) {
    Iterator<FeatureStructure> it = aCAS.getFeatureStructures();
    while (it.hasNext()) {
        FeatureStructure fs = it.next();
        FeatureValue fValue = fs.getFeatureValue(featureName);
        if (fValue != null) {
          return true;
        }
    }
    return false;
View Full Code Here

  }

  public static boolean hasFeatureStructure(CasData aCAS, String aName) {
    Iterator<FeatureStructure> it = aCAS.getFeatureStructures();
    while (it.hasNext()) {
        FeatureStructure fs = it.next();
        if (fs.getType().equals(aName)) {
          return true;
        }
    }
    return false;
  }
View Full Code Here

  }

  public static void dumpFeatures(CasData aCAS) {
    Iterator<FeatureStructure> it = aCAS.getFeatureStructures();
    while (it.hasNext()) {
        FeatureStructure fs = it.next();
        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(), "dumpFeatures",
                LOG_RESOURCE_BUNDLE, "UIMA_cas_feature_structure_type__FINE", fs.getType());

        String[] names = fs.getFeatureNames();
        for (int i = 0; names != null && i < names.length; i++) {
          FeatureValue fValue = fs.getFeatureValue(names[i]);
          if (fValue != null) {
            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                    "dumpFeatures", LOG_RESOURCE_BUNDLE, "UIMA_cas_feature_name__FINE",
                    new Object[] { names[i], fValue.toString() });
          }
View Full Code Here

  public static String getFeatureValueByType(CasData aCAS, String featureName) {
    Iterator<FeatureStructure> it = aCAS.getFeatureStructures();
    String featureValue = null;
    while (it.hasNext()) {
        FeatureStructure fs = it.next();
        if (System.getProperty("DEBUG") != null)
          System.out.println("FeatureName::::::::::::::::::::::::::::::::::::::::::>"
                  + fs.getType() + " Searching For::" + featureName);
        if (featureName.equals(fs.getType())) {
          String[] names = fs.getFeatureNames();
          for (int i = 0; names != null && i < names.length; i++) {
            if (System.getProperty("DEBUG") != null)
              System.out.println("Feature Structure:::" + fs.getType() + " Has Value::" + names[i]);
          }

          if ("uima.cpm.DocumentText".equals(featureName) || "UTF8:UTF8Content".equals(featureName)) {
            FeatureValue fValue = fs.getFeatureValue("value");
            if (fValue == null) {
              return null;
            }
            return fValue.toString();
          } else if ("Detag:DetagContent".equals(featureName)) {
            FeatureValue fValue = fs.getFeatureValue("Doc:SpannedText");
            if (fValue == null) {
              return null;
            }
            return fValue.toString();

          }
          FeatureValue fValue = fs.getFeatureValue(featureName);
          if (fValue != null) {
            featureValue = fValue.toString();
            break;
          }
      }
View Full Code Here

          String featureName) {
    Iterator<FeatureStructure> it = aCAS.getFeatureStructures();
    String featureValue = null;
    Vector<String> v = new Vector<String>();
    while (it.hasNext()) {
        FeatureStructure fs = it.next();
        if (featureStructureName.equals(fs.getType())) {
          String[] names = fs.getFeatureNames();
          for (int i = 0; names != null && i < names.length; i++) {
            if (names[i].equals(featureName)) {
              FeatureValue fValue = fs.getFeatureValue(featureName);
              if (fValue != null) {
                featureValue = fValue.toString();
                v.add(featureValue);
              }
            }
View Full Code Here

  public static String getFeatureValueByType(CasData aCAS, String aFeatureStructure,
          String featureName) {
    Iterator<FeatureStructure> it = aCAS.getFeatureStructures();
    String featureValue = null;
    while (it.hasNext()) {
      FeatureStructure fs = it.next();
      if (fs.getType().equals(aFeatureStructure)) {
        FeatureValue fValue = fs.getFeatureValue(featureName);
        if (fValue != null) {
          featureValue = fValue.toString();
          break;
        }
      }
View Full Code Here

  public static NameValuePair[] getCasDataFeatures(CasData aCasData, String aFeatureStructureName) {
    NameValuePair[] valuePairSet = null;
    Iterator<FeatureStructure> it = aCasData.getFeatureStructures();

    while (it.hasNext()) {
      FeatureStructure fs = it.next();
      if (fs.getType().equals(aFeatureStructureName)) {
        String[] featureNames = fs.getFeatureNames();
        if (featureNames == null) {
          // return empty set
          return new NameValuePair[0];
        }
        valuePairSet = new NameValuePair[featureNames.length];
        for (int i = 0; i < featureNames.length; i++) {
          valuePairSet[i] = new NameValuePair_impl();
          valuePairSet[i].setName(featureNames[i]);
          valuePairSet[i].setValue(fs.getFeatureValue(featureNames[i]).toString());
          // System.out.println("DATACasUtils.getCasDataFeatures()-Name::"+valuePairSet[i].getName()+"
          // Value:::"+valuePairSet[i].getValue().toString());
        }
      }
    }
View Full Code Here

    TypeSystemDescription result = UIMAFramework.getResourceSpecifierFactory()
        .createTypeSystemDescription();
    Iterator<FeatureStructure> iter = aCasData.getFeatureStructures();
    List<TypeDescription> typesArr = new ArrayList<TypeDescription>();
    while (iter.hasNext()) {
      FeatureStructure casFS = iter.next();
      TypeDescription newType = UIMAFramework.getResourceSpecifierFactory().createTypeDescription();
      newType.setName(casFS.getType());
      newType.setSupertypeName("uima.tcas.annotation");
      newType.setDescription("CasData Type");
      String features[] = casFS.getFeatureNames();
      if (features != null) {
        for (int i = 0; i < features.length; i++) {
          String featName = features[i];
          String rangeName = "";
          String description = "";
          PrimitiveValue pVal = (PrimitiveValue) casFS.getFeatureValue(featName);
          if (pVal.get().getClass().getName().equals("java.lang.String")) {
            System.out.println(" the feature is a String ");
            rangeName = "uima.cas.String";
            description = " featue of the casDataType";
          }
View Full Code Here

    }

    // iterate over FSs and generate XCAS
    Iterator<FeatureStructure> iter = aCasData.getFeatureStructures();
    while (iter.hasNext()) {
      FeatureStructure fs = iter.next();
      if (mTypesToFilter == null || !mTypesToFilter.contains(fs.getType())) {
        _generate(fs, docTextHolder);
      }
    }

    // end enclosing CAS tag
View Full Code Here

TOP

Related Classes of org.apache.uima.cas_data.FeatureStructure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.