Package org.apache.uima.cas

Examples of org.apache.uima.cas.StringArrayFS


            sfs.set(0, 1);
          }
        }
        break;
      case 19:{
          StringArrayFS sfs = (StringArrayFS) fs.getFeatureValue(akofAstring);
          if ((null != sfs) && (0 < sfs.size())) {
            sfs.set(0, "change");
          }
        }
        break;
      case 20: {
          FloatArrayFS sfs = (FloatArrayFS) fs.getFeatureValue(akofAfloat);
          if ((null != sfs) && (0 < sfs.size())) {
            sfs.set(0, 1F);
          }
        }
        break;
      case 21: {
          DoubleArrayFS sfs = (DoubleArrayFS) fs.getFeatureValue(akofAdouble);
          if ((null != sfs) && (0 < sfs.size())) {
            sfs.set(0, 1D);
          }
        }
        break;
      case 22: {
          LongArrayFS sfs = (LongArrayFS) fs.getFeatureValue(akofAlong);
          if ((null != sfs) && (0 < sfs.size())) {
            sfs.set(0, 1L);
          }
        }
        break;
      case 23: {
          ShortArrayFS sfs = (ShortArrayFS) fs.getFeatureValue(akofAshort);
          if ((null != sfs) && (0 < sfs.size())) {
            sfs.set(0, (short)1);
          }
        }
        break;
      case 24: {
          ByteArrayFS sfs = (ByteArrayFS) fs.getFeatureValue(akofAbyte);
          if ((null != sfs) && (0 < sfs.size())) {
            sfs.set(0, (byte)1);
          }
        }
        break;
      case 25: {
          ArrayFS sfs = (ArrayFS) fs.getFeatureValue(akofAfs);
          if ((null != sfs) && (0 < sfs.size())) {
            sfs.set(0, lfs.get(r.nextInt(lfs.size())));
          }
        }
      break;
      }
    }     
View Full Code Here


            fs = null;
          }
        }

        if (arrayType == LowLevelCAS.TYPE_CLASS_STRINGARRAY) {
          StringArrayFS strFS = new StringArrayFSImpl(addr, cas);
          fsvalues = strFS.toArray();
        } else {
          fsvalues = fs.toStringArray();
        }

        for (int i = 0; i < fsvalues.length; i++) {
View Full Code Here

    // create an FS of exampleType and index it
    AnnotationFS fs = cas.createAnnotation(exampleType, 1, 5);
    cas.getIndexRepository().addFS(fs);

    // create Array FSs
    StringArrayFS strArrayFS = cas.createStringArrayFS(5);
    strArrayFS.set(0, "zzzzzz");
    strArrayFS.set(1, "yyyyyy");
    strArrayFS.set(2, "xxxxxx");
    strArrayFS.set(3, "wwwwww");
    strArrayFS.set(4, "vvvvvv");

    IntArrayFS intArrayFS = cas.createIntArrayFS(5);
    intArrayFS.set(0, Integer.MAX_VALUE);
    intArrayFS.set(1, Integer.MAX_VALUE - 1);
    intArrayFS.set(2, 42);
View Full Code Here

    Feature classesFeat = entityType.getFeatureByBaseName("classes");
    Iterator<FeatureStructure> iter = cas.getIndexRepository().getIndex("testEntityIndex").iterator();
    assertTrue(iter.hasNext());
    while (iter.hasNext()) {
      FeatureStructure fs = iter.next();
      StringArrayFS arrayFS = (StringArrayFS) fs.getFeatureValue(classesFeat);
      assertNotNull(arrayFS);
      for (int i = 0; i < arrayFS.size(); i++) {
        assertNotNull(arrayFS.get(i));
      }
    }

    // reserialize
    StringWriter sw = new StringWriter();
View Full Code Here

    Feature classesFeat = entityType.getFeatureByBaseName("classes");
    Iterator<FeatureStructure> iter = cas2.getIndexRepository().getIndex("testEntityIndex").iterator();
    assertTrue(iter.hasNext());
    while (iter.hasNext()) {
      FeatureStructure fs = iter.next();
      StringArrayFS arrayFS = (StringArrayFS) fs.getFeatureValue(classesFeat);
      assertNotNull(arrayFS);
      for (int i = 0; i < arrayFS.size(); i++) {
        assertNotNull(arrayFS.get(i));
      }
    }
  }
View Full Code Here

    assertTrue(gerView.getAnnotationIndex().size() == 5); // 4 annots plus documentAnnotation
  }
 
  public void testStringArrayWithNullValues() throws Exception {
    CAS cas = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
    StringArrayFS strArray = cas.createStringArrayFS(3);
    strArray.set(1, "value");
    cas.getIndexRepository().addFS(strArray);
   
    assertEquals(null, strArray.get(0));
    assertEquals("value", strArray.get(1));
    assertEquals(null, strArray.get(2));
   
    //serialize to XCAS and back
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    XCASSerializer.serialize(cas,baos);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XCASDeserializer.deserialize(bais, cas);

    //check
    Iterator iter = cas.getIndexRepository().getAllIndexedFS(cas.getTypeSystem().getType("uima.cas.StringArray"));
    StringArrayFS strArrayOut = (StringArrayFS)iter.next();
    assertEquals(null, strArrayOut.get(0));
    assertEquals("value", strArrayOut.get(1));
    assertEquals(null, strArrayOut.get(2));
  }
View Full Code Here

      cas.setDocumentText("Sample Text");

      // test stringArray feature
      Feature stringArrayFeat = cas.getDocumentAnnotation().getType()
            .getFeatureByBaseName("stringArray");
      StringArrayFS stringArrayFS = cas.createStringArrayFS(4);
      stringArrayFS.set(0, "Test0");
      stringArrayFS.set(1, "Test1");
      stringArrayFS.set(2, "Test2");
      cas.getDocumentAnnotation().setFeatureValue(stringArrayFeat,
            stringArrayFS);
      String path = "/stringArray";
      FeaturePath featurePath = new FeaturePathImpl();
      featurePath.initialize(path);
View Full Code Here

        tableModel.addRow(new Object[] { featName, new Integer(intVal) });
      } else if (CAS.TYPE_NAME_FLOAT.equals(rangeTypeName)) {
        float floatVal = aAnnotation.getFloatValue(feat);
        tableModel.addRow(new Object[] { featName, new Float(floatVal) });
      } else if (CAS.TYPE_NAME_STRING_ARRAY.equals(rangeTypeName)) {
        StringArrayFS arrayFS = (StringArrayFS) aAnnotation.getFeatureValue(feat);
        StringBuffer displayVal = new StringBuffer();
        if (arrayFS == null) {
          displayVal.append("null");
        } else {
          displayVal.append('[');
          String[] vals = arrayFS.toArray();
          for (int i = 0; i < vals.length - 1; i++) {
            displayVal.append(vals[i]);
            displayVal.append(',');
          }
          if (vals.length > 0) {
            displayVal.append(vals[vals.length - 1]);
          }
          displayVal.append(']');
        }
        tableModel.addRow(new Object[] { featName, displayVal });
      } else if (CAS.TYPE_NAME_INTEGER_ARRAY.equals(rangeTypeName)) {
        IntArrayFS arrayFS = (IntArrayFS) aAnnotation.getFeatureValue(feat);
        StringBuffer displayVal = new StringBuffer();
        if (arrayFS == null) {
          displayVal.append("null");
        } else {
          displayVal.append('[');
          int[] vals = arrayFS.toArray();
          for (int i = 0; i < vals.length - 1; i++) {
            displayVal.append(vals[i]);
            displayVal.append(',');
          }
          if (vals.length > 0) {
            displayVal.append(vals[vals.length - 1]);
          }
          displayVal.append(']');
        }
        tableModel.addRow(new Object[] { featName, displayVal });
      } else if (CAS.TYPE_NAME_FLOAT_ARRAY.equals(rangeTypeName)) {
        FloatArrayFS arrayFS = (FloatArrayFS) aAnnotation.getFeatureValue(feat);
        StringBuffer displayVal = new StringBuffer();
        if (arrayFS == null) {
          displayVal.append("null");
        } else {
          displayVal.append('[');
          float[] vals = arrayFS.toArray();
          for (int i = 0; i < vals.length - 1; i++) {
            displayVal.append(vals[i]);
            displayVal.append(',');
          }
          if (vals.length > 0) {
View Full Code Here

    } else if (value instanceof CommonArrayFS) {
      CommonArrayFS array = (CommonArrayFS) value;

      size = array.size();
    } else if (value instanceof StringArrayFS) {
      StringArrayFS array = (StringArrayFS) value;

      size = array.size();
    } else {
      throw new CasEditorError("Unkown array type!");
    }

    return size;
View Full Code Here

    assertTrue(fs.getShortValue(shortFeature) == Short.MIN_VALUE);
    assertTrue(fs.getLongValue(longFeature) == Long.MIN_VALUE);
    assertTrue(fs.getDoubleValue(doubleFeature) == Double.MAX_VALUE);

    // check the array values
    StringArrayFS strArrayFS = (StringArrayFS) fs.getFeatureValue(stringArrayFeature);
    assertTrue(strArrayFS.get(0).equals("zzzzzz"));
    assertTrue(strArrayFS.get(1).equals("yyyyyy"));
    assertTrue(strArrayFS.get(2).equals("xxxxxx"));
    assertTrue(strArrayFS.get(3).equals("wwwwww"));
    assertTrue(strArrayFS.get(4).equals("vvvvvv"));

    IntArrayFS intArrayFS = (IntArrayFS) fs.getFeatureValue(intArrayFeature);
    assertTrue(intArrayFS.get(0) == Integer.MAX_VALUE);
    assertTrue(intArrayFS.get(1) == Integer.MAX_VALUE - 1);
    assertTrue(intArrayFS.get(2) == 42);
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.StringArrayFS

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.