Package org.apache.uima.cas

Examples of org.apache.uima.cas.SofaFS


      responseFrame.fset(Constants.ANNOTATION_TIME, annotationTime);

      // UIMAFramework.getLogger().log("CAS ACount::" +
      // cas.getAnnotationIndex().size());
      int totalAnnots = 0;
      SofaFS sofa;
      FSIterator sItr = cas.getSofaIterator();
      while (sItr.isValid()) {
        sofa = (SofaFS) sItr.get();
        totalAnnots += cas.getView(sofa).getAnnotationIndex().size();
        sItr.moveToNext();
View Full Code Here


      ct.getExtraDataFrame().fset(Constants.ANNOTATION_TIME, annotationTime);
      // Extract CAS
      // UIMAFramework.getLogger().log("CAS ACount::" +
      // cas.getAnnotationIndex().size());
      int totalAnnots = 0;
      SofaFS sofa;
      FSIterator sItr = cas.getSofaIterator();
      while (sItr.isValid()) {
        sofa = (SofaFS) sItr.get();
        totalAnnots += cas.getView(sofa).getAnnotationIndex().size();
        sItr.moveToNext();
View Full Code Here

      // Add a new Sofa
      // id.setSofaID("FrenchDocument");
      // Sofa fs = new Sofa(jcas, id, "text");
      CAS frCas = jcas.getCas().createView("FrenchDocument");
      SofaFS fs = frCas.getSofa();
      assertTrue(4 == fs.getSofaRef());

      // Open JCas views of some Sofas
      JCas engJcas = cas.getJCas(es);
      JCas frJcas = jcas.getView("FrenchDocument");
View Full Code Here

    // Assert.assertFalse(aCAS instanceof CAS);
    // Create the English document Sofa
    SofaID realSofaName = getUimaContext().mapToSofaID("InputText");
    // System.out.println("CASINITIALIZER: real sofa name for InputText " +
    // realSofaName.getSofaID());
    SofaFS ls = aCAS.createSofa(realSofaName, "text");
    ls.setLocalSofaData("this beer is good");
  }
View Full Code Here

    } catch (NullPointerException e) {
      // Create the Source text Sofa
      SofaID sofaid = getUimaContext().mapToSofaID("InputText");
      // System.out.println("COLLECTIONREADER: real sofa name for InputText " + sofaid.getSofaID());

      SofaFS ls = aCAS.createSofa(sofaid, "text");
      ls.setLocalSofaData(text);
    }
    hasMore = false;
  }
View Full Code Here

      Iterator<?> sofas = ((CASImpl) MainFrame.this.cas).getBaseCAS().getSofaIterator();
      Feature sofaIdFeat = MainFrame.this.cas.getTypeSystem().getFeatureByFullName(
          CAS.FEATURE_FULL_NAME_SOFAID);
      boolean nonDefaultSofaFound = false;
      while (sofas.hasNext()) {
        SofaFS sofa = (SofaFS) sofas.next();
        String sofaId = sofa.getStringValue(sofaIdFeat);
        if (!CAS.NAME_DEFAULT_SOFA.equals(sofaId)) {
          this.sofaSelectionComboBox.addItem(sofaId);
          nonDefaultSofaFound = true;
        }
      }
View Full Code Here

    Iterator<?> sofas = ((CASImpl) getCas()).getBaseCAS().getSofaIterator();
    Feature sofaIdFeat = getCas().getTypeSystem()
        .getFeatureByFullName(CAS.FEATURE_FULL_NAME_SOFAID);
    boolean nonDefaultSofaFound = false;
    while (sofas.hasNext()) {
      SofaFS sofa = (SofaFS) sofas.next();
      String sofaId = sofa.getStringValue(sofaIdFeat);
      if (!CAS.NAME_DEFAULT_SOFA.equals(sofaId)) {
        this.sofaSelectionComboBox.addItem(sofaId);
        nonDefaultSofaFound = true;
      }
    }
View Full Code Here

    sofaSelectionComboBox.removeAllItems();
    Iterator sofas = aCAS.getSofaIterator();
    Feature sofaIdFeat = aCAS.getTypeSystem().getFeatureByFullName(CAS.FEATURE_FULL_NAME_SOFAID);
    boolean nonDefaultSofaFound = false;
    while (sofas.hasNext()) {
      SofaFS sofa = (SofaFS) sofas.next();
      if (sofa.getLocalStringData() != null) {
        String sofaId = sofa.getStringValue(sofaIdFeat);
        if (CAS.NAME_DEFAULT_SOFA.equals(sofaId)) {
          sofaId = "DEFAULT"; // make nicer display
        } else {
          nonDefaultSofaFound = true;
        }
View Full Code Here

    try {

      // Create a Sofa (using old APIs for now)
      SofaID_impl id = new SofaID_impl();
      id.setSofaID("EnglishDocument");
      SofaFS es = this.cas.createSofa(id, "text");
      // Initial View is #1!!!
      assertTrue(2 == es.getSofaRef());

      // Set the document text
      es.setLocalSofaData("this beer is good");

      // Test Multiple Sofas across XCAS serialization
      XCASSerializer ser = new XCASSerializer(this.cas.getTypeSystem());
      OutputStream outputXCAS = new FileOutputStream("Sofa.xcas");
      XMLSerializer xmlSer = new XMLSerializer(outputXCAS);
      try {
        ser.serialize(cas, xmlSer.getContentHandler());
        outputXCAS.close();
      } catch (IOException e) {
        e.printStackTrace();
      } catch (SAXException e) {
        e.printStackTrace();
      }

      // Deserialize XCAS
     this.cas.reset();
      InputStream inputXCAS = new FileInputStream("Sofa.xcas");
      try {
        XCASDeserializer.deserialize(inputXCAS, cas, false);
        inputXCAS.close();
      } catch (SAXException e2) {
        e2.printStackTrace();
      } catch (IOException e2) {
        e2.printStackTrace();
      }

      // Add a new Sofa
      // SofaID_impl gid = new SofaID_impl();
      // gid.setSofaID("GermanDocument");
      // SofaFS gs = ((CASImpl)cas).createSofa(gid,"text");
      CAS gerTcas =this.cas.createView("GermanDocument");
      assertTrue(gerTcas.getViewName().equals("GermanDocument"));
      SofaFS gs = gerTcas.getSofa();

      assertTrue(gs != null);
      assertTrue(3 == gs.getSofaRef());

      // Set the document text
      // gs.setLocalSofaData("das bier ist gut");
      gerTcas.setDocumentText("das bier ist gut");

      // Test multiple Sofas across binary serialization
      CASSerializer cs = Serialization.serializeNoMetaData(cas);
      cas = Serialization.createCAS(casMgr, cs);

      // Add a new Sofa
      // SofaID_impl fid = new SofaID_impl();
      // fid.setSofaID("FrenchDocument");
      // SofaFS fs = ((CASImpl)cas).createSofa(fid, "text");
      CAS frT =this.cas.createView("FrenchDocument");
      assertTrue(frT.getViewName().equals("FrenchDocument"));
      SofaFS fs = frT.getSofa();
      assertTrue(fs != null);
      assertTrue(4 == fs.getSofaRef());

      // Test multiple Sofas across blob serialization
      ByteArrayOutputStream fos = new ByteArrayOutputStream();
      Serialization.serializeCAS(cas, fos);
     this.cas.reset();
View Full Code Here

    assertTrue( testView.getViewName().equals("TestView"));
   
    this.cas.reset();
    SofaID_impl id = new SofaID_impl();
    id.setSofaID("TestView");
    SofaFS testSofa = this.cas.createSofa(id, "text");
    CAS newView = this.cas.getView(testSofa);
    assertTrue( newView.getViewName().equals("TestView"));
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.SofaFS

Copyright © 2018 www.massapicom. 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.