Examples of FSIndexRepository


Examples of org.apache.uima.cas.FSIndexRepository

    tokenTypeFs2.setIntValue(beginFeat, 17);
   
    cas.addFsToIndexes(tokenTypeFs1);
    cas.addFsToIndexes(tokenTypeFs2);
   
    FSIndexRepository ir = cas.getIndexRepository();
    FSIndex<FeatureStructure> index = ir.getIndex(CASTestSetup.ANNOT_SET_INDEX);
    assertEquals(index.size(), 1);

    index = ir.getIndex(CASTestSetup.ANNOT_SORT_INDEX);
    assertEquals(index.size(), 2);

  }
View Full Code Here

Examples of org.apache.uima.cas.FSIndexRepository

    } else {
      root.setUserObject(noIndexReposLabel);
    }
    root.removeAllChildren();
    if (this.cas != null && useCAS) {
      FSIndexRepository ir = this.cas.getIndexRepository();
      Iterator<String> it = ir.getLabels();
      while (it.hasNext()) {
        String label = it.next();
        FSIndex index1 = ir.getIndex(label);
        IndexTreeNode nodeObj = new IndexTreeNode(label, index1.getType(), index1.size());
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeObj);
        root.add(node);
        node.add(createTypeTree(index1.getType(), this.cas.getTypeSystem(), label, ir));
      }
View Full Code Here

Examples of org.apache.uima.cas.FSIndexRepository

      this.cas.getIndexRepository().addFS(
          this.cas.createAnnotation(this.tokenType, i * 2, (i * 2) + 1));
    }
    final int start = 5;
    final int end = 7;
    FSIndexRepository repo = this.cas.getIndexRepository();
    for (int i = 0; i < 10; i++) {
      AnnotationFS annotation = this.cas.createAnnotation(this.annotationType, start, end);
      repo.addFS(annotation);
    }
    AnnotationFS match = this.cas.createAnnotation(this.annotationType, start, end);
    FSIndex<AnnotationFS> index = this.cas.getAnnotationIndex();
    FSIterator<AnnotationFS> it = index.iterator();
    it.moveTo(match);
View Full Code Here

Examples of org.apache.uima.cas.FSIndexRepository

   * Test deleting FSs from indexes.
   */
  public void testDelete() {
    // Create a bunch of FSs.
    AnnotationFS[] fsArray = new AnnotationFS[100];
    FSIndexRepository ir = this.cas.getIndexRepository();
    for (int i = 0; i < fsArray.length; i++) {
      fsArray[i] = this.cas.createAnnotation(this.tokenType, i * 5, (i * 5) + 4);
      ir.addFS(fsArray[i]);
    }
    FSIndex<FeatureStructure> setIndex = this.cas.getIndexRepository().getIndex(
        CASTestSetup.ANNOT_SET_INDEX, this.tokenType);
    FSIterator<FeatureStructure> setIt = setIndex.iterator();
    FSIndex<AnnotationFS> sortedIndex = this.cas.getAnnotationIndex(this.tokenType);
    FSIterator<AnnotationFS> sortedIt = sortedIndex.iterator();
    FSIndex<FeatureStructure> bagIndex = ir.getIndex(CASTestSetup.ANNOT_BAG_INDEX, this.tokenType);
    FSIterator<FeatureStructure> bagIt = bagIndex.iterator();
    // For each index, check that the FSs are actually in the index.
    for (int i = 0; i < fsArray.length; i++) {
      setIt.moveTo(fsArray[i]);
      assertTrue(setIt.isValid());
      assertTrue(setIt.get().equals(fsArray[i]));
      bagIt.moveTo(fsArray[i]);
      assertTrue(bagIt.isValid());
      assertTrue(bagIt.get().equals(fsArray[i]));
      sortedIt.moveTo(fsArray[i]);
      assertTrue(sortedIt.isValid());
      assertTrue(sortedIt.get().equals(fsArray[i]));
    }
    // Remove an annotation, then add it again. Try setting the iterators to
    // that FS. The iterator should either be invalid, or point to a
    // different FS.
    for (int i = 0; i < fsArray.length; i++) {
      ir.removeFS(fsArray[i]);
      setIt.moveTo(fsArray[i]);
      if (setIt.isValid()) {
        int oldRef = this.cas.ll_getFSRef(fsArray[i]);
        int newRef = this.cas.ll_getFSRef(setIt.get());
        assertTrue(oldRef != newRef);
        assertTrue(!setIt.get().equals(fsArray[i]));
      }
      bagIt.moveTo(fsArray[i]);
      if (bagIt.isValid()) {
        assertTrue(!bagIt.get().equals(fsArray[i]));
      }
      sortedIt.moveTo(fsArray[i]);
      if (sortedIt.isValid()) {
        assertTrue(!sortedIt.get().equals(fsArray[i]));
      }
      ir.addFS(fsArray[i]);
    }
    // Remove all annotations.
    for (int i = 0; i < fsArray.length; i++) {
      ir.removeFS(fsArray[i]);
    }
    // All iterators should be invalidated when being reset.
    bagIt.moveToFirst();
    assertFalse(bagIt.isValid());
    setIt.moveToFirst();
View Full Code Here

Examples of org.apache.uima.cas.FSIndexRepository

    public Object getContents() {
      return getIndexContents(fsIndex);
    }

    public Object getSubTypes() {
      FSIndexRepository ir = cas.getIndexRepository();
      Type type = fsIndex.getType();
      List<Type> subtypes = cas.getTypeSystem().getProperlySubsumedTypes(type);

      DebugNameValuePair[] r = new DebugNameValuePair[subtypes.size()];

      int i = 0;
      Iterator<Type> it = subtypes.iterator();
      while (it.hasNext()) {
        Type stype = it.next();
        r[i++] = new DebugNameValuePair("Type: " + stype.getName(),
                new UnexpandedFeatureStructures(ir.getIndex(indexName, stype)));
      }
      return r;
    }
View Full Code Here

Examples of org.apache.uima.cas.FSIndexRepository

    assertTrue(i3 != null);
  }

  public void testGetFSIndexRepository() throws Exception {
    try {
      FSIndexRepository ir = jcas.getFSIndexRepository();
      LowLevelIndexRepository ll_ir = jcas.getLowLevelIndexRepository();

      assertTrue(ir != null);
      assertTrue(ir == cas.getIndexRepository());
      assertTrue(ll_ir != null);
View Full Code Here

Examples of org.apache.uima.cas.FSIndexRepository

    } else {
      root.setUserObject(noIndexReposLabel);
    }
    root.removeAllChildren();
    if (this.cas != null && useCAS) {
      FSIndexRepository ir = this.cas.getIndexRepository();
      Iterator it = ir.getLabels();
      while (it.hasNext()) {
        String label = (String) it.next();
        FSIndex index1 = ir.getIndex(label);
        IndexTreeNode nodeObj = new IndexTreeNode(label, index1.getType(), index1.size());
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(nodeObj);
        root.add(node);
        node.add(createTypeTree(index1.getType(), this.cas.getTypeSystem(), label, ir));
      }
View Full Code Here

Examples of org.apache.uima.cas.FSIndexRepository

      Type et = ts.getType("EnumType");
      Assert.assertEquals("EnumType", et.getName());
      Assert.assertEquals(et, f2.getRange());

      // indexes
      FSIndexRepository irep = cas.getIndexRepository();
      FSIndex ind = irep.getIndex("Index1");
      Assert.assertNotNull(ind);
      Assert.assertEquals("Type1", ind.getType().getName());
      Assert.assertEquals(FSIndex.SORTED_INDEX, ind.getIndexingStrategy());

      FeatureStructure fs1 = cas.createFS(t1);
      fs1.setIntValue(f1, 0);
      FeatureStructure fs2 = cas.createFS(t1);
      fs2.setIntValue(f1, 1);
      Assert.assertTrue(ind.compare(fs1, fs2) < 0);

      FSIndex ind2 = irep.getIndex("Index2");
      Assert.assertNotNull(ind2);
      Assert.assertEquals("Type2", ind2.getType().getName());
      Assert.assertEquals(FSIndex.SET_INDEX, ind2.getIndexingStrategy());

      FeatureStructure fs3 = cas.createFS(t2);
      fs3.setStringValue(f2, "One");
      FeatureStructure fs4 = cas.createFS(t2);
      fs4.setStringValue(f2, "Two");
      Assert.assertTrue(ind2.compare(fs3, fs4) > 0);

      FSIndex ind3 = irep.getIndex("Index3");
      Assert.assertNotNull(ind3);
      Assert.assertEquals("uima.tcas.Annotation", ind3.getType().getName());
      Assert.assertEquals(FSIndex.SORTED_INDEX, ind3.getIndexingStrategy());

      AnnotationFS fs5 = cas.createAnnotation(t1, 0, 0);
View Full Code Here

Examples of org.apache.uima.cas.FSIndexRepository

    public Object getContents() {
      return getIndexContents(fsIndex);
    }

    public Object getSubTypes() {
      FSIndexRepository ir = cas.getIndexRepository();
      Type type = fsIndex.getType();
      List subtypes = cas.getTypeSystem().getProperlySubsumedTypes(type);

      DebugNameValuePair[] r = new DebugNameValuePair[subtypes.size()];

      int i = 0;
      Iterator it = subtypes.iterator();
      while (it.hasNext()) {
        Type stype = (Type) it.next();
        r[i++] = new DebugNameValuePair("Type: " + stype.getName(),
                new UnexpandedFeatureStructures(ir.getIndex(indexName, stype)));
      }
      return r;
    }
View Full Code Here

Examples of org.apache.uima.cas.FSIndexRepository

    public Object getContents() {
      return getIndexContents(fsIndex);
    }

    public Object getSubTypes() {
      FSIndexRepository ir = cas.getIndexRepository();
      Type type = fsIndex.getType();
      List subtypes = cas.getTypeSystem().getProperlySubsumedTypes(type);

      DebugNameValuePair[] r = new DebugNameValuePair[subtypes.size()];

      int i = 0;
      Iterator it = subtypes.iterator();
      while (it.hasNext()) {
        Type stype = (Type) it.next();
        r[i++] = new DebugNameValuePair("Type: " + stype.getName(),
                new UnexpandedFeatureStructures(ir.getIndex(indexName, stype)));
      }
      return r;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.