public static <T extends FeatureStructure> T createFSList(CAS aCas, FeatureStructure... aValues) { return createFSList(aCas, asList(aValues)); }
public static FSList createFSList(JCas aJCas, Collection<? extends TOP> aCollection) { return createFSList(aJCas.getCas(), aCollection); }
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; }
public synchronized static AbstractQuery createAbstractQuery(JCas jcas, List<? extends QueryConcept> concepts) { AbstractQuery ret = new AbstractQuery(jcas); ret.setConcepts(FSCollectionFactory.createFSList(jcas, concepts)); return ret; }
public static void mergeConcept(JCas jcas, Concept dst, Concept src) { List<String> names = Stream.concat(getConceptNames(dst).stream(), getConceptNames(src).stream()) .filter(Objects::nonNull).distinct().collect(toList()); dst.setNames(FSCollectionFactory.createStringList(jcas, names)); List<String> ids = Stream.concat(getConceptIds(dst).stream(), getConceptIds(src).stream()) .filter(Objects::nonNull).distinct().collect(toList()); dst.setIds(FSCollectionFactory.createStringList(jcas, ids)); List<String> uris = Stream.concat(getConceptUris(dst).stream(), getConceptUris(src).stream()) .filter(Objects::nonNull).distinct().collect(toList()); dst.setUris(FSCollectionFactory.createStringList(jcas, uris)); List<ConceptType> types = Stream .concat(getConceptTypes(dst).stream(), getConceptTypes(src).stream()) .filter(Objects::nonNull).distinct().collect(toList()); dst.setTypes(FSCollectionFactory.createFSList(jcas, types)); List<ConceptMention> mentions = Stream .concat(getConceptMentions(dst).stream(), getConceptMentions(src).stream()) .filter(Objects::nonNull).distinct().collect(toList()); dst.setMentions(FSCollectionFactory.createFSList(jcas, mentions)); }
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; }
public synchronized static Answer createAnswer(JCas jcas, String text, double score, List<CandidateAnswerVariant> cavs) { Answer ret = new Answer(jcas); ret.setText(text); ret.setScore(score); ret.setVariants(FSCollectionFactory.createFSList(jcas, cavs)); return ret; }
sysChain.setMembers(FSCollectionFactory.createFSList(docCas, mappedElements)); sysChain.addToIndexes();
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; }
/** * All tags are treated equally as segment bounds, whether header or footer * * @param jcas - * @param listTypes segment names are assigned based upon preceding headers * @param text - * @param offset offset of the given text within the document */ static private void createLists( final JCas jcas, final Map<Pair<Integer>, ListType> listTypes, final String text, final int offset ) { if ( listTypes == null || listTypes.isEmpty() ) { return; } for ( Map.Entry<Pair<Integer>, ListType> boundedListType : listTypes.entrySet() ) { final Pair<Integer> listBounds = boundedListType.getKey(); final ListType listType = boundedListType.getValue(); final Collection<ListEntry> listEntries = findListEntries( jcas, listBounds, text.substring( listBounds.getValue1(), listBounds.getValue2() ), offset, listType.__entrySeparator ); final FSList fsList = FSCollectionFactory.createFSList( jcas, listEntries ); fsList.addToIndexes(); final org.apache.ctakes.typesystem.type.textspan.List list = new org.apache.ctakes.typesystem.type.textspan.List( jcas, offset + listBounds.getValue1(), offset + listBounds.getValue2() ); list.setId( listType.__name ); list.setItems( fsList ); list.addToIndexes(); } }
/** * All tags are treated equally as segment bounds, whether header or footer * * @param jcas - * @param listTypes segment names are assigned based upon preceding headers * @param text - * @param offset offset of the given text within the document */ static private void createLists( final JCas jcas, final Map<Pair<Integer>, ListType> listTypes, final String text, final int offset ) { if ( listTypes == null || listTypes.isEmpty() ) { return; } for ( Map.Entry<Pair<Integer>, ListType> boundedListType : listTypes.entrySet() ) { final Pair<Integer> listBounds = boundedListType.getKey(); final ListType listType = boundedListType.getValue(); final Collection<ListEntry> listEntries = findListEntries( jcas, listBounds, text.substring( listBounds.getValue1(), listBounds.getValue2() ), offset, listType.__entrySeparator ); final FSList fsList = FSCollectionFactory.createFSList( jcas, listEntries ); fsList.addToIndexes(); final org.apache.ctakes.typesystem.type.textspan.List list = new org.apache.ctakes.typesystem.type.textspan.List( jcas, offset + listBounds.getValue1(), offset + listBounds.getValue2() ); list.setId( listType.__name ); list.setItems( fsList ); list.addToIndexes(); } }
public synchronized static ComplexQueryConcept createComplexQueryConcept(JCas jcas, Collection<String> namedEntityTypes, TypeConstants.ConceptType conceptType, QueryOperator operator, List<? extends QueryConcept> operatorArgs) { ComplexQueryConcept ret = new ComplexQueryConcept(jcas); ret.setNamedEntityTypes(FSCollectionFactory.createStringList(jcas, namedEntityTypes)); ret.setConceptType(conceptType.name()); ret.setOperator(operator); ret.setOperatorArgs(FSCollectionFactory.createFSList(jcas, operatorArgs)); return ret; }
FSList newMembers = FSCollectionFactory.createFSList(chainCas, ptMarkableList); newMembers.addToIndexes(); CollectionTextRelation ptChain = new CollectionTextRelation(chainCas);
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]); } }
break; default: aFS.setFeatureValue(feat, createFSList(aFS.getCAS(), aValue)); break;