org.apache.uima.jcas.cas.DoubleArray Java Examples
The following examples show how to use
org.apache.uima.jcas.cas.DoubleArray.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CASImpl.java From uima-uimaj with Apache License 2.0 | 6 votes |
public TOP createArray(TypeImpl array_type, int arrayLength) { TypeImpl_array tia = (TypeImpl_array) array_type; TypeImpl componentType = tia.getComponentType(); if (componentType.isPrimitive()) { checkArrayPreconditions(arrayLength); switch (componentType.getCode()) { case intTypeCode: return new IntegerArray(array_type, this, arrayLength); case floatTypeCode: return new FloatArray(array_type, this, arrayLength); case booleanTypeCode: return new BooleanArray(array_type, this, arrayLength); case byteTypeCode: return new ByteArray(array_type, this, arrayLength); case shortTypeCode: return new ShortArray(array_type, this, arrayLength); case longTypeCode: return new LongArray(array_type, this, arrayLength); case doubleTypeCode: return new DoubleArray(array_type, this, arrayLength); case stringTypeCode: return new StringArray(array_type, this, arrayLength); default: throw Misc.internalError(); } } // return (TOP) createArrayFS(/* array_type, */ arrayLength); // for backwards compat w/ v2, don't create typed arrays if (IS_DISABLE_SUBTYPE_FSARRAY_CREATION) { return (TOP) createArrayFS(arrayLength); } else { return (TOP) createArrayFS(array_type, arrayLength); } }
Example #2
Source File: NewFeatureUtils.java From baleen with Apache License 2.0 | 5 votes |
private static DoubleArray getDoubleArray(JCas jCas, Collection<?> list) { final DoubleArray a = new DoubleArray(jCas, list.size()); int i = 0; for (final Object s : list) { a.set(i++, ((Number) s).doubleValue()); } return a; }
Example #3
Source File: CASImpl.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override public DoubleArray emptyDoubleArray() { if (null == svd.emptyDoubleArray) { svd.emptyDoubleArray = new DoubleArray(this.getJCas(), 0); } return svd.emptyDoubleArray; }
Example #4
Source File: FeatureStructureImplC.java From uima-uimaj with Apache License 2.0 | 5 votes |
private boolean isOkArray(TypeImpl range, Object v) { if (v == null) { return true; } final int rangeTypeCode = range.getCode(); /* The assignment is stricter than the Java rules - must match */ switch (rangeTypeCode) { case TypeSystemConstants.booleanArrayTypeCode: return v instanceof BooleanArray; case TypeSystemConstants.byteArrayTypeCode: return v instanceof ByteArray; case TypeSystemConstants.shortArrayTypeCode: return v instanceof ShortArray; case TypeSystemConstants.intArrayTypeCode: return v instanceof IntegerArray; case TypeSystemConstants.floatArrayTypeCode: return v instanceof FloatArray; case TypeSystemConstants.longArrayTypeCode: return v instanceof LongArray; case TypeSystemConstants.doubleArrayTypeCode: return v instanceof DoubleArray; case TypeSystemConstants.stringArrayTypeCode: return v instanceof StringArray; // case TypeSystemConstants.javaObjectArrayTypeCode: // return v instanceof JavaObjectArray; case TypeSystemConstants.fsArrayTypeCode: return v instanceof FSArray; } // it is possible that the array has a special type code corresponding to a type "someUserType"[] // meaning an array of some user type. UIMA implements these as instances of FSArray (I think) if (!(v instanceof FSArray)) { return false; } return true; }
Example #5
Source File: TopicDistribution.java From bluima with Apache License 2.0 | 4 votes |
/** getter for probability - gets * @generated * @return value of the feature */ public DoubleArray getProbability() { if (TopicDistribution_Type.featOkTst && ((TopicDistribution_Type)jcasType).casFeat_probability == null) jcasType.jcas.throwFeatMissing("probability", "ch.epfl.bbp.uima.types.TopicDistribution"); return (DoubleArray)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((TopicDistribution_Type)jcasType).casFeatCode_probability)));}
Example #6
Source File: CasComparer.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * * @param fs1 * @param fs2 * @param visited when called for sorting FSs, is sortCompareSeen(cleared); * when called for comparing for equality, holds FSs already compared in other views * @return */ private int compare1(TOP fs1, TOP fs2, Set<TOP> visited) { if (!isSortUse) { // only do null check for non- sort use if (fs1 == null && fs2 == null) { return 0; } if (fs1 == null) return chkEqual(-1, "fs1 was null and fs2 was not"); if (fs2 == null) return chkEqual(1, "fs2 was null and fs1 was not"); } boolean wasPresent1 = !visited.add(fs1); boolean wasPresent2 = !visited.add(fs2); if (wasPresent1 && wasPresent2) { return 0; // already checked and found equal } if (!wasPresent1 && !wasPresent2) { int r; TypeImpl t1, t2; if (0 != (r = compStr((t1 = (TypeImpl) fs1.getType()).getName(), (t2 = (TypeImpl) fs2.getType()).getName()))) { return chkEqual(r, "Types of FSs are different: Type1 = %s, Type2 = %s", t1, t2); } // types are the same if (CAS.TYPE_NAME_SOFA.equals(t1.getName())) { if (isSortUse) { return Integer.compare(((Sofa)fs1).getSofaNum(), ((Sofa)fs2).getSofaNum()); } return 0; // skip comparing sofa so this routine can be used for cas copier testing } if (t1.isArray()) { final int len1 = ((CommonArrayFS)fs1).size(); if (0 != (r = Integer.compare(len1, ((CommonArrayFS)fs2).size()))) { return r; } SlotKind kind = t1.getComponentSlotKind(); switch(kind) { case Slot_BooleanRef: return compareAllArrayElements(len1, i -> Boolean.compare(((BooleanArray )fs1).get(i), ((BooleanArray)fs2).get(i)), "Miscompare Boolean Arrays %n%s%n%s", fs1, fs2); case Slot_ByteRef: return compareAllArrayElements(len1, i -> Byte .compare(((ByteArray )fs1).get(i), ((ByteArray )fs2).get(i)), "Miscompare Byte Arrays %n%s%n%s" , fs1, fs2); case Slot_ShortRef: return compareAllArrayElements(len1, i -> Short .compare(((ShortArray )fs1).get(i), ((ShortArray )fs2).get(i)), "Miscompare Short Arrays %n%s%n%s" , fs1, fs2); case Slot_Int: return compareAllArrayElements (len1, i -> Integer.compare(((IntegerArray )fs1).get(i), ((IntegerArray)fs2).get(i)), "Miscompare Integer Arrays %n%s%n%s", fs1, fs2); case Slot_LongRef: return compareAllArrayElements(len1, i -> Long .compare(((LongArray )fs1).get(i), ((LongArray )fs2).get(i)), "Miscompare Long Arrays %n%s%n%s", fs1, fs2); case Slot_Float: return compareAllArrayElements (len1, i -> Integer.compare(Float.floatToRawIntBits (((FloatArray )fs1).get(i)), Float.floatToRawIntBits (((FloatArray )fs2).get(i))), "Miscompare Float Arrays %n%s%n%s", fs1, fs2); case Slot_DoubleRef: return compareAllArrayElements(len1, i -> Long .compare(Double.doubleToRawLongBits(((DoubleArray)fs1).get(i)), Double.doubleToRawLongBits(((DoubleArray)fs2).get(i))), "Miscompare Double Arrays %n%s%n%s", fs1, fs2); case Slot_HeapRef: return compareAllArrayElements(len1, i -> compare1((TOP)((FSArray<?> )fs1).get(i), (TOP)((FSArray<?> )fs2).get(i), visited), "Miscompare FS Arrays %n%s%n%s", fs1, fs2); case Slot_StrRef: return compareAllArrayElements(len1, i -> Misc.compareStrings(((StringArray )fs1).get(i), ((StringArray )fs2).get(i)), "Miscompare String Arrays %n%s%n%s", fs1, fs2); default: Misc.internalError(); return 0; // only to avoid a compile error } } ts = fs1.getCAS().getTypeSystem(); return compareFeatures(fs1, fs2, t1.getFeatureImpls(), t2.getFeatureImpls(), visited); } // getting here: one was already traversed, the other not. Possible use case: // fs1 is a list with a loop; fs2 is a list without a loop // arbitrarily return the one with a loop first if (fs1 instanceof EmptyList) { return 0; // allow different or shared EmptyList instances to compare equal // because some deserializers or user code can create them as shared or not } if (wasPresent1) { return chkEqual(-1, "First element had a ref loop %s%n, second didn't so far %s", fs1, fs2); } return chkEqual(-1, "Second element had a ref loop %s%n, first didn't so far %s", fs2, fs1); }
Example #7
Source File: CAS.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * @return a lazily created shared (for this CAS) 0-length array */ default DoubleArray emptyDoubleArray() { return ((CASImpl)getLowLevelCAS()).emptyDoubleArray(); }
Example #8
Source File: CASImpl.java From uima-uimaj with Apache License 2.0 | 4 votes |
@Override public void ll_setDoubleArrayValue(int fsRef, int position, double d) { ((DoubleArray) getFsFromId_checked(fsRef)).set(position, d); }
Example #9
Source File: CASImpl.java From uima-uimaj with Apache License 2.0 | 4 votes |
@Override public double ll_getDoubleArrayValue(int fsRef, int position) { return ((DoubleArray) getFsFromId_checked(fsRef)).get(position); }
Example #10
Source File: CASImpl.java From uima-uimaj with Apache License 2.0 | 4 votes |
@Override public DoubleArrayFS createDoubleArrayFS(int length) throws CASRuntimeException { checkArrayPreconditions(length); return new DoubleArray(this.getJCas(), length); }
Example #11
Source File: FSCollectionFactory.java From uima-uimafit with Apache License 2.0 | 4 votes |
public static DoubleArray fillArray(DoubleArray aArray, double... aValues) { return (DoubleArray) fillArrayFS(aArray, aValues); }
Example #12
Source File: FSCollectionFactory.java From uima-uimafit with Apache License 2.0 | 4 votes |
public static DoubleArray fillArray(DoubleArray aArray, Iterable<Double> aValues) { return (DoubleArray) fillArrayFS(aArray, aValues); }
Example #13
Source File: FSCollectionFactory.java From uima-uimafit with Apache License 2.0 | 4 votes |
public static DoubleArray createDoubleArray(JCas aJCas, double... aArray) { return fillArray(new DoubleArray(aJCas, aArray.length), aArray); }
Example #14
Source File: FSCollectionFactory.java From uima-uimafit with Apache License 2.0 | 4 votes |
public static DoubleArray createDoubleArray(JCas aJCas, Collection<Double> aCollection) { return fillArray(new DoubleArray(aJCas, aCollection.size()), aCollection); }
Example #15
Source File: Topic.java From bluima with Apache License 2.0 | 4 votes |
/** setter for scores - sets * @generated * @param v value to set into the feature */ public void setScores(DoubleArray v) { if (Topic_Type.featOkTst && ((Topic_Type)jcasType).casFeat_scores == null) jcasType.jcas.throwFeatMissing("scores", "ch.epfl.bbp.uima.types.Topic"); jcasType.ll_cas.ll_setRefValue(addr, ((Topic_Type)jcasType).casFeatCode_scores, jcasType.ll_cas.ll_getFSRef(v));}
Example #16
Source File: Topic.java From bluima with Apache License 2.0 | 4 votes |
/** getter for scores - gets * @generated * @return value of the feature */ public DoubleArray getScores() { if (Topic_Type.featOkTst && ((Topic_Type)jcasType).casFeat_scores == null) jcasType.jcas.throwFeatMissing("scores", "ch.epfl.bbp.uima.types.Topic"); return (DoubleArray)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((Topic_Type)jcasType).casFeatCode_scores)));}
Example #17
Source File: TopicDistribution.java From bluima with Apache License 2.0 | 4 votes |
/** setter for probability - sets * @generated * @param v value to set into the feature */ public void setProbability(DoubleArray v) { if (TopicDistribution_Type.featOkTst && ((TopicDistribution_Type)jcasType).casFeat_probability == null) jcasType.jcas.throwFeatMissing("probability", "ch.epfl.bbp.uima.types.TopicDistribution"); jcasType.ll_cas.ll_setRefValue(addr, ((TopicDistribution_Type)jcasType).casFeatCode_probability, jcasType.ll_cas.ll_getFSRef(v));}
Example #18
Source File: JCas.java From uima-uimaj with Apache License 2.0 | 2 votes |
/** * Retrieve a lazily-created constant from the cas which holds a 0-length instance. * Since this can be a common value, we * avoid creating multiple copies of it. All uses can use the same value because it is not * updatable (it has no subfields). This is initialized lazily on first reference, and reset when * the CAS is reset. * @return 0-length instance of a DoubleArray */ default DoubleArray emptyDoubleArray() { return this.getCas().emptyDoubleArray(); }
Example #19
Source File: Root.java From uima-uimaj with Apache License 2.0 | 2 votes |
/** getter for arrayDouble - gets * @generated * @return value of the feature */ public DoubleArray getArrayDouble() { return (DoubleArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayDouble)));}
Example #20
Source File: Root.java From uima-uimaj with Apache License 2.0 | 2 votes |
/** setter for arrayDouble - sets * @generated * @param v value to set into the feature */ public void setArrayDouble(DoubleArray v) { _setFeatureValueNcWj(wrapGetIntCatchException(_FH_arrayDouble), v); }
Example #21
Source File: Root.java From uima-uimaj with Apache License 2.0 | 2 votes |
/** indexed getter for arrayDouble - gets an indexed value - * @generated * @param i index in the array to get * @return value of the element at index i */ public double getArrayDouble(int i) { return ((DoubleArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayDouble)))).get(i);}
Example #22
Source File: Root.java From uima-uimaj with Apache License 2.0 | 2 votes |
/** indexed setter for arrayDouble - sets an indexed value - * @generated * @param i index in the array to set * @param v value to set into the array */ public void setArrayDouble(int i, double v) { ((DoubleArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayDouble)))).set(i, v); }