You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ea...@apache.org on 2007/03/08 19:43:18 UTC

svn commit: r516138 - in /incubator/uima/uimacpp/trunk/examples: data/sofa.xcas src/SofaDataAnnotator.cpp src/SofaExampleAnnotator.cpp src/SofaExampleApplication.cpp

Author: eae
Date: Thu Mar  8 10:43:17 2007
New Revision: 516138

URL: http://svn.apache.org/viewvc?view=rev&rev=516138
Log:
use recommended getView API

Modified:
    incubator/uima/uimacpp/trunk/examples/data/sofa.xcas
    incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp
    incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp
    incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp

Modified: incubator/uima/uimacpp/trunk/examples/data/sofa.xcas
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/data/sofa.xcas?view=diff&rev=516138&r1=516137&r2=516138
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/data/sofa.xcas (original)
+++ incubator/uima/uimacpp/trunk/examples/data/sofa.xcas Thu Mar  8 10:43:17 2007
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <CAS>
 <uima.cas.Sofa _indexed="0" _id="1" sofaNum="1" sofaID="EnglishDocument" mimeType="text"  sofaString="This is a text document for analysis" />
+<uima.tcas.DocumentAnnotation _indexed="1" _id="8" sofa="1" begin="0" end="36" language="**"/>
 </CAS>

Modified: incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp?view=diff&rev=516138&r1=516137&r2=516138
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp (original)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp Thu Mar  8 10:43:17 2007
@@ -62,17 +62,13 @@
   TyErrorId process(CAS & rCas, ResultSpecification const & crResultSpecification) {
     cout << "SofaDataAnnotator: process() begins" << endl;
 
-    /** get the default text sofa */
-    SofaFS textSofa = rCas.getSofa(getAnnotatorContext().mapToSofaID("EnglishDocument"));
-    if (!textSofa.isValid()) {
-      cout << "  No Sofa named EnglishDocument found" << endl;
-      return (TyErrorId)UIMA_ERR_USER_ANNOTATOR_COULD_NOT_PROCESS;
-    }
-
     /** get the CAS view of the sofa */
-    CAS * tcas = rCas.getView(textSofa);
+    CAS * tcas = rCas.getView("EnglishDocument");
     /** get the handle to the index repository */
     FSIndexRepository & indexRep = tcas->getIndexRepository();
+
+    /** get the default text sofa */
+    SofaFS textSofa = tcas->getSofa();
 
     /** get the handle to the sofa data stream */
     SofaDataStream * pStream = textSofa.getSofaDataStream();

Modified: incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp?view=diff&rev=516138&r1=516137&r2=516138
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp (original)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp Thu Mar  8 10:43:17 2007
@@ -77,26 +77,18 @@
     CAS *engTcas, *germTcas;
     UnicodeString delimUS(" ");
     UChar *myLocalSaveState;
-    SofaFS engSofa;
 
     // Look for english document and "translate" to German
     cout << "SofaExampleAnnotator: process() begins" << endl;
 
-    // get English text Sofa and open CAS view
-    engSofa = rCAS.getSofa(getAnnotatorContext().mapToSofaID("EnglishDocument"));
-    if (!engSofa.isValid()) {
-      cout << "  No Sofa named EnglishDocument found" << endl;
-      getAnnotatorContext().getLogger().logError("No Sofa named EnglishDocument found");
-      return (TyErrorId)UIMA_ERR_USER_ANNOTATOR_COULD_NOT_PROCESS;
-    }
-    engTcas = rCAS.getView(engSofa);
+    // get English view
+    engTcas = rCAS.getView("EnglishDocument");
     DocumentFS adocFS = engTcas->getDocumentAnnotation();
     UnicodeStringRef aengText = adocFS.getCoveredText();
     cout << "      English Input: " << aengText << endl;
 
     // Create the output German text Sofa and open CAS view
-    SofaFS germSofa = rCAS.createSofa(pAnc->mapToSofaID("GermanDocument"), "text");
-    germTcas = rCAS.getView(germSofa);
+    germTcas = rCAS.createView("GermanDocument");
 
     // Get pointer to the English text document
     DocumentFS docFS = engTcas->getDocumentAnnotation();

Modified: incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp?view=diff&rev=516138&r1=516137&r2=516138
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp (original)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp Thu Mar  8 10:43:17 2007
@@ -97,14 +97,13 @@
     // Initialize the CAS
     CAS* aCas = pEngine->newCAS();
     for (int jj=0; jj<runTimes; jj++) {
-      //create a text sofa with appropriate name for English->German translator
-      SofaFS engSofa = aCas->createSofa(
-                         pEngine->getAnnotatorContext().mapToSofaID("EnglishDocument"), "text");
+      //create a text view with appropriate name for English->German translator
+      CAS * eTcas = aCas->createView("EnglishDocument");
 
       //and set the Sofa data with the English document
-      engSofa.setLocalSofaData(ustrInputText);
+      eTcas->setSofaDataString(ustrInputText, "text");
+
 // Get pointer to the English text document
-      CAS * eTcas = aCas->getView(engSofa);
       DocumentFS docFS = eTcas->getDocumentAnnotation();
       UnicodeStringRef eText = docFS.getCoveredText();
       //cout << "eng tcas covered text " << eText << endl;
@@ -116,7 +115,7 @@
 
       if (!runQuiet)
         cout << endl << "Retrieving all annotations for the English document:" << endl;
-      CAS* engTcas = aCas->getView(engSofa);
+      CAS* engTcas = aCas->getView("EnglishDocument");
 
       ANIndex anIdx = engTcas->getAnnotationIndex(
                         engTcas->getTypeSystem().getType("uima.tcas.Annotation"));
@@ -134,8 +133,7 @@
 
       if (!runQuiet)
         cout << endl << "Retrieving all annotations for the German document:" << endl;
-      CAS* germTcas = aCas->getView(aCas->getSofa(
-                                      pEngine->getAnnotatorContext().mapToSofaID("GermanDocument")));
+      CAS* germTcas = aCas->getView("GermanDocument");
 
       Type crossType  = engTcas->getTypeSystem().getType("sofa.test.CrossAnnotation");
       Feature otherFeat = crossType.getFeatureByBaseName("otherAnnotation");