/** * Convert an {@link ArrayFS} to a {@link Collection}. * * @param aArray * the array to convert. * @return a new collection containing the same feature structures as the provided array. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static Collection<FeatureStructure> create(ArrayFS aArray) { return create(aArray, (Type) null); }
public static BooleanArrayFS createBooleanArray(CAS aCas, Collection<Boolean> aCollection) { return fillArrayFS(aCas.createBooleanArrayFS(aCollection.size()), aCollection); }
public synchronized static Concept createConcept(JCas jcas, List<String> names, List<String> uris, List<String> ids, List<ConceptMention> mentions, List<ConceptType> types) { Concept ret = new Concept(jcas); ret.setNames(FSCollectionFactory.createStringList(jcas, names)); ret.setUris(FSCollectionFactory.createStringList(jcas, uris)); ret.setIds(FSCollectionFactory.createStringList(jcas, ids)); ret.setMentions(FSCollectionFactory.createFSList(jcas, mentions)); mentions.stream().forEach(mention -> mention.setConcept(ret)); ret.setTypes(FSCollectionFactory.createFSList(jcas, types)); return ret; }
final FSArray childArray = FSCollectionFactory.createFSArray(aJCas, splitChildren); if (parentSplit == null) { compound.setSplits(childArray);
switch (feat.getRange().getName()) { case CAS.TYPE_NAME_BOOLEAN_ARRAY: aFS.setFeatureValue(feat, createBooleanArray(aFS.getCAS(), aValue)); break; case CAS.TYPE_NAME_BYTE_ARRAY: aFS.setFeatureValue(feat, createByteArray(aFS.getCAS(), aValue)); break; case CAS.TYPE_NAME_DOUBLE_ARRAY: aFS.setFeatureValue(feat, createDoubleArray(aFS.getCAS(), aValue)); break; case CAS.TYPE_NAME_FLOAT_ARRAY: aFS.setFeatureValue(feat, createFloatArray(aFS.getCAS(), aValue)); break; case CAS.TYPE_NAME_INTEGER_ARRAY: aFS.setFeatureValue(feat, createIntArray(aFS.getCAS(), aValue)); break; case CAS.TYPE_NAME_LONG_ARRAY: aFS.setFeatureValue(feat, createLongArray(aFS.getCAS(), aValue)); break; case CAS.TYPE_NAME_SHORT_ARRAY: aFS.setFeatureValue(feat, createShortArray(aFS.getCAS(), aValue)); break; case CAS.TYPE_NAME_STRING_ARRAY: aFS.setFeatureValue(feat, createStringArray(aFS.getCAS(), aValue)); break; default: aFS.setFeatureValue(feat, createArrayFS(aFS.getCAS(), aValue)); break;
public synchronized static Document createDocument(JCas jcas, String uri, double score, String text, int rank, String queryString, String searchId, Collection<CandidateAnswerVariant> candidateAnswers, String title, String docId, List<String> sections, List<String> sectionLabels) { Document ret = new Document(jcas); ret.setUri(uri); ret.setScore(score); ret.setText(text); ret.setRank(rank); ret.setQueryString(queryString); ret.setSearchId(searchId); ret.setCandidateAnswers(FSCollectionFactory.createFSArray(jcas, candidateAnswers)); ret.setTitle(title); ret.setDocId(docId); ret.setSections((StringArray) FSCollectionFactory.createStringArray(jcas, sections)); ret.setSectionLabels((StringArray) FSCollectionFactory.createStringArray(jcas, sectionLabels)); return ret; }
IStringListExpression stringListExpr = (IStringListExpression) value; List<String> stringList = stringListExpr.getStringList(context, this); StringArrayFS stringArray = FSCollectionFactory.createStringArray(cas, stringList); annotation.setFeatureValue(feature, stringArray); } else if (value instanceof IStringExpression) { IStringExpression stringExpr = (IStringExpression) value; String string = stringExpr.getStringValue(context, this); StringArrayFS array = FSCollectionFactory.createStringArray(cas, new String[] { string }); annotation.setFeatureValue(feature, array); INumberExpression numberExpr = (INumberExpression) value; int v = numberExpr.getIntegerValue(context, this); IntArrayFS array = FSCollectionFactory.createIntArray(cas, new int[] { v }); annotation.setFeatureValue(feature, array); } else if (value instanceof INumberListExpression) { INumberListExpression expr = (INumberListExpression) value; List<Number> list = expr.getNumberList(context, this); IntArrayFS array = FSCollectionFactory.createIntArray(cas, RutaListUtils.toIntArray(list)); annotation.setFeatureValue(feature, array); INumberExpression numberExpr = (INumberExpression) value; double v = numberExpr.getDoubleValue(context, this); DoubleArrayFS array = FSCollectionFactory.createDoubleArray(cas, new double[] { v }); annotation.setFeatureValue(feature, array); } else if (value instanceof INumberListExpression) { INumberListExpression expr = (INumberListExpression) value; List<Number> list = expr.getNumberList(context, this); DoubleArrayFS array = FSCollectionFactory.createDoubleArray(cas, RutaListUtils.toDoubleArray(list));
public static <T extends FeatureStructure> T createFSList(CAS aCas, FeatureStructure... aValues) { return createFSList(aCas, asList(aValues)); }
public static void setFeature(FeatureStructure aFS, String aFeature, String... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isPrimitive()) { requireSingleValue(feat, aValue); aFS.setStringValue(feat, aValue[0]); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else if (feat.getRange().isArray()) { aFS.setFeatureValue(feat, createStringArray(aFS.getCAS(), aValue)); } else { aFS.setFeatureValue(feat, createStringList(aFS.getCAS(), aValue)); } }
public static void setFeature(FeatureStructure aFS, String aFeature, FeatureStructure... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isArray()) { aFS.setFeatureValue(feat, createArrayFS(aFS.getCAS(), aValue)); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else if (isListType(aFS.getCAS().getTypeSystem(), feat.getRange())) { aFS.setFeatureValue(feat, createFSList(aFS.getCAS(), aValue)); } else { requireSingleValue(feat, aValue); aFS.setFeatureValue(feat, aValue[0]); } }
public static void setFeature(FeatureStructure aFS, String aFeature, boolean... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isPrimitive()) { requireSingleValue(feat, aValue); aFS.setBooleanValue(feat, aValue[0]); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else { aFS.setFeatureValue(feat, createBooleanArray(aFS.getCAS(), aValue)); } }
public synchronized static Search createSearch(JCas jcas, String query, List<SearchResult> hitList, AbstractQuery abstractQuery, String searchId) { Search ret = new Search(jcas); ret.setQuery(query); ret.setHitList(FSCollectionFactory.createFSArray(jcas, hitList)); ret.setAbstractQuery(abstractQuery); ret.setSearchId(searchId); return ret; }
public static FSList createFSList(JCas aJCas, Collection<? extends TOP> aCollection) { return createFSList(aJCas.getCas(), aCollection); }
parent.children.add(wrapper.constituent); wrapper.constituent.setChildren(FSCollectionFactory.createFSArray(getJCas(), wrapper.children)); wrapper.constituent.addToIndexes(); ConstituentWrapper rootWrapper = constituents.pop(); rootWrapper.constituent.setEnd(getBuffer().length()); rootWrapper.constituent.setChildren(FSCollectionFactory.createFSArray( getJCas(), rootWrapper.children)); rootWrapper.constituent.addToIndexes();
/** * Convenience method to iterator over all feature structures of a given type. * * @param array * features structure array. * @param type * the type. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static Collection<FeatureStructure> selectFS(ArrayFS array, Type type) { return FSCollectionFactory.create(array, type); }
public static ByteArrayFS createByteArray(CAS aCas, Collection<Byte> aCollection) { return fillArrayFS(aCas.createByteArrayFS(aCollection.size()), aCollection); }
public synchronized static CandidateAnswerVariant createCandidateAnswerVariant(JCas jcas, List<CandidateAnswerOccurrence> caos, List<String> names, String docId) { CandidateAnswerVariant ret = new CandidateAnswerVariant(jcas); ret.setOccurrences(FSCollectionFactory.createFSList(jcas, caos)); ret.setNames(FSCollectionFactory.createStringList(jcas, names)); ret.setDocId(docId); return ret; }
public synchronized static Answer createAnswer(JCas jcas, double score, List<CandidateAnswerVariant> cavs) { Answer ret = new Answer(jcas); Optional<String> name = cavs.stream().map(TypeUtil::getCandidateAnswerVariantNames) .flatMap(Collection::stream).findFirst(); if (name.isPresent()) { ret.setText(name.get()); } ret.setScore(score); ret.setVariants(FSCollectionFactory.createFSList(jcas, cavs)); return ret; }
e.getKey().setArguments(FSCollectionFactory.createFSArray(aJCas, e.getValue()));
/** * Convenience method to iterator over all feature structures of a given type. * * @param cas * the CAS containing the type system. * @param type * the type. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static Collection<FeatureStructure> selectFS(final CAS cas, final Type type) { return FSCollectionFactory.create(cas, type); }