Examples of DoubleArrayFS


Examples of org.apache.uima.cas.DoubleArrayFS

      array.set(slot, Long.parseLong(value));
    } else if (arrayFS instanceof FloatArrayFS) {
      FloatArrayFS array = (FloatArrayFS) arrayFS;
      array.set(slot, Float.parseFloat(value));
    } else if (arrayFS instanceof DoubleArrayFS) {
      DoubleArrayFS array = (DoubleArrayFS) arrayFS;
      array.set(slot, Double.parseDouble(value));
    } else if (arrayFS instanceof StringArrayFS) {
      StringArrayFS array = (StringArrayFS) arrayFS;
      array.set(slot, value);
    } else {
      throw new TaeError("Unkown array type!");
    }
  }
View Full Code Here

Examples of org.apache.uima.cas.DoubleArrayFS

      return array.get(slot);
    } else if (arrayFS instanceof FloatArrayFS) {
      FloatArrayFS array = (FloatArrayFS) arrayFS;
      return array.get(slot);
    } else if (arrayFS instanceof DoubleArrayFS) {
      DoubleArrayFS array = (DoubleArrayFS) arrayFS;
      return array.get(slot);
    } else if (arrayFS instanceof StringArrayFS) {
      StringArrayFS array = (StringArrayFS) arrayFS;

      String value = array.get(slot);

      if (value == null) {
        value = "";
      }

      return value;
    } else if (arrayFS instanceof ArrayFS) {
      ArrayFS array = (ArrayFS) arrayFS;
      return array.get(slot);
    } else {
      throw new TaeError("Unkown array type!");
    }
  }
View Full Code Here

Examples of org.apache.uima.cas.DoubleArrayFS

      array.set(slot, Long.parseLong(value));
    } else if (arrayFS instanceof FloatArrayFS) {
      FloatArrayFS array = (FloatArrayFS) arrayFS;
      array.set(slot, Float.parseFloat(value));
    } else if (arrayFS instanceof DoubleArrayFS) {
      DoubleArrayFS array = (DoubleArrayFS) arrayFS;
      array.set(slot, Double.parseDouble(value));
    } else if (arrayFS instanceof StringArrayFS) {
      StringArrayFS array = (StringArrayFS) arrayFS;
      array.set(slot, value);
    } else {
      throw new CasEditorError("Unkown array type!");
    }
  }
View Full Code Here

Examples of org.apache.uima.cas.DoubleArrayFS

      return array.get(slot);
    } else if (arrayFS instanceof FloatArrayFS) {
      FloatArrayFS array = (FloatArrayFS) arrayFS;
      return array.get(slot);
    } else if (arrayFS instanceof DoubleArrayFS) {
      DoubleArrayFS array = (DoubleArrayFS) arrayFS;
      return array.get(slot);
    } else if (arrayFS instanceof StringArrayFS) {
      StringArrayFS array = (StringArrayFS) arrayFS;

      String value = array.get(slot);

      if (value == null) {
        value = "";
      }

      return value;
    } else if (arrayFS instanceof ArrayFS) {
      ArrayFS array = (ArrayFS) arrayFS;
      return array.get(slot);
    } else {
      throw new CasEditorError("Unkown array type!");
    }
  }
View Full Code Here

Examples of org.apache.uima.cas.DoubleArrayFS

        } else if (CAS.TYPE_NAME_LONG_ARRAY.equals(rangeTypeName)) {
          LongArrayFS arrayFS = (LongArrayFS) aFS.getFeatureValue(feat);
          if (arrayFS != null)
            vals = arrayFS.toStringArray();
        } else if (CAS.TYPE_NAME_DOUBLE_ARRAY.equals(rangeTypeName)) {
          DoubleArrayFS arrayFS = (DoubleArrayFS) aFS.getFeatureValue(feat);
          if (arrayFS != null)
            vals = arrayFS.toStringArray();
        }
        String attrVal;
        if (vals == null) {
          attrVal = "null";
        } else {
View Full Code Here

Examples of org.apache.uima.cas.DoubleArrayFS

        destFS.set(i, arrayFs.get(i));
      }
      return destFS;
    }
    if (aSrcFs instanceof DoubleArrayFS) {
      DoubleArrayFS arrayFs = (DoubleArrayFS) aSrcFs;
      int len = arrayFs.size();
      DoubleArrayFS destFS = mDestBaseCas.createDoubleArrayFS(len);
      for (int i = 0; i < len; i++) {
        destFS.set(i, arrayFs.get(i));
      }
      return destFS;
    }
    if (aSrcFs instanceof BooleanArrayFS) {
      BooleanArrayFS arrayFs = (BooleanArrayFS) aSrcFs;
      int len = arrayFs.size();
      BooleanArrayFS destFS = mDestBaseCas.createBooleanArrayFS(len);
      for (int i = 0; i < len; i++) {
        destFS.set(i, arrayFs.get(i));
      }
      return destFS;
    }
    if (aSrcFs instanceof ArrayFS) {
      ArrayFS arrayFs = (ArrayFS) aSrcFs;
      int len = arrayFs.size();
      ArrayFS destFS = mDestBaseCas.createArrayFS(len);
      for (int i = 0; i < len; i++) {
        FeatureStructure srcElem = arrayFs.get(i);
        if (srcElem != null) {
          FeatureStructure copyElem = copyFsInner(arrayFs.get(i));
          destFS.set(i, copyElem);
        }
      }
      return destFS;
    }
    assert false; // the set of array types should be exhaustive, so we should never get here
View Full Code Here

Examples of org.apache.uima.cas.DoubleArrayFS

      // SofaFS longarraySofaFS = cas.createSofa(id, "text");
      // longarraySofaFS.setLocalSofaData(longArrayFS);
      CAS longArrayView =this.cas.createView("longArraySofaData");
      longArrayView.setSofaDataArray(longArrayFS, "longs");

      DoubleArrayFS doubleArrayFS =this.cas.createDoubleArrayFS(5);
      doubleArrayFS.set(0, Double.MAX_VALUE);
      doubleArrayFS.set(1, Double.MIN_VALUE);
      doubleArrayFS.set(2, Double.parseDouble("1.5555"));
      doubleArrayFS.set(3, Double.parseDouble("99.000000005"));
      doubleArrayFS.set(4, Double.parseDouble("4.44444444444444444"));
      // create a Sofa and set the SofaArray feature.
      // id = new SofaID_impl();
      // id.setSofaID("doubleArraySofaData");
      // SofaFS doublearraySofaFS = cas.createSofa(id, "text");
      // doublearraySofaFS.setLocalSofaData(doubleArrayFS);
      CAS doubleArrayView =this.cas.createView("doubleArraySofaData");
      doubleArrayView.setSofaDataArray(doubleArrayFS, "doubles");

      // create remote sofa and set the SofaURI feature
      // id = new SofaID_impl();
      // id.setSofaID("remoteSofaData");
      // SofaFS remoteSofa = cas.createSofa(id, "text");
      // remoteSofa.setRemoteSofaURI("file:.\\Sofa.xcas");
      CAS remoteView =this.cas.createView("remoteSofaData");
      String sofaFileName = "./Sofa.xcas";
      remoteView.setSofaDataURI("file:" + sofaFileName, "text");
      PrintWriter out = new PrintWriter(sofaFileName);
      out.print("this beer is good");
      out.close();
     
      // read sofa data
      // InputStream is = strSofa.getSofaDataStream();
      InputStream is = stringView.getSofaDataStream();
      assertTrue(is != null);
      byte[] dest = new byte[1];
      StringBuffer buf = new StringBuffer();
      while (is.read(dest) != -1) {
        buf.append((char) dest[0]);
      }
      assertTrue(buf.toString().equals("this beer is good"));

      dest = new byte[4];
      // is = intarraySofaFS.getSofaDataStream();
      is.close();
      is = intArrayView.getSofaDataStream();
      assertTrue(is != null);
      int i = 0;
      while (is.read(dest) != -1) {
        assertTrue(ByteBuffer.wrap(dest).getInt() == intArrayFS.get(i++));
      }

      is.close();
      is = stringArrayView.getSofaDataStream();
      assertTrue(is != null);
      BufferedReader br = new BufferedReader(new InputStreamReader(is));
      i = 0;
      while (br.ready()) {
        assertTrue(stringArrayFS.get(i++).equals(br.readLine()));
      }

      // is = floatarraySofaFS.getSofaDataStream();
      is.close();
      is = floatArrayView.getSofaDataStream();
      assertTrue(is != null);
      i = 0;
      while (is.read(dest) != -1) {
        assertTrue(ByteBuffer.wrap(dest).getFloat() == floatArrayFS.get(i++));
      }

      dest = new byte[2];
      // is = shortarraySofaFS.getSofaDataStream();
      is.close();
      is = shortArrayView.getSofaDataStream();
      assertTrue(is != null);
      i = 0;
      while (is.read(dest) != -1) {
        assertTrue(ByteBuffer.wrap(dest).getShort() == shortArrayFS.get(i++));
      }

      dest = new byte[1];
      // is = bytearraySofaFS.getSofaDataStream();
      is.close();
      is = byteArrayView.getSofaDataStream();
      assertTrue(is != null);
      i = 0;
      while (is.read(dest) != -1) {
        assertTrue(ByteBuffer.wrap(dest).get() == byteArrayFS.get(i++));
      }

      dest = new byte[8];
      // is = longarraySofaFS.getSofaDataStream();
      is.close();
      is = longArrayView.getSofaDataStream();
      assertTrue(is != null);
      i = 0;
      while (is.read(dest) != -1) {
        assertTrue(ByteBuffer.wrap(dest).getLong() == longArrayFS.get(i++));
      }

      // is = doublearraySofaFS.getSofaDataStream();
      is.close();
      is = doubleArrayView.getSofaDataStream();
      assertTrue(is != null);
      i = 0;
      while (is.read(dest) != -1) {
        assertTrue(ByteBuffer.wrap(dest).getDouble() == doubleArrayFS.get(i++));
      }

      dest = new byte[1];
      is.close();
      // is = remoteSofa.getSofaDataStream();
View Full Code Here

Examples of org.apache.uima.cas.DoubleArrayFS

    loadCas(casSrc, mSrc);
    ReuseInfo[] ri = serializeDeserialize(casSrc, remoteCas, null, null);
    MarkerImpl marker = (MarkerImpl) remoteCas.createMarker();
    lfs = getIndexedFSs(remoteCas, m);
    FeatureStructure fs = lfs.get(10)/* has double array length 2 */
    DoubleArrayFS d = (DoubleArrayFS) maybeGetFeatureKind(fs, m, "Adouble");
    d.set(0, 12.34D);
    verifyDelta(marker, ri);
  }
View Full Code Here

Examples of org.apache.uima.cas.DoubleArrayFS

    fafs.set(5, Float.POSITIVE_INFINITY);
    maybeSetFeatureKind(fs, m, "Afloat", fafs);
  }

  private void createDoubleA (CASImpl cas, TTypeSystem m, FeatureStructure fs, double x) {
    DoubleArrayFS fafs = cas.createDoubleArrayFS(6);
    fafs.set(0, Double.MAX_VALUE - x);
//    fafs.set(1, Double.MIN_NORMAL + x);
    fafs.set(2, Double.MIN_VALUE + x);
    fafs.set(3, Double.NaN);
    fafs.set(4, Double.NEGATIVE_INFINITY);
    fafs.set(5, Double.POSITIVE_INFINITY);
    maybeSetFeatureKind(fs, m, "Adouble", fafs);
  }
View Full Code Here

Examples of org.apache.uima.cas.DoubleArrayFS

  private static final double[] doubleValues = {
    1d, 0d, -1d, Double.MAX_VALUE, /*Double.MIN_NORMAL,*/ Double.MIN_VALUE, 33d, -33.33d  };
 
  private DoubleArrayFS randomDoubleA(CASImpl cas) {
    int length = random.nextInt(2) + 1;
    DoubleArrayFS fs = cas.createDoubleArrayFS(length);
    for (int i = 0; i < length; i++) {
      fs.set(i, doubleValues[random.nextInt(doubleValues.length)]);
    }
    return fs;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.