本文整理汇总了Java中org.apache.uima.jcas.cas.FSArray.set方法的典型用法代码示例。如果您正苦于以下问题:Java FSArray.set方法的具体用法?Java FSArray.set怎么用?Java FSArray.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.jcas.cas.FSArray
的用法示例。
在下文中一共展示了FSArray.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readCast
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
private static void readCast(JCas jcas, Drama drama, Document doc) {
Map<String, CastFigure> idFigureMap = new HashMap<String, CastFigure>();
Elements castEntries = doc.select("castList > castItem > role");
// castEntries.addAll(doc.select("profileDesc > particDesc > listPerson
// > personGrp"));
FSArray castListArray = new FSArray(jcas, castEntries.size());
for (int i = 0; i < castEntries.size(); i++) {
Element castEntry = castEntries.get(i);
String id = castEntry.attr("xml:id");
StringArray arr = new StringArray(jcas, 1);
arr.set(0, castEntry.text());
CastFigure figure = new CastFigure(jcas);
figure.setXmlId(id);
figure.setNames(arr);
idFigureMap.put(id, figure);
castListArray.set(i, figure);
}
drama.setCastList(castListArray);
for (Speaker speaker : JCasUtil.select(jcas, Speaker.class)) {
speaker.setCastFigure(new FSArray(jcas, speaker.getXmlId().size()));
for (int i = 0; i < speaker.getXmlId().size(); i++)
speaker.setCastFigure(i, idFigureMap.get(speaker.getXmlId(i)));
}
}
示例2: removeSlotMentions
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static void removeSlotMentions(CCPClassMention ccpCM, Class slotType, JCas jcas) {
List<CCPSlotMention> slotMentionsToKeep = new ArrayList<CCPSlotMention>();
FSArray slotMentions = ccpCM.getSlotMentions();
if (slotMentions != null) {
for (int i = 0; i < slotMentions.size(); i++) {
if (!(slotType.isInstance(slotMentions.get(i)))) {
slotMentionsToKeep.add((CCPSlotMention) slotMentions.get(i));
}
}
}
FSArray updatedSlotMentions = new FSArray(jcas, slotMentionsToKeep.size());
for (int i = 0; i < slotMentionsToKeep.size(); i++) {
updatedSlotMentions.set(i, slotMentionsToKeep.get(i));
}
ccpCM.setSlotMentions(updatedSlotMentions);
}
示例3: readCast
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static void readCast(JCas jcas, Drama drama, Document doc) {
Map<String, CastFigure> idFigureMap = new HashMap<String, CastFigure>();
Elements castEntries = doc.select("profileDesc > particDesc > listPerson > person");
// castEntries.addAll(doc.select("profileDesc > particDesc > listPerson
// > personGrp"));
FSArray castListArray = new FSArray(jcas, castEntries.size());
for (int i = 0; i < castEntries.size(); i++) {
Element castEntry = castEntries.get(i);
String id = castEntry.attr("xml:id");
StringArray arr = new StringArray(jcas, 1);
arr.set(0, castEntry.text());
CastFigure figure = new CastFigure(jcas);
figure.setXmlId(id);
figure.setNames(arr);
idFigureMap.put(id, figure);
castListArray.set(i, figure);
}
drama.setCastList(castListArray);
for (Speaker speaker : JCasUtil.select(jcas, Speaker.class)) {
speaker.setCastFigure(new FSArray(jcas, speaker.getXmlId().size()));
for (int i = 0; i < speaker.getXmlId().size(); i++)
speaker.setCastFigure(i, idFigureMap.get(speaker.getXmlId(i)));
}
}
示例4: createCCPTextAnnotation
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static CCPTextAnnotation createCCPTextAnnotation(String mentionType, int[] span, JCas jcas,
CCPAnnotator annotatorInfo, CCPAnnotationSet annotationSetInfo) {
CCPTextAnnotation ccpTA = new CCPTextAnnotation(jcas);
int startIndex = span[0];
int endIndex = span[1];
ccpTA.setBegin(startIndex);
ccpTA.setEnd(endIndex);
/* create span */
FSArray ccpSpans = new FSArray(jcas, 1);
CCPSpan ccpSpan = new CCPSpan(jcas);
ccpSpan.setSpanStart(startIndex);
ccpSpan.setSpanEnd(endIndex);
ccpSpans.set(0, ccpSpan);
ccpTA.setSpans(ccpSpans);
ccpTA.setAnnotator(annotatorInfo);
FSArray asets = new FSArray(jcas, 1);
asets.set(0, annotationSetInfo);
ccpTA.setAnnotationSets(asets);
ccpTA.setDocumentSectionID(-1);
CCPClassMention ccpCM = new CCPClassMention(jcas);
ccpCM.setMentionName(mentionType);
ccpTA.setClassMention(ccpCM);
ccpCM.setCcpTextAnnotation(ccpTA);
ccpTA.addToIndexes();
return ccpTA;
}
示例5: outputPattern
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
* Output pattern (save to the jCas)
*
* @param jCas
* the j cas
* @param pattern
* the pattern
*/
private void outputPattern(final JCas jCas, final PatternExtract pattern) {
final Pattern a = new Pattern(jCas);
a.setBegin(pattern.getStart());
a.setEnd(pattern.getEnd());
a.setSource(pattern.getFrom());
a.setTarget(pattern.getTo());
final List<WordToken> tokens = pattern.getWordTokens();
final FSArray array = new FSArray(jCas, tokens.size());
int i = 0;
for (final WordToken w : tokens) {
array.set(i, w);
i++;
}
a.setWords(array);
addToJCasIndex(a);
}
示例6: testToList
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
@Test
public void testToList() {
assertTrue(UimaTypesUtils.toList((StringArray)null).isEmpty());
assertTrue(UimaTypesUtils.toList((FSArray)null).isEmpty());
// Empty list
FSArray array = new FSArray(jCas, 2);
assertEquals(2, UimaTypesUtils.toList(array).size());
// Populate
array.set(0, new Entity(jCas));
array.set(1, new Entity(jCas));
List<Entity> list = UimaTypesUtils.toList(array);
assertEquals(2, list.size());
assertSame(array.get(0), list.get(0));
assertSame(array.get(0), list.get(0));
}
示例7: fillWords
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
private static void fillWords(TermOccAnnotation toa, CAS cas) throws CASException, IOException {
FSArray fs = (FSArray) cas.createArrayFS(toa.getPattern().size());
int i = 0;
int begin = -1;
int end = -1;
while(i != toa.getPattern().size()){
if (begin != -1 && token == JsonToken.VALUE_NUMBER_INT){
end = parser.getValueAsInt();
}
else if (token == JsonToken.VALUE_NUMBER_INT){
begin = parser.getValueAsInt();
}
else if (end != -1){
List<WordAnnotation> wa = JCasUtil.selectCovered(cas.getJCas(),WordAnnotation.class,begin,end);
fs.set(i,wa.get(0));
begin = -1;
end = -1;
i++;
}
token = parser.nextToken();
}
toa.setWords(fs);
}
示例8: readCast
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
private static void readCast(JCas jcas, Drama drama, Document doc) {
Map<String, CastFigure> idFigureMap = new HashMap<String, CastFigure>();
Elements castEntries = doc.select("profileDesc > particDesc > listPerson > person");
castEntries.addAll(doc.select("profileDesc > particDesc > listPerson > personGrp"));
FSArray castListArray = new FSArray(jcas, castEntries.size());
for (int i = 0; i < castEntries.size(); i++) {
Element castEntry = castEntries.get(i);
String id = castEntry.attr("xml:id");
Elements nameElements = castEntry.select("persName");
StringArray arr = new StringArray(jcas, nameElements.size());
for (int j = 0; j < nameElements.size(); j++) {
arr.set(j, nameElements.get(j).text());
}
CastFigure figure = new CastFigure(jcas);
figure.setXmlId(id);
figure.setNames(arr);
idFigureMap.put(id, figure);
castListArray.set(i, figure);
}
drama.setCastList(castListArray);
for (Speaker speaker : JCasUtil.select(jcas, Speaker.class)) {
speaker.setCastFigure(new FSArray(jcas, speaker.getXmlId().size()));
for (int i = 0; i < speaker.getXmlId().size(); i++)
speaker.setCastFigure(i, idFigureMap.get(speaker.getXmlId(i)));
}
}
示例9: process
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
* cycle through all annotations and set the annotation set
*/
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
/* create an annotation set list */
CCPAnnotationSet ccpAnnotationSet = new CCPAnnotationSet(jcas);
ccpAnnotationSet.setAnnotationSetID(setID);
ccpAnnotationSet.setAnnotationSetName(setName);
ccpAnnotationSet.setAnnotationSetDescription(setDescription);
FSArray annotationSets = new FSArray(jcas, 1);
annotationSets.set(0, ccpAnnotationSet);
FSIterator annotIter = jcas.getJFSIndexRepository().getAnnotationIndex(CCPTextAnnotation.type).iterator();
while (annotIter.hasNext()) {
Object possibleAnnot = annotIter.next();
if (possibleAnnot instanceof CCPTextAnnotation) {
CCPTextAnnotation ccpTA = (CCPTextAnnotation) possibleAnnot;
boolean ignore = checkForIgnoreBasedOnAnnotationSet(ccpTA);
if (!ignore) {
ccpTA.setAnnotationSets(annotationSets);
}
} else {
System.err.println("WARNING -- AnnotationSetValidator_AE: CCPTextAnnotation expected but instead got "
+ possibleAnnot.getClass().getName());
}
}
}
示例10: overwriteSlotValues
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public void overwriteSlotValues(ClassMention slotValue) throws InvalidInputException {
Object wrappedClassMention = slotValue.getWrappedObject();
if (wrappedClassMention instanceof CCPClassMention) {
CCPClassMention ccpCM = (CCPClassMention) wrappedClassMention;
FSArray updatedClassMentions = new FSArray(jcas, 1);
updatedClassMentions.set(0, ccpCM);
wrappedCSM.setClassMentions(updatedClassMentions);
} else {
throw new InvalidInputException("Expected CCPClassMention. Cannot add class"
+ wrappedClassMention.getClass().getName()
+ " to the ClassMentions list of a CCPComplexSlotMention");
}
}
示例11: swapClassMentionInfo
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static void swapClassMentionInfo(CCPClassMention fromCM, CCPClassMention toCM) throws CASException {
toCM.setMentionName(fromCM.getMentionName());
JCas jcas = fromCM.getCAS().getJCas();
FSArray fromSlotMentions = fromCM.getSlotMentions();
if (fromSlotMentions != null) {
FSArray toSlotMentions = new FSArray(jcas, fromSlotMentions.size());
for (int i = 0; i < fromSlotMentions.size(); i++) {
if (fromSlotMentions.get(i) instanceof CCPPrimitiveSlotMention) {
toSlotMentions.set(i,
copyCCPPrimitiveSlotMention((CCPPrimitiveSlotMention) fromSlotMentions.get(i)));
} else if (fromSlotMentions.get(i) instanceof CCPComplexSlotMention) {
CCPComplexSlotMention toSM = new CCPComplexSlotMention(jcas);
UIMA_Util.swapComplexSlotMentionInfo((CCPComplexSlotMention) fromSlotMentions.get(i), toSM);
toSlotMentions.set(i, toSM);
} else {
System.err.println("Expecting CCPNonComplexSlotMention of CCPComplexSlotMention but got: "
+ fromSlotMentions.get(i).getClass().getName());
}
}
toCM.setSlotMentions(toSlotMentions);
}
CCPTextAnnotation fromTextAnnotation = fromCM.getCcpTextAnnotation();
if (fromTextAnnotation != null) {
toCM.setCcpTextAnnotation(fromTextAnnotation);
}
}
示例12: swapComplexSlotMentionInfo
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
public static void swapComplexSlotMentionInfo(CCPComplexSlotMention fromSM, CCPComplexSlotMention toSM)
throws CASException {
toSM.setMentionName(fromSM.getMentionName());
JCas jcas = fromSM.getCAS().getJCas();
FSArray fromClassMentions = fromSM.getClassMentions();
if (fromClassMentions != null) {
FSArray toClassMentions = new FSArray(jcas, fromClassMentions.size());
for (int i = 0; i < fromClassMentions.size(); i++) {
CCPClassMention toCM = new CCPClassMention(jcas);
UIMA_Util.swapClassMentionInfo((CCPClassMention) fromClassMentions.get(i), toCM);
toClassMentions.set(i, toCM);
}
toSM.setClassMentions(toClassMentions);
}
}
示例13: processComplexSlotMention
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
private CCPComplexSlotMention processComplexSlotMention(ComplexSlotMention complexSlotMention, JCas jcas,
HashMap<String, String> alreadyCreatedAnnotations, HashMap<String, CCPClassMention> alreadyCreatedMentions) {
// create a new Knowtator mention
CCPComplexSlotMention ccpComplexSlotMention = new CCPComplexSlotMention(jcas);
ccpComplexSlotMention.setMentionName(complexSlotMention.getMentionName());
// for each of its classMentions, create a new Knowtator mention
Collection<ClassMention> classMentions = complexSlotMention.getClassMentions();
if (classMentions.size() == 0) {
return null;
}
FSArray classMentionFSArray = new FSArray(jcas, classMentions.size());
int fsArrayIndex = 0;
for (ClassMention cm : classMentions) {
CCPClassMention ccpClassMention = (CCPClassMention) createUIMAMention(cm, jcas, alreadyCreatedAnnotations,
alreadyCreatedMentions);
classMentionFSArray.set(fsArrayIndex++, ccpClassMention);
}
// add slot mentions array to classmention
ccpComplexSlotMention.setClassMentions(classMentionFSArray);
return ccpComplexSlotMention;
}
示例14: listToFsarray
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
* Converts a list of FeatureStructure objects into an FSArray
*
* @param list
* @param jcas
* @return
*/
public static FSArray listToFsarray(List<FeatureStructure> list, JCas jcas) {
FSArray fsarray = new FSArray(jcas, list.size());
for (int i = 0; i < list.size(); i++) {
fsarray.set(i, list.get(i));
}
return fsarray;
}
示例15: setCCPTextAnnotationSpan
import org.apache.uima.jcas.cas.FSArray; //导入方法依赖的package包/类
/**
* this method resets the span for an annotation.. this includes the Span FSArray
*
* @param ccpTA
* @param spanStart
* @param spanEnd
*/
public static void setCCPTextAnnotationSpan(CCPTextAnnotation ccpTA, int spanStart, int spanEnd)
throws CASException {
JCas jcas = ccpTA.getCAS().getJCas();
/* Initialize a new CCPSpan */
CCPSpan ccpSpan = new CCPSpan(jcas);
ccpSpan.setSpanStart(spanStart);
ccpSpan.setSpanEnd(spanEnd);
/* Add the span to the span array */
FSArray ccpSpans = new FSArray(jcas, 1);
ccpSpans.set(0, ccpSpan);
/* Update the text annotation with the new span information */
ccpTA.setSpans(ccpSpans);
ccpTA.setBegin(spanStart);
ccpTA.setEnd(spanEnd);
// /* update class mention to point to this text annotation */
// CCPClassMention ccpCM = ccpTA.getClassMention();
// if (ccpCM != null) {
// FSArray ccpTAs = new FSArray(jcas, 1);
// ccpTAs.set(0, ccpTA);
// ccpCM.setCcpTextAnnotations(ccpTAs);
// }
}