org.apache.uima.jcas.cas.FSArray类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.apache.uima.jcas.cas.FSArray类的一些代码示例,展示了FSArray类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FSArray类的具体详情如下:
包路径:org.apache.uima.jcas.cas.FSArray
类名称:FSArray

FSArray介绍

[英]Java Class model for Cas FSArray type
[中]Cas FSArray类型的Java类模型

代码示例

代码示例来源:origin: CLLKazan/UIMA-Ext

public static FSArray toFSArray(JCas cas, Iterable<? extends FeatureStructure> srcCol,
    int srcSize) {
  FSArray result = new FSArray(cas, srcSize);
  int i = 0;
  for (FeatureStructure fs : srcCol) {
    result.set(i, fs);
    i++;
  }
  return result;
}

代码示例来源:origin: apache/tika

StringBuilder sb = new StringBuilder();
if (mentions != null) {
  for (int i = 0; i < mentions.size(); i++) {
    if (mentions.get(i) instanceof UmlsConcept) {
      UmlsConcept concept = (UmlsConcept) mentions.get(i);
      sb.append("cui=").append(concept.getCui()).append(",").
        append(concept.getCodingScheme()).append("=").
        append(concept.getCode());
      if (i < mentions.size() - 1) {
        sb.append(",");

代码示例来源:origin: org.apache.uima/textmarker-core

public static <T extends FeatureStructure> List<T> toList(FSArray fsArray, Class<T> cls) {
 List<T> list = new ArrayList<T>();
 if (fsArray == null) {
  return list;
 }
 for (FeatureStructure fs : fsArray.toArray()) {
  list.add(cls.cast(fs));
 }
 return list;
}

代码示例来源:origin: de.unistuttgart.ims/uimautil

public static FSArray toFSArray(JCas jcas, FeatureStructure... fs) {
  FSArray arr = new FSArray(jcas, fs.length);
  for (int i = 0; i < fs.length; i++) {
    arr.set(i, fs[i]);
  }
  arr.addToIndexes();
  return arr;
}

代码示例来源:origin: org.apache.ctakes/ctakes-drug-ner

/**
 * Stores annotation version as a property JCas object.
 * 
 * @param jcas
 */
private void storeAnnotationVersion(JCas jcas) {
   FSIterator<TOP> itr = jcas.getJFSIndexRepository().getAllIndexedFS(Pairs.type);
  if (itr == null || !itr.hasNext())
    return;
  Pairs props = (Pairs) itr.next(); 
  // create a new property array that is one item bigger
  FSArray propArr = props.getPairs();
  FSArray newPropArr = new FSArray(jcas, propArr.size() + 1);
  for (int i = 0; i < propArr.size(); i++) {
    newPropArr.set(i, propArr.get(i));
  }
  Pair annotVerProp = new Pair(jcas);    		
  annotVerProp.setAttribute(iv_annotVerPropKey);
  annotVerProp.setValue(String.valueOf(iv_annotVer));
  // add annotation version prop as last item in array
  newPropArr.set(newPropArr.size() - 1, annotVerProp);
  props.setPairs(newPropArr);
}
public void processCas(CAS cas) throws ResourceProcessException {

代码示例来源:origin: org.apache.ctakes/ctakes-constituency-parser

public static void removeRightOfAnnotation(JCas jcas, TreebankNode node, Annotation annot) {
  // if the whole tree is to the left of the annotation then do nothing:
  if(node.getEnd() <= annot.getBegin() || node.getLeaf()) return;
  // if there is some overlap then iterate over trees, ignoring those to the left, recursing on those that overlap, and deleting those to the right
  for(int i = 0; i < node.getChildren().size(); i++){
    TreebankNode child = node.getChildren(i);
    if(child.getEnd() <= annot.getBegin()){
      // child is to the left of annotation completely
      continue;
    }else if(child.getBegin() > annot.getEnd()){
      // child is to the right of annotation completely -- remove it and all to the right
      FSArray newChildren = new FSArray(jcas, i);
      for(int j = 0; j < i; j++){
        newChildren.set(j, node.getChildren(j));
      }
      node.setChildren(newChildren);
      break;
    }else{
      removeRightOfAnnotation(jcas, child, annot);
    }
  }
}

代码示例来源:origin: apache/uima-uimaj

public FSArray getFSArray0L() {
 if (null == sharedView.fsArray0L)
  sharedView.fsArray0L = new FSArray(this, 0);
 return sharedView.fsArray0L;
}

代码示例来源:origin: de.unistuttgart.ims/de.unistuttgart.ims.drama.util

public static Collection<CastFigure> getCastFigures(Utterance u) {
  Collection<Speaker> s = getSpeakers(u);
  Collection<CastFigure> f = new LinkedList<CastFigure>();
  for (Speaker speaker : s) {
    for (int i = 0; i < speaker.getCastFigure().size(); i++)
      f.add(speaker.getCastFigure(i));
  }
  return f;
}

代码示例来源:origin: org.apache.ctakes/ctakes-constituency-parser

public static TopTreebankNode getTreeCopy(JCas jcas, TopTreebankNode orig){
  if(orig == null) return null;
  TopTreebankNode copy = new TopTreebankNode(jcas);
  copy.setNodeType(orig.getNodeType());
  copy.setBegin(orig.getBegin());
  copy.setEnd(orig.getEnd());
  copy.setParent(null);
  copy.setChildren(new FSArray(jcas,1));
  copy.setTreebankParse(orig.getTreebankParse());
  if(orig.getChildren() == null || orig.getChildren().size() == 0){
    System.err.println("WHAT?");
  }
  copy.setChildren(0, getTreeCopy(jcas, orig.getChildren(0)));
  copy.getChildren(0).setParent(copy);
  return copy;
}

代码示例来源:origin: dstl/baleen

@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));
 }
}

代码示例来源:origin: org.apache.uima/ruta-core

public static FSArray toFSArray(JCas jCas, List<? extends FeatureStructure> fsList) {
 FSArray fsArray = new FSArray(jCas, fsList.size());
 fsArray.copyFromArray(fsList.toArray(new FeatureStructure[fsList.size()]), 0, 0, fsList.size());
 return fsArray;
}

代码示例来源:origin: apache/uima-uimaj

/**
 * @see org.apache.uima.cas.ArrayFS#toArray()
 */
public FeatureStructure[] toArray() {
 final int size = size();
 FeatureStructure[] outArray = new FeatureStructure[size];
 copyToArray(0, outArray, 0, size);
 return outArray;
}

代码示例来源:origin: dstl/baleen

Arrays.stream(e.getTokens().toArray())
     .map(w -> ((WordToken) w).getCoveredText())
     .map(this::normalize)
if (e.getEntities() != null && e.getEntities().size() > 0) {
 Arrays.stream(e.getEntities().toArray())
   .forEach(
     x -> {

代码示例来源:origin: apache/uima-uimaj

@Override
public FeatureStructure next() {
 if (!hasNext())
  throw new NoSuchElementException();
 return get(i++);
}

代码示例来源:origin: org.apache.ctakes/ctakes-clinical-pipeline

/**
* Stores annotation version as a property JCas object.
*
* @param jcas
*/
private void storeAnnotationVersion( JCas jcas ) {
 FSIterator<TOP> itr = jcas.getJFSIndexRepository().getAllIndexedFS( Pairs.type );
 if ( itr == null || !itr.hasNext() ) {
   return;
 }
 Pairs props = (Pairs)itr.next();
 // create a new property array that is one item bigger
 FSArray propArr = props.getPairs();
 FSArray newPropArr = new FSArray( jcas, propArr.size() + 1 );
 for ( int i = 0; i < propArr.size(); i++ ) {
   newPropArr.set( i, propArr.get( i ) );
 }
 Pair annotVerProp = new Pair( jcas );
 annotVerProp.setAttribute( iv_annotVerPropKey );
 annotVerProp.setValue( String.valueOf( iv_annotVer ) );
 // add annotation version prop as last item in array
 newPropArr.set( newPropArr.size() - 1, annotVerProp );
 props.setPairs( newPropArr );
}

代码示例来源:origin: apache/ctakes

public static void removeRightOfAnnotation(JCas jcas, TreebankNode node, Annotation annot) {
  // if the whole tree is to the left of the annotation then do nothing:
  if(node.getEnd() <= annot.getBegin() || node.getLeaf()) return;
  // if there is some overlap then iterate over trees, ignoring those to the left, recursing on those that overlap, and deleting those to the right
  for(int i = 0; i < node.getChildren().size(); i++){
    TreebankNode child = node.getChildren(i);
    if(child.getEnd() <= annot.getBegin()){
      // child is to the left of annotation completely
      continue;
    }else if(child.getBegin() > annot.getEnd()){
      // child is to the right of annotation completely -- remove it and all to the right
      FSArray newChildren = new FSArray(jcas, i);
      for(int j = 0; j < i; j++){
        newChildren.set(j, node.getChildren(j));
      }
      node.setChildren(newChildren);
      break;
    }else{
      removeRightOfAnnotation(jcas, child, annot);
    }
  }
}

代码示例来源:origin: org.apache.uima/uimafit-core

public static FSArray createFSArray(JCas aJCas, Collection<? extends FeatureStructure> aCollection) {
 return fillArrayFS(new FSArray(aJCas, aCollection.size()), aCollection);
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.wsd/de.tudarmstadt.ukp.dkpro.wsd.evaluation

protected void tableCellGoldResults(FSArray senses)
  throws IOException
{
  if (senses == null || senses.size() == 0) {
    tableCellSenseArray(senses, SenseType.GOLDNA, null);
  }
  else {
    tableCellSenseArray(senses, SenseType.GOLD, null);
  }
}

代码示例来源:origin: apache/ctakes

public static TopTreebankNode getTreeCopy(JCas jcas, TopTreebankNode orig){
  if(orig == null) return null;
  TopTreebankNode copy = new TopTreebankNode(jcas);
  copy.setNodeType(orig.getNodeType());
  copy.setBegin(orig.getBegin());
  copy.setEnd(orig.getEnd());
  copy.setParent(null);
  copy.setChildren(new FSArray(jcas,1));
  copy.setTreebankParse(orig.getTreebankParse());
  if(orig.getChildren() == null || orig.getChildren().size() == 0){
    System.err.println("WHAT?");
  }
  copy.setChildren(0, getTreeCopy(jcas, orig.getChildren(0)));
  copy.getChildren(0).setParent(copy);
  return copy;
}

代码示例来源:origin: de.unistuttgart.ims.uima.io/generic-xml-reader

public static FSArray toFSArray(JCas jcas, FeatureStructure... fs) {
  FSArray arr = new FSArray(jcas, fs.length);
  for (int i = 0; i < fs.length; i++) {
    arr.set(i, fs[i]);
  }
  arr.addToIndexes();
  return arr;
}

相关文章