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/02/03 18:19:14 UTC

svn commit: r503265 [1/6] - /incubator/uima/uimacpp/trunk/src/test/src/

Author: eae
Date: Sat Feb  3 09:19:12 2007
New Revision: 503265

URL: http://svn.apache.org/viewvc?view=rev&rev=503265
Log:
Initial entry

Added:
    incubator/uima/uimacpp/trunk/src/test/src/
    incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/annotator_dump.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/annotator_tok.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/conui.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/doc_buffer.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/plugin_annotator_dump.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/plugin_tokenizer.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/ss_tokenizer.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_cas.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_cas.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_casserializer.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_casserializer.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_engine.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_engine.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_engine.vcproj-new
    incubator/uima/uimacpp/trunk/src/test/src/test_iterators.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_iterators.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_language.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_language.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_sofa.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_sofa.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_typepriority.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_typepriority.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_xcasdeserialization.cpp   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/test_xcasdeserialization.vcproj   (with props)
    incubator/uima/uimacpp/trunk/src/test/src/tt_types.cpp   (with props)

Added: incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.cpp?view=auto&rev=503265
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.cpp (added)
+++ incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.cpp Sat Feb  3 09:19:12 2007
@@ -0,0 +1,188 @@
+/** SimpleTextSegmenter.cpp
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+
+Example CAS Multiplier
+*/
+#include <stdio.h>
+#include "uima/api.hpp"
+using namespace uima;
+
+
+class  SimpleTextSegmenter : public Annotator {
+private:
+
+  UnicodeStringRef docTextUS;
+
+  size_t threshhold;
+  size_t docLen;
+  size_t start;
+  size_t delimLen;
+  size_t remainingLen;
+
+  UnicodeString delimUS;
+  const UChar * delimP;
+  const UChar * docTextBeginP;
+  const UChar * remainingTextP;
+  bool hasMore;
+
+  AnnotatorContext * pAnc;
+
+  int segmentNum;
+
+  /* We have a separate function getConfigValues()
+     for initialize() and reconfigure()
+  */
+  TyErrorId getConfigValues() {
+    return (TyErrorId)UIMA_ERR_NONE;
+  }
+
+
+public:
+
+  SimpleTextSegmenter(void) {
+    //   cout << "SimpleTextSegmenter: Constructor" << endl;
+  }
+
+  ~SimpleTextSegmenter(void) {
+    //   cout << "SimpleTextSegmenter: Destructor" << endl;
+  }
+
+  /** */
+  TyErrorId initialize(AnnotatorContext & rclAnnotatorContext) {
+    cout << "SimpleTextSegmenter: initialize()" << endl;
+
+    pAnc = &rclAnnotatorContext;
+
+    /* default delimiter */
+    delimUS = "\n";
+
+    /* read in configuration parameter setting */
+    UnicodeString param("SegmentDelimiter");
+    if (rclAnnotatorContext.isParameterDefined(param) ) {
+      rclAnnotatorContext.extractValue(param, delimUS);
+    }
+
+    delimP = delimUS.getBuffer();
+    delimLen = delimUS.length();
+    if (delimLen < 1 ) {
+      pAnc->getLogger().logError("initialize() Invalid delimiter specified. Must be at least one character in length");
+      UIMA_EXC_THROW_NEW(Exception,
+                         UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT,
+                         UIMA_MSG_ID_EXCON_CONFIG_VALUE_EXTRACT,
+                         ErrorMessage(UIMA_MSG_ID_LITERAL_STRING, "Invalid value for SegmentDelimiter"),
+                         ErrorInfo::unrecoverable);
+    }
+
+    cout << "initialize() using segment delimiter " << delimUS << " with length " << delimLen << endl;
+
+    pAnc->getLogger().logMessage("initialize() Using Segment Delimiter '" + delimUS + "'");
+    segmentNum=0;
+    return (TyErrorId)UIMA_ERR_NONE;
+  }
+
+  // Segment the input text.
+  TyErrorId process(CAS & cas, ResultSpecification const & crResultSpecification) {
+    cout  << "SimpleTextSegmenter: process()" << endl;
+
+    // Get the text document
+    docTextUS = cas.getDocumentText();
+    /* Get number of Unicode chars (UTF-16 code units)  */
+    docLen = docTextUS.length();
+    start = 0;
+    remainingTextP = docTextUS.getBuffer();
+    remainingLen=docLen;
+    return (TyErrorId)UIMA_ERR_NONE;
+  }
+
+
+  bool  hasNext() {
+    cout << "SimpleTextSegmenter:hasNext() " << remainingLen << endl;
+
+    if (remainingLen < 1 || remainingTextP==NULL) {
+      hasMore=false;
+    } else {
+      hasMore = true;
+    }
+    return hasMore;
+  }
+
+  /** */
+  CAS &  next() {
+
+    cout << "SimpleTextSegmenter: next()" << endl;
+
+    if (!hasMore) {
+      UIMA_EXC_THROW_NEW(Exception,
+                         UIMA_ERR_USER_ANNOTATOR_COULD_NOT_PROCESS,
+                         UIMA_MSG_ID_EXCON_PROCESSING_CAS,
+                         ErrorMessage(UIMA_MSG_ID_LITERAL_STRING, "There is not next() available."),
+                         ErrorInfo::unrecoverable);
+    }
+
+    UChar * segEndP =  u_strFindFirst(remainingTextP, remainingLen, delimP, delimLen);
+    size_t segLen=remainingLen;
+
+    if (segEndP != NULL) {
+      segLen = segEndP - remainingTextP;
+    }
+
+    //get a CAS from pool.
+    CAS & cas = pAnc->getEmptyCAS();
+
+    //create a sofa for the segment
+    if (segEndP) {
+      UnicodeStringRef segStr(remainingTextP, segLen+delimLen);
+      remainingTextP = segEndP + delimLen;
+      remainingLen = remainingLen-(segLen+delimLen);
+      cas.setDocumentText(segStr.getBuffer(), segStr.length());
+    } else {
+      if (remainingLen > 0) {   //when delim not found, create Sofa with remaining
+        UnicodeStringRef segStr(remainingTextP, remainingLen);
+
+        cas.setDocumentText(segStr.getBuffer(), segStr.length());
+      }
+      remainingLen=0;
+      remainingTextP = NULL;
+    }
+
+    return cas;
+  }
+
+  int  getCasInstancesRequired() {
+    return 1;
+  }
+
+  /** */
+  TyErrorId typeSystemInit(TypeSystem const & crTypeSystem) {
+    cout << " typeSystemInit()" << endl;
+
+    return (TyErrorId)UIMA_ERR_NONE;
+  }
+
+  /** */
+  TyErrorId destroy() {
+    cout << "SimpleTextSegmenter: destroy()" << endl;
+    return (TyErrorId)UIMA_ERR_NONE;
+  }
+};
+
+// This macro exports an entry point that is used to create the annotator.
+
+MAKE_AE(SimpleTextSegmenter);

Propchange: incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.vcproj
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.vcproj?view=auto&rev=503265
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.vcproj (added)
+++ incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.vcproj Sat Feb  3 09:19:12 2007
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="SimpleTextSegmenter"
+	ProjectGUID="{0BC37546-5E6B-4383-9984-EF348B9FB966}"
+	RootNamespace="SimpleTextSegmenter"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(InputDir)\.."
+			IntermediateDirectory="..\Debug\$(ProjectName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".;&quot;$(APR_HOME)\include&quot;;&quot;$(ICU_HOME)\include&quot;;&quot;$(XERCES_HOME)\include&quot;;&quot;$(JAVA_HOME)\include&quot;;&quot;$(JAVA_HOME)\include\win32&quot;;&quot;$(UIMACPP_HOME)\include&quot;;&quot;$(UIMACPP_HOME)\include\apr&quot;"
+				PreprocessorDefinitions="UIMA_SUPPRESS_TIMING;WIN32;_DEBUG;_WINDOWS;_USRDLL"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="icuuc.lib libapr$(APR_VER).lib uimaD.lib"
+				OutputFile="$(OutDir)\lib$(ProjectName).dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;$(APR_HOME)\Debug&quot;;&quot;$(XERCES_HOME)\lib&quot;;&quot;$(ICU_HOME)\lib&quot;;&quot;$(UIMACPP_HOME)\lib&quot;"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+				SubSystem="2"
+				ImportLibrary="$(OutDir)/$(ProjectName).lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(InputDir)\.."
+			IntermediateDirectory="..\Release\$(ProjectName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				AdditionalIncludeDirectories=".;&quot;$(APR_HOME)\include&quot;;&quot;$(ICU_HOME)\include&quot;;&quot;$(XERCES_HOME)\include&quot;;&quot;$(JAVA_HOME)\include&quot;;&quot;$(JAVA_HOME)\include\win32&quot;;&quot;$(UIMACPP_HOME)\include&quot;;&quot;$(UIMACPP_HOME)\include\apr&quot;"
+				PreprocessorDefinitions="UIMA_SUPPRESS_TIMING;TRACEOFF;NDEBUG;WIN32;_WINDOWS;_USRDLL"
+				MinimalRebuild="FALSE"
+				BasicRuntimeChecks="0"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="icuuc.lib libapr$(APR_VER).lib uima.lib"
+				OutputFile="$(OutDir)\lib$(ProjectName).dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;$(APR_HOME)\Release&quot;;&quot;$(XERCES_HOME)\lib&quot;;&quot;$(ICU_HOME)\lib&quot;;&quot;$(UIMACPP_HOME)\lib&quot;"
+				GenerateDebugInformation="FALSE"
+				ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/$(ProjectName).lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath="SimpleTextSegmenter.cpp">
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

Propchange: incubator/uima/uimacpp/trunk/src/test/src/SimpleTextSegmenter.vcproj
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Added: incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.cpp?view=auto&rev=503265
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.cpp (added)
+++ incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.cpp Sat Feb  3 09:19:12 2007
@@ -0,0 +1,256 @@
+/*
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+-----------------------------------------------------------------------------
+
+   \brief  An example implementation of the Sofa Stream Handler APIs
+           defined in uima/sofastreamhandler.hpp
+           to support the file URI scheme
+
+-----------------------------------------------------------------------------
+
+   Description:  This implements a SofaStreamHandler for a file URI scheme.
+     The file to be read is specified as an argument to
+     openStream(char * uriString). uriString is expected to be
+     contain the URI scheme and path to file as follows:
+                   file:myfile
+                   eg: file://C:\myfile.txt  on Windows
+                       file:///home/myid/myfile.txt on UNIX
+
+                 To build the SofaStreamHandlerFile DLL:
+                   On linux:
+                     make -f SofaStreamHandlerFile.mak
+                   On Windows:
+                     devenv SofaStreamHandlerFile.vcproj /build Release
+
+                 The handler dll must be registered with the UIMA framework
+                 by setting an environement variable as follows:
+                   On Linux:
+                     export UIMACPP_STREAMHANDLERS=file:SofaStreamHandlerFile
+                   On Windows:
+                     set UIMACPP_STREAMHANDLERS=file:SofaStreamHandlerFile
+
+-------------------------------------------------------------------------- */
+
+
+
+#include <uima/api.hpp>
+#include <uima/sofastreamhandler.hpp>
+#include <sys/stat.h>
+#if defined(__OS_UNIX__)
+#define LSEEK lseek
+#include <unistd.h>
+#elif defined(__OS_WIN32__)
+#define LSEEK _lseeki64
+#include <io.h>
+#endif
+#include <stdio.h>
+
+
+using namespace uima;
+using namespace std;
+
+
+class SofaStreamHandlerFile : public SofaStreamHandler {
+
+
+private:
+  FILE * stream;
+  char * buffer;
+  INT64 filesize;
+  size_t buflen;
+  INT64 cur_pos ;
+
+public:
+//--------------------------------------------------------------
+// openStream
+// @param - uriString in UTF-8
+//--------------------------------------------------------------
+  void openStream(const char * uriString) {
+    return openStream(uriString,BUFSIZ);
+    ;
+  }
+
+//--------------------------------------------------------------
+// openStreamWithMinInternalBufSize
+// open the file for reading and allocate an internal buffer of at least the
+// specified size.
+// @param - uriString in UTF-8
+//          minimumBufferSize
+//--------------------------------------------------------------
+  void openStream (const char * uriString, size_t minimumBufferSize) {
+    cout << "SofaStreamHandlerFile: openStream() " << uriString << endl;
+    if (strncmp(uriString, "file://", 7) == 0) {
+      buffer = new char[minimumBufferSize];
+      buflen = minimumBufferSize;
+      cur_pos=0;
+      const char * filename = uriString+7;
+      stream = fopen(filename,"rb");
+      if (stream == NULL) {
+        UIMA_EXC_THROW_NEW(Exception,
+                           UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT,
+                           UIMA_MSG_ID_EXCON_CONFIG_VALUE_EXTRACT,
+                           ErrorMessage(UIMA_MSG_ID_LITERAL_STRING, "Invalid value for SegmentDelimiter"),
+                           ErrorInfo::unrecoverable);
+
+      } else  {
+        int rc = setvbuf (stream, buffer, _IOFBF, buflen);
+        if (rc==0) {
+          struct stat fstat;
+          stat(filename, &fstat);
+          filesize = fstat.st_size;
+        }
+      }
+    } else {
+      UIMA_EXC_THROW_NEW(Exception,
+                         UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT,
+                         UIMA_MSG_ID_EXCON_CONFIG_VALUE_EXTRACT,
+                         ErrorMessage(UIMA_MSG_ID_LITERAL_STRING, "Invalid value for SegmentDelimiter"),
+                         ErrorInfo::unrecoverable);
+
+    }
+    return  ;
+  }
+
+//--------------------------------------------------------------
+// getTotalStreamSize
+// @return total size of the data
+//--------------------------------------------------------------
+  INT64 getTotalStreamSize() {
+    return filesize;
+  }
+
+//--------------------------------------------------------------
+// getBufferSize
+// @return buffer length
+//--------------------------------------------------------------
+  size_t getBufferSize() {
+    return buflen;
+  }
+
+//--------------------------------------------------------------
+// howManyAvailable
+// @return number of bytes available for read
+//         -1 indicates EOF
+//--------------------------------------------------------------
+  INT64 howManyAvailable() {
+    if (filesize-cur_pos < 0) return -1;
+    else return (filesize-cur_pos);
+  }
+
+//--------------------------------------------------------------
+// getNext - deliver the specified number of bytes in network
+//           byte order.
+// reads the specified number of bytes from the
+// current position.  Advances the current position
+// by the number of bytes read. This implementation
+// assumes that the data in the file is in network
+// byte order.
+// This call blocks till read request is satisfied or
+// EOF is reached.
+//
+// @param - numBytes, the number of bytes to read
+//        - pBuffer, buffer into which the bytes are to be copied.
+//
+// @returns number of bytes actually copied into buffer.
+//          This may be less than the number of
+//          bytes requested.
+//          -1 indicates EOF.
+//--------------------------------------------------------------
+  INT64 getNext(size_t numBytes,
+                void * pBuffer) {
+    cout << "SofaStreamHandlerFile: getNext() " << numBytes << endl;
+    if (feof(stream)) {
+      return -1;
+    }
+
+    size_t numread = fread(pBuffer,1,numBytes,stream);
+    cur_pos += numread;
+
+    return numread;
+  }
+
+//--------------------------------------------------------------
+// seek
+// sets the position within the current stream.
+// @param - offset - number of bytes from origin
+//        - origin is one of the following (taken from lseek spec):
+//          If SEEK_SET, the position is set to offset bytes.
+//          If SEEK_CUR, the position is  set  to  its
+//              current location plus offset bytes.
+//          If SEEK_END,  the position is set to the total length
+//              plus offset bytes.
+//          These constants are defined in stdio.h
+//
+// @return 0 indicates success
+//--------------------------------------------------------------
+  int  seek (INT64 offset, int origin) {
+
+    if (offset == 0) {
+      cur_pos = fseek(stream, offset, origin );
+      return 0;
+    }
+
+    INT64 remaining = offset;
+    long off = 0;
+
+    while (remaining > 0) {
+      if (remaining > LONG_MAX) {
+        off = LONG_MAX;
+      } else {
+        off = remaining;
+      }
+      remaining = remaining-off;
+      cur_pos = fseek(stream, off, origin );
+    }
+
+    if (cur_pos == -1L)
+      return -3;
+    else return 0 ;
+
+  }
+
+//--------------------------------------------------------------
+// closeStream
+// close the stream. Delete the internal buffer.
+//-------------------------------------------------------------
+  void closeStream() {
+    if (stream != NULL) {
+      fclose(stream);
+      stream=NULL;
+    }
+    if (buffer != NULL)  {
+      delete buffer;
+      buffer=NULL;
+    }
+    return;
+  }
+
+//--------------------------------------------------------------
+// getDataPointer
+// This returns a pointer to the data in memory.
+// @return  NULL.
+//--------------------------------------------------------------
+
+  void *  getDataPointer() {
+    return NULL;
+  }
+};
+
+MAKE_HANDLER(SofaStreamHandlerFile);

Propchange: incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.vcproj
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.vcproj?view=auto&rev=503265
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.vcproj (added)
+++ incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.vcproj Sat Feb  3 09:19:12 2007
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="SofaStreamHandlerFile"
+	ProjectGUID="{0BC37546-5E6B-4383-9984-EF348B9FB966}"
+	RootNamespace="SofaStreamHandlerFile"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(InputDir)\.."
+			IntermediateDirectory="..\Debug\$(ProjectName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".;&quot;$(APR_HOME)\include&quot;;&quot;$(ICU_HOME)\include&quot;;&quot;$(XERCES_HOME)\include&quot;;&quot;$(JAVA_HOME)\include&quot;;&quot;$(JAVA_HOME)\include\win32&quot;;&quot;$(UIMACPP_HOME)\include&quot;;&quot;$(UIMACPP_HOME)\include\apr&quot;"
+				PreprocessorDefinitions="UIMA_SUPPRESS_TIMING;WIN32;_DEBUG;_WINDOWS;_USRDLL"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="icuuc.lib libapr$(APR_VER).lib uimaD.lib"
+				OutputFile="$(OutDir)\$(ProjectName).dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;$(APR_HOME)\Debug&quot;;&quot;$(XERCES_HOME)\lib&quot;;&quot;$(ICU_HOME)\lib&quot;;&quot;$(UIMACPP_HOME)\lib&quot;"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+				SubSystem="2"
+				ImportLibrary="$(OutDir)/$(ProjectName).lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(InputDir)\.."
+			IntermediateDirectory="..\Release\$(ProjectName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				AdditionalIncludeDirectories=".;&quot;$(APR_HOME)\include&quot;;&quot;$(ICU_HOME)\include&quot;;&quot;$(XERCES_HOME)\include&quot;;&quot;$(JAVA_HOME)\include&quot;;&quot;$(JAVA_HOME)\include\win32&quot;;&quot;$(UIMACPP_HOME)\include&quot;;&quot;$(UIMACPP_HOME)\include\apr&quot;"
+				PreprocessorDefinitions="UIMA_SUPPRESS_TIMING;TRACEOFF;NDEBUG;WIN32;_WINDOWS;_USRDLL"
+				MinimalRebuild="FALSE"
+				BasicRuntimeChecks="0"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="icuuc.lib libapr$(APR_VER).lib uima.lib"
+				OutputFile="$(OutDir)\$(ProjectName).dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;$(APR_HOME)\Release&quot;;&quot;$(XERCES_HOME)\lib&quot;;&quot;$(ICU_HOME)\lib&quot;;&quot;$(UIMACPP_HOME)\lib&quot;"
+				GenerateDebugInformation="FALSE"
+				ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/$(ProjectName).lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath="SofaStreamHandlerFile.cpp">
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

Propchange: incubator/uima/uimacpp/trunk/src/test/src/SofaStreamHandlerFile.vcproj
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Added: incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.cpp?view=auto&rev=503265
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.cpp (added)
+++ incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.cpp Sat Feb  3 09:19:12 2007
@@ -0,0 +1,144 @@
+/**************************************************************************/
+/*  Licensed Materials - Property of IBM                                  */
+/*  (C) Copyright IBM Corporation 2003, 2004.                             */
+/*  All rights reserved.                                                  */		
+/*                                                                        */
+/* US Government Users Restricted Rights - Use, duplication or            */
+/* disclosure restricted by GSA ADP Schedule Contract with                */
+/* IBM Corporation.                                                       */
+/**************************************************************************/
+/*  Permission Notice                                                     */
+/*                                                                        */
+/*  Permission is granted to copy, use, modify, and merge this sample     */
+/*  software into your applications and to permit others to do any of the */
+/*  foregoing. You may further distribute this software for               */
+/*  commercial purposes only as part of your application that adds        */
+/*  significant value and function beyond that provided by these          */
+/*  samples.                                                              */
+/*  You must include this permission statement and retain the copyright   */
+/*  notice in all copies and modified versions of this software.          */
+/*                                                                        */
+/**************************************************************************/
+/*                                                                        */
+/*  DISCLAIMER OF WARRANTIES                                              */
+/*                                                                        */
+/*  The sample software is provided to you by IBM to assist you in        */
+/*  developing your applications. THIS SOFTWARE IS PROVIDED AS-IS,        */
+/*  WITHOUT WARRANTY OF ANY KIND. IBM SHALL NOT BE LIABLE FOR ANY         */
+/*  DAMAGES ARISING OUT OF YOUR USE OR THE USE BY ANY THIRD PARTY OF      */
+/*  OF THE SAMPLE SOFTWARE EVEN IF IT HAS BEEN ADVISED OF THE POSSIBILITY */
+/*  OF SUCH DAMAGES. IN ADDITION, IBM SHALL NOT BE LIABLE FOR ANY THIRD   */
+/*  PARTY CLAIMS AGAINST YOU.                                             */
+/*                                                                        */
+/**************************************************************************/
+
+#include "uima/api.hpp"
+
+
+using namespace uima;
+
+ 
+class TextSegmentConsumer : public Annotator {
+private:
+  
+  int numProcessed; 
+  int numSegments;
+
+  
+
+
+public:
+
+  TextSegmentConsumer(void)
+  {
+    cout << "TextSegmentConsumer: Constructor" << endl;
+  }
+
+  ~TextSegmentConsumer(void)
+  {
+    cout << "TextSegmentConsumer: Destructor" << endl;
+  }
+  
+  /** */
+  TyErrorId initialize(AnnotatorContext & rclAnnotatorContext)
+  {
+    cout << "TextSegmentConsumer: initialize()" << endl;
+    numProcessed=0;
+	numSegments=0;
+    if (rclAnnotatorContext.isParameterDefined("TotalNumberOfSegments") &&
+		rclAnnotatorContext.extractValue("TotalNumberOfSegments", numSegments) == UIMA_ERR_NONE)  {
+	    if (numSegments < 1) {
+ 			UIMA_EXC_THROW_NEW(Exception,
+	                  UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT,
+                      UIMA_MSG_ID_EXCON_CONFIG_VALUE_EXTRACT,
+                      ErrorMessage(UIMA_MSG_ID_LITERAL_STRING, "Invalid value for 'TotalNumberOfSegments'"),
+                      ErrorInfo::unrecoverable);
+        }    
+     } else {
+	   numSegments=3;	
+	 }
+	 cout << "TextSegmentConsumer::initialize() .. Total number of segments expected: " 
+	             << numSegments << endl;    	
+    return (TyErrorId)UIMA_ERR_NONE;
+  }
+
+
+  TyErrorId typeSystemInit(TypeSystem const & crTypeSystem) {
+    cout << "TextSegmentConsumer: typeSystemInit()" << endl;
+    return(TyErrorId)UIMA_ERR_NONE;
+  }
+
+  /** */
+  TyErrorId destroy()
+  {
+    cout << "TextSegmentConsumer: destroy()" << endl;
+    return (TyErrorId)UIMA_ERR_NONE;
+  }
+
+  
+  TyErrorId process(CAS & rCAS, const ResultSpecification& spec)
+  {
+   cout << "TextSegmentConsumer: process() begins" << endl;
+
+   if (rCAS.getDocumentText().length() > 0) {
+         cout << "TextSegmentConsumer::process() Got a text segment " << rCAS.getDocumentText() << endl;
+	   numProcessed++;
+   } else {
+	   UIMA_EXC_THROW_NEW(Exception,
+		   UIMA_ERR_USER_ANNOTATOR_COULD_NOT_PROCESS,
+		   UIMA_MSG_ID_EXCON_CONFIG_VALUE_EXTRACT,
+		   ErrorMessage(UIMA_MSG_ID_LITERAL_STRING, "getDocumentText() returned string of zero length."),
+		   ErrorInfo::unrecoverable);
+   }
+
+   cout << "TextSegmentConsumer: process() ends" << endl;
+   return (TyErrorId)UIMA_ERR_NONE;
+  }
+
+  TyErrorId batchProcessComplete()
+  {
+  cout << "TextSegmentConsumer: batchProcessComplete()" << endl;
+  return (TyErrorId)UIMA_ERR_NONE;
+  }
+
+  TyErrorId collectionProcessComplete()
+  {
+  cout << "TextSegmentConsumer: collectionProcessComplete() num processed: " << numProcessed << endl;
+
+  if (numProcessed != numSegments) {
+	  UIMA_EXC_THROW_NEW(Exception,
+		   UIMA_ERR_USER_ANNOTATOR_COULD_NOT_PROCESS,
+		   UIMA_MSG_ID_EXCON_CONFIG_VALUE_EXTRACT,
+		   ErrorMessage(UIMA_MSG_ID_LITERAL_STRING, "getDocumentText() returned string of zero length."),
+		   ErrorInfo::unrecoverable);
+  }
+  
+  return (TyErrorId)UIMA_ERR_NONE;
+  }
+
+
+};
+
+// This macro exports an entry point that is used to create the annotator.
+
+MAKE_AE(TextSegmentConsumer);

Propchange: incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.vcproj
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.vcproj?view=auto&rev=503265
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.vcproj (added)
+++ incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.vcproj Sat Feb  3 09:19:12 2007
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="TextSegmentConsumer"
+	ProjectGUID="{0BC37546-5E6B-4383-9984-EF348B9FB966}"
+	RootNamespace="TextSegmentConsumer"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(InputDir)\.."
+			IntermediateDirectory="..\Debug\$(ProjectName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories=".;&quot;$(APR_HOME)\include&quot;;&quot;$(ICU_HOME)\include&quot;;&quot;$(XERCES_HOME)\include&quot;;&quot;$(JAVA_HOME)\include&quot;;&quot;$(JAVA_HOME)\include\win32&quot;;&quot;$(UIMACPP_HOME)\include&quot;;&quot;$(UIMACPP_HOME)\include\apr&quot;"
+				PreprocessorDefinitions="UIMA_SUPPRESS_TIMING;WIN32;_DEBUG;_WINDOWS;_USRDLL"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="icuuc.lib libapr$(APR_VER).lib uimaD.lib"
+				OutputFile="$(OutDir)\lib$(ProjectName).dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;$(APR_HOME)\Debug&quot;;&quot;$(XERCES_HOME)\lib&quot;;&quot;$(ICU_HOME)\lib&quot;;&quot;$(UIMACPP_HOME)\lib&quot;"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+				SubSystem="2"
+				ImportLibrary="$(OutDir)/$(ProjectName).lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(InputDir)\.."
+			IntermediateDirectory="..\Release\$(ProjectName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				AdditionalIncludeDirectories=".;&quot;$(APR_HOME)\include&quot;;&quot;$(ICU_HOME)\include&quot;;&quot;$(XERCES_HOME)\include&quot;;&quot;$(JAVA_HOME)\include&quot;;&quot;$(JAVA_HOME)\include\win32&quot;;&quot;$(UIMACPP_HOME)\include&quot;;&quot;$(UIMACPP_HOME)\include\apr&quot;"
+				PreprocessorDefinitions="UIMA_SUPPRESS_TIMING;TRACEOFF;NDEBUG;WIN32;_WINDOWS;_USRDLL"
+				MinimalRebuild="FALSE"
+				BasicRuntimeChecks="0"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="icuuc.lib libapr$(APR_VER).lib uima.lib"
+				OutputFile="$(OutDir)\lib$(ProjectName).dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;$(APR_HOME)\Release&quot;;&quot;$(XERCES_HOME)\lib&quot;;&quot;$(ICU_HOME)\lib&quot;;&quot;$(UIMACPP_HOME)\lib&quot;"
+				GenerateDebugInformation="FALSE"
+				ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/$(ProjectName).lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath="TextSegmentConsumer.cpp">
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

Propchange: incubator/uima/uimacpp/trunk/src/test/src/TextSegmentConsumer.vcproj
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Added: incubator/uima/uimacpp/trunk/src/test/src/annotator_dump.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/annotator_dump.cpp?view=auto&rev=503265
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/annotator_dump.cpp (added)
+++ incubator/uima/uimacpp/trunk/src/test/src/annotator_dump.cpp Sat Feb  3 09:19:12 2007
@@ -0,0 +1,350 @@
+/** \file filename annotator_dump.cpp
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+-------------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Include dependencies                                              */
+/* ----------------------------------------------------------------------- */
+
+// this is included ONCE for the main source file of each binary
+#include "uima/pragmas.hpp"
+#include "uima/annotator_dump.hpp"
+#include "uima/xmlwriter.hpp"
+
+#include <iostream>
+#include <algorithm>
+#ifdef _MSC_VER
+#include <minmax.h> // for min
+#endif
+using namespace std;
+
+#include "uima/assertmsg.h"
+#include "uima/macros.h"
+#include "uima/trace.hpp"
+
+#include "uima/strconvert.hpp"
+//#include "uima/fixed_vector.hpp"
+
+//config parameter names
+/* ----------------------------------------------------------------------- */
+/*           Constants                                                     */
+/* ----------------------------------------------------------------------- */
+
+#define ANNOTATOR_DUMP_PARAM_OUTFILE          _TEXT("OutputFile")
+#define ANNOTATOR_DUMP_PARAM_APPEND           _TEXT("AppendFile")
+#define ANNOTATOR_DUMP_PARAM_DUMP_DOCBUFFER   _TEXT("DumpDocBuffer")
+#define ANNOTATOR_DUMP_PARAM_SAVE_DOCBUFFER   _TEXT("SaveDocBuffer")
+#define ANNOTATOR_DUMP_PARAM_STYLE            _TEXT("OutputStyle")
+#define ANNOTATOR_DUMP_OUTPUT_TYPES           _TEXT("OutputTypes")
+
+//error codes
+
+const int ANNOTATOR_DUMP_ERROR_OFFSET           = 100;
+const int ANNOTATOR_DUMP_ERROR_OPEN             = (0 + ANNOTATOR_DUMP_ERROR_OFFSET);
+const int ANNOTATOR_DUMP_ERROR_AT               = (1 + ANNOTATOR_DUMP_ERROR_OFFSET);
+
+const int ANNOTATOR_DUMP_WARN_OFFSET            = 200;
+const int ANNOTATOR_DUMP_WARN_TET               = (0 + ANNOTATOR_DUMP_WARN_OFFSET);
+
+const int ANNOTATOR_DUMP_MSG_OFFSET             = 300;
+const int ANNOTATOR_DUMP_MSG_STYLE              = (0 + ANNOTATOR_DUMP_MSG_OFFSET);
+const int ANNOTATOR_DUMP_MSG_TYPES              = (1 + ANNOTATOR_DUMP_MSG_OFFSET);
+
+/* ----------------------------------------------------------------------- */
+/*       Implementation                                                    */
+/* ----------------------------------------------------------------------- */
+
+// Default Constructor
+
+AnnotatorDump::AnnotatorDump(void) :
+    iv_clOutputStream() {}
+
+AnnotatorDump::~AnnotatorDump(void) {
+  ;
+}
+
+TyErrorId
+AnnotatorDump::initialize(
+  AnnotatorContext & rclAnnotatorContext) {
+  TyErrorId                  tyErrId;
+  string                     strFileName;
+  int                     uiOutputStyle;
+
+
+  // Default Values
+
+  // in append mode all data in a session/collection is dumped into one file
+  // otherwise the same dump file is deleted and rewritten for each document
+  // in the session/collection
+  // default is false
+  iv_bAppendFile = false;
+
+  // we don't dump the Document Buffer
+  iv_bDumpDocBuffer = false;
+  iv_bSaveDocBuffer = false;
+
+  // the representation will be in Xml-Format
+  iv_enOutputStyle = Xml;
+
+  // Reading the Values from the Config-Section
+
+  //Filename for the Output-Stream
+  icu::UnicodeString us;
+  tyErrId = rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_PARAM_OUTFILE, us);
+
+  // Convert filename to default encoding
+  UnicodeStringRef usr(us);
+  usr.extract(strFileName);
+
+  if (tyErrId != UIMA_ERR_NONE) {
+    getAnnotatorContext().getLogger().logError(
+      _TEXT("Required option '" ANNOTATOR_DUMP_PARAM_OUTFILE "' not found"),
+      (long)ANNOTATOR_DUMP_ERROR_OPEN);
+    return(UIMA_ERR_USER_ANNOTATOR_CONFIG_INVALID_PARAM);
+  }
+
+  iv_clOutputFilename = strFileName.c_str();
+  (void) rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_PARAM_DUMP_DOCBUFFER, iv_bDumpDocBuffer);
+  (void) rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_PARAM_SAVE_DOCBUFFER, iv_bSaveDocBuffer);
+  (void) rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_PARAM_APPEND, iv_bAppendFile);
+
+  // in append mode all data in a session/collection is dumped into one file
+  // otherwise the same dump file is deleted and rewritten for each document
+  // in the session/collection
+  if (iv_bAppendFile) {
+    tyErrId = openOutputFile();
+    if (tyErrId != UIMA_ERR_NONE) {
+      return tyErrId;
+    }
+  }
+
+  //Output Style
+  uiOutputStyle = 0;
+  tyErrId = rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_PARAM_STYLE,  uiOutputStyle);
+  if (tyErrId != UIMA_ERR_CONFIG_OPTION_NOT_FOUND) {
+    switch (uiOutputStyle) {
+    case 0:
+      iv_enOutputStyle = Xml;
+      break;
+    case 1:
+      iv_enOutputStyle = XCas;
+      break;
+    default:
+      getAnnotatorContext().getLogger().logWarning(
+        "Invalid Output Style. Use Default",
+        (long) ANNOTATOR_DUMP_MSG_STYLE);
+      break;
+    }
+  }
+
+  /*
+     int iDummy;
+     if (   rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_OUTPUT_TYPES, iDummy)){
+       getAnnotatorContext().getLogger().logWarning((long) ANNOTATOR_DUMP_MSG_TYPES,
+         _TEXT("Specification of output types currently not suported. All types will be dumped."));
+     }
+  */
+
+  // Test getting a multi-valued parameter
+
+  vector<string*> vecOutputTypes;
+  tyErrId = rclAnnotatorContext.extractValue(ANNOTATOR_DUMP_OUTPUT_TYPES,  vecOutputTypes);
+  if (tyErrId != UIMA_ERR_CONFIG_OPTION_NOT_FOUND) {
+    size_t i, len = 0;
+    for (i=0; i<vecOutputTypes.size(); ++i) {
+      string * rString = vecOutputTypes[i];
+      len += rString->length();
+    }
+    cout << "  parameter OutputTypes has "<<i<<" values with a total of "<<len<<" characters." << endl;
+    // Release contents of vector allocated by extractValue in case library uses a different heap.
+    rclAnnotatorContext.release(vecOutputTypes);
+  }
+
+  // Release string buffer allocated by library in case it uses a different heap.
+  usr.release(strFileName);
+
+  return(TyErrorId)UIMA_ERR_NONE;
+}
+
+
+TyErrorId AnnotatorDump::typeSystemInit(uima::TypeSystem const & typeSystem) {
+
+  // Test that can get all types in a vector
+  std::vector<Type> allTypes;
+  typeSystem.getAllTypes(allTypes);
+  cout << "  typeSystem has " << allTypes.size() << " types -" << endl << "      from '"
+  << allTypes[0].getName() << "' to '" << allTypes[allTypes.size()-1].getName() << "'" << endl;
+  typeSystem.release(allTypes);                // Release storage allocated from library's heap
+
+  std::vector<Feature> allFeats;
+  typeSystem.getAllFeatures(allFeats);
+  cout << "  typeSystem has " << allFeats.size() << " features -" << endl << "      from '"
+  << allFeats[0].getName() << "' to '" << allFeats[allFeats.size()-1].getName() << "'" << endl;
+  typeSystem.release(allFeats);                // Release storage allocated from library's heap
+
+  return UIMA_ERR_NONE;
+}
+
+
+TyErrorId
+AnnotatorDump::openOutputFile( void ) {
+  iv_clOutputStream.open(iv_clOutputFilename.getAsCString());     //overwrite
+
+  if (iv_clOutputStream.good()) {
+    return UIMA_ERR_NONE;
+  }
+  getAnnotatorContext().getLogger().logError(
+    string("Failed to open Output File ")+ iv_clOutputFilename.getAsCString(),
+    (long) ANNOTATOR_DUMP_ERROR_OPEN);
+  return(UIMA_ERR_USER_ANNOTATOR_IO_WRITE_PROBLEM);
+}
+
+void
+AnnotatorDump::closeOutputFile( void ) {
+  iv_clOutputStream.close();
+}
+
+TyErrorId
+AnnotatorDump::destroy(
+) {
+  if (iv_bAppendFile) {
+    closeOutputFile();
+  }
+
+  return(TyErrorId)UIMA_ERR_NONE;
+}
+
+TyErrorId
+AnnotatorDump::reconfigure(
+) {
+  return(TyErrorId)UIMA_ERR_NONE;
+}
+
+TyErrorId
+AnnotatorDump::process(CAS & tcas,
+                       const ResultSpecification &
+                      ) {
+  TyErrorId tyErrId;
+
+  // in append mode all data in a session/collection is dumped into one file
+  // otherwise the same dump file is deleted and rewritten for each document
+  // in the session/collection
+  if (!iv_bAppendFile) {
+    tyErrId = openOutputFile();
+    if (tyErrId != UIMA_ERR_NONE) {
+      return tyErrId;
+    }
+  }
+
+  assert(iv_clOutputStream.good());
+
+  if (iv_bDumpDocBuffer) {
+    //    Dumping the Document Buffer
+    UnicodeStringRef doc = tcas.getDocumentText();
+
+    outputDocBuffer(doc);
+  }
+
+  uima::CASWriterABase * writer = NULL;
+  switch (iv_enOutputStyle) {
+  case Xml:
+    writer = new uima::XMLDumpWriter(tcas, iv_bDumpDocBuffer);
+    break;
+  case XCas:
+    writer = new uima::XCASWriter(tcas, iv_bDumpDocBuffer);
+    break;
+  default:
+    assert(false);
+  }
+  assert( EXISTS(writer) );
+  auto_ptr<CASWriterABase> apWriter( writer );
+  apWriter->write(iv_clOutputStream);
+
+  // in append mode all data in a session/collection is dumped into one file
+  // otherwise the same dump file is deleted and rewritten for each document
+  // in the session/collection
+  if (!iv_bAppendFile) {
+    closeOutputFile();
+  }
+
+  return(TyErrorId)UIMA_ERR_NONE;
+}
+
+void AnnotatorDump::outputDocBuffer(UnicodeStringRef const & crclDoc) {
+  assert(crclDoc.length() > 0);
+  uima::util::Filename        clFilename(iv_clOutputFilename);
+  ofstream                   clOutStream;
+  TyDocIndex                 tyIndexFirst = 0;
+  TyDocIndex                 tyIndexLast = crclDoc.length() - 1;
+
+  clFilename.setNewExtension(_TEXT(".asc"));
+  if (iv_bAppendFile) {
+    clOutStream.open(clFilename.getAsCString(), ios::out | ios::app);   //append (create, resp.)
+  } else {
+    clOutStream.open(clFilename.getAsCString());    //overwrite
+  }
+
+  if (iv_clOutputStream.good()) {
+    clOutStream << "Document Buffer Status:" << endl
+    << "=======================" << endl;
+
+    clOutStream << endl
+    << "Document buffer length...........: " << crclDoc.length() << endl
+    << "Document buffer size in memory...: " << (crclDoc.length() * sizeof(UChar)) << endl
+    << "Document buffer index first......: " << tyIndexFirst << endl
+    << "Document buffer index last.......: " << tyIndexLast << endl;
+
+    clOutStream << endl
+    << "Document Buffer Dump:" << endl
+    << "=====================" << endl;
+    assertWithMsg(sizeof(WORD16) == sizeof(UChar), "Port required");
+    DUMPHEX(clOutStream, (WORD16 const *)crclDoc.getBuffer(), crclDoc.length());
+    clOutStream << endl;
+  }
+  if (iv_bSaveDocBuffer) {
+    ofstream                clOutStream;
+
+    clFilename.setNewExtension(_TEXT(".ucs"));
+
+    clOutStream.open(clFilename.getAsCString(), ios::binary);   //overwrite
+    /** include byte-order-mark ??
+       clOutStream << CosClConverterABase::getUCS2HostEndianId();
+    **/
+    clOutStream.write((const char *) crclDoc.getBuffer(), (crclDoc.length() * sizeof(UChar)));
+  }
+}
+
+
+/* ----------------------------------------------------------------------- */
+/*   Mapping for generic C API wrapper                                     */
+/* ----------------------------------------------------------------------- */
+
+typedef AnnotatorDump UserDefinedAnnotator;
+// define for error/exception info in annotator_generic.inl
+#define UIMA_ANNOTATOR_NAME "annotator_dump"
+
+/* ----------------------------------------------------------------------- */
+/*   Include generic C API wrapper                                         */
+/* ----------------------------------------------------------------------- */
+
+#include "uima/annotator_generic.inl"
+
+/* <EOF> */
+

Propchange: incubator/uima/uimacpp/trunk/src/test/src/annotator_dump.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/test/src/annotator_tok.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/annotator_tok.cpp?view=auto&rev=503265
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/annotator_tok.cpp (added)
+++ incubator/uima/uimacpp/trunk/src/test/src/annotator_tok.cpp Sat Feb  3 09:19:12 2007
@@ -0,0 +1,465 @@
+/**
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+-----------------------------------------------------------------------------
+
+   Description: A Unicode UIMA Tokenizer Annotator.
+
+-------------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Include dependencies                                              */
+/* ----------------------------------------------------------------------- */
+
+// this is included ONCE for the main source file of each binary
+#include "uima/annotator_tok.hpp"
+#include "uima/ss_tokenizer.hpp"               // sentsep for Uima
+#include "uima/tt_types.hpp"
+
+#include "uima/assertmsg.h"
+#include "uima/macros.h"
+#include "uima/trace.hpp"
+#include "uima/comp_ids.h"                             /* for trace */
+
+/* ----------------------------------------------------------------------- */
+/*       Globals                                                           */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Config values                                                     */
+/* ----------------------------------------------------------------------- */
+
+// Const table with all the option we access in the config file
+// The sequence of entries herer must match the enum EnAnnotatorConfigOptions
+// in the hpp file.
+const ConfigOptionInfo::StOptionInfo
+AnnotatorTokenizer::cv_astConfigOptionInfo[] = {
+      {
+        "TokenNumbersIncludeStopwords",              //cpszOptionName
+        ConfigOptionInfo::enValueType_Boolean,  //enValueType
+        false,                                       //bOptionIsMultiValued
+        0,                                           //uiNbrOfValuesRequired
+        "true",                                      //cpszDefaultValueAsString
+        "If true token numbers are counted including stopwords"    //cpszComment
+      },
+      {
+        "UseRelativeTokenAndSentenceNumbers",        //cpszOptionName
+        ConfigOptionInfo::enValueType_Boolean,  //enValueType
+        false,                                       //bOptionIsMultiValued
+        0,                                           //uiNbrOfValuesRequired
+        "false",                                     //cpszDefaultValueAsString
+        "If true token and sentence numbers are reset to 1 for each new sentence/paragraph"    //cpszComment
+      },
+      {
+        "IgnorePunctuationTokens",                   //cpszOptionName
+        ConfigOptionInfo::enValueType_Boolean,  //enValueType
+        false,                                       //bOptionIsMultiValued
+        0,                                           //uiNbrOfValuesRequired
+        "false",                                     //cpszDefaultValueAsString
+        "If true, punctuation tokens are ignored"    //cpszComment
+      }
+    };
+
+/* ----------------------------------------------------------------------- */
+/*       Implementation                                                    */
+/* ----------------------------------------------------------------------- */
+
+/** Default Constructor.
+*/
+AnnotatorTokenizer::AnnotatorTokenizer(void) :
+    iv_uiParagraphStartIndex(0),
+    iv_uiSentenceStartIndex(0),
+    iv_uiTokenNbr(0),
+    iv_uiSentenceNbr(0),
+    iv_uiParagraphNbr(0),
+    iv_cuiCOUNTER_START(1),
+    iv_bTokenNumbersIncludeStopwords(true),
+    iv_bUseRelativeTokenAndSentenceNumbers(false),
+    iv_bIgnorePunctuationTokens(false),
+    iv_iTraceCompID(UIMA_TRACE_COMPID_ANNOTATOR_DEFAULT),
+    iv_pCASImpl(NULL),
+    iv_pFSHeap(NULL),
+    iv_tyTokenType(0),
+    iv_tyTokenTypeSize(0),
+    iv_tySentenceType(0),
+    iv_tySentenceTypeSize(0),
+    iv_tyParagraphType(0),
+    iv_tyParagraphTypeSize(0),
+    iv_tySofaFeatureOffset(0),
+    iv_tyBeginPositionFeatureOffset(0),
+    iv_tyEndPositionFeatureOffset(0),
+    iv_tyTokenNbrFeatureOffset(0),
+    iv_tySentenceNbrFeatureOffset(0),
+    iv_tyParagraphNbrFeatureOffset(0),
+    iv_stemFeature(0),
+    iv_bIsTokenReq(false),
+    iv_bIsSentenceReq(false),
+    iv_bIsParagraphReq(false),
+    iv_stemsRequired(false)
+#ifdef DEBUG_TIMING
+    ,
+    iv_clTotalTimer(),
+    iv_clSSTokTimer(),
+    iv_clUimaAnCreateTimer(),
+    iv_clUimaAnSetValTimer()
+#endif
+ {}
+
+    AnnotatorTokenizer::~AnnotatorTokenizer(void) {
+  util::Trace clTrace(util::enTraceDetailLow, UIMA_TRACE_ORIGIN, iv_iTraceCompID);
+  // set pointer to NULL to make clear this object did not own them
+  iv_pFSHeap                 = NULL;
+}
+
+TyErrorId
+AnnotatorTokenizer::getConfigValues(AnnotatorContext & rANC) {
+  // this must be done before any trace call
+  iv_iTraceCompID = rANC.getTraceCompId();
+
+  util::Trace clTrace(util::enTraceDetailLow, UIMA_TRACE_ORIGIN, iv_iTraceCompID);
+
+  // make sure we have an entry in our config value table for each enum
+  assert(NUMBEROF(cv_astConfigOptionInfo) == enNumberOfConfigOptions);
+
+  TyErrorId utErrID;
+
+  // Get Option: token numbers are counted including stopwords?
+  utErrID = extractConfigOptionBoolean(
+              rANC,
+              cv_astConfigOptionInfo[enConfigOption_TokenNumbersIncludeStopwords],
+              iv_bTokenNumbersIncludeStopwords
+            );
+  if (utErrID != UIMA_ERR_NONE) {
+    return utErrID;
+  }
+
+  // Get Option: token and sentence number are reset to 1 for each new sentence/paragraph
+  utErrID = extractConfigOptionBoolean(
+              rANC,
+              cv_astConfigOptionInfo[enConfigOption_UseRelativeTokenAndSentenceNumbers],
+              iv_bUseRelativeTokenAndSentenceNumbers
+            );
+  if (utErrID != UIMA_ERR_NONE) {
+    return utErrID;
+  }
+
+  // Get Option:  If true, punctuation tokens are ignored
+  utErrID = extractConfigOptionBoolean(
+              rANC,
+              cv_astConfigOptionInfo[enConfigOption_IgnorePunctuationTokens],
+              iv_bIgnorePunctuationTokens
+            );
+  if (utErrID != UIMA_ERR_NONE) {
+    return utErrID;
+  }
+
+  return UIMA_ERR_NONE;
+}
+
+TyErrorId
+AnnotatorTokenizer::initialize(
+  AnnotatorContext & rclAnnotatorContext
+) {
+  util::Trace clTrace(util::enTraceDetailLow, UIMA_TRACE_ORIGIN, iv_iTraceCompID);
+  return UIMA_ERR_NONE;
+}
+
+TyErrorId AnnotatorTokenizer::typeSystemInit(TypeSystem const & typeSystem) {
+
+  if (getConfigValues(getAnnotatorContext()) != UIMA_ERR_NONE) {
+    return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
+  }
+
+  lowlevel::TypeSystem const & crTypeSystem = uima::lowlevel::TypeSystem::promoteTypeSystem(typeSystem);
+
+  iv_tyTokenType = crTypeSystem.getTypeByName( TT::TYPE_NAME_TOKEN_ANNOTATION );
+  iv_tySentenceType = crTypeSystem.getTypeByName( TT::TYPE_NAME_SENTENCE_ANNOTATION );
+  iv_tyParagraphType = crTypeSystem.getTypeByName( TT::TYPE_NAME_PARAGRAPH_ANNOTATION );
+  iv_tySentenceTypeSize = crTypeSystem.getFeatureNumber( iv_tySentenceType );
+  iv_tyParagraphTypeSize = crTypeSystem.getFeatureNumber( iv_tyParagraphType );
+  iv_tyTokenTypeSize = crTypeSystem.getFeatureNumber( iv_tyTokenType );
+  iv_tySofaFeatureOffset = crTypeSystem.getFeatureOffset( uima::internal::gs_tySofaRefFeature );
+  iv_tyBeginPositionFeatureOffset = crTypeSystem.getFeatureOffset( uima::internal::gs_tyBeginPosFeature );
+  iv_tyEndPositionFeatureOffset = crTypeSystem.getFeatureOffset( uima::internal::gs_tyEndPosFeature );
+  iv_tyTokenPropertiesFeatureOffset = crTypeSystem.getFeatureOffset( crTypeSystem.getFeatureByBaseName( iv_tyTokenType, TT::FEATURE_BASE_NAME_TOKEN_PROPERTIES ) );
+  iv_tyTokenNbrFeatureOffset = crTypeSystem.getFeatureOffset( crTypeSystem.getFeatureByBaseName( iv_tyTokenType, TT::FEATURE_BASE_NAME_TOKEN_NUMBER ) );
+  iv_tySentenceNbrFeatureOffset = crTypeSystem.getFeatureOffset( crTypeSystem.getFeatureByBaseName( iv_tySentenceType, TT::FEATURE_BASE_NAME_SENTENCE_NUMBER ) );
+  iv_tyParagraphNbrFeatureOffset = crTypeSystem.getFeatureOffset( crTypeSystem.getFeatureByBaseName( iv_tyParagraphType, TT::FEATURE_BASE_NAME_PARAGRAPH_NUMBER ) );
+  iv_stemFeature = crTypeSystem.getFeatureByBaseName( iv_tyTokenType, "stem");
+  return (TyErrorId)UIMA_ERR_NONE;
+}
+
+/** call the UIMA Annotator to deinitialize itself based on a UIMA engine
+    and return a UIMA error code */
+TyErrorId
+AnnotatorTokenizer::destroy() {
+  util::Trace  clTrace(util::enTraceDetailLow, UIMA_TRACE_ORIGIN, iv_iTraceCompID);
+
+#if defined(DEBUG_TIMING)
+  dumpTimingData();
+#endif
+
+  resetCharClasses();
+
+  return (TyErrorId)UIMA_ERR_NONE;
+}
+
+#if defined(DEBUG_TIMING)
+void AnnotatorTokenizer::dumpTimingData( void ) const {
+  cout << "----------------------------------------------------------------" << endl;
+  cout << " AnnotatorTokenizer: " << endl;
+  cout << " total amount of time:" << iv_clTotalTimer.timeString() << endl;
+  ;
+  cout << "   Sentsep        :  " << (iv_clSSTokTimer-iv_clUimaAnCreateTimer-iv_clUimaAnSetValTimer).timeAndPercentString(iv_clTotalTimer) << endl;
+  ;
+  cout << "   Create ANs     :  " << iv_clUimaAnCreateTimer.timeAndPercentString(iv_clTotalTimer) << endl;
+  ;
+  cout << "   Set AN Values  :  " << iv_clUimaAnSetValTimer.timeAndPercentString(iv_clTotalTimer) << endl;
+  ;
+  cout << "----------------------------------------------------------------" << endl;
+}
+#endif
+
+/** call the UIMA Annotator to reconfigure itself based on a UIMA Configuration
+    section and return a UIMA error code */
+TyErrorId
+AnnotatorTokenizer::reconfigure(
+) {
+  util::Trace  clTrace(util::enTraceDetailLow, UIMA_TRACE_ORIGIN, iv_iTraceCompID);
+  resetCharClasses();
+  if (getConfigValues(getAnnotatorContext()) != UIMA_ERR_NONE) {
+    return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
+  }
+  return (TyErrorId)UIMA_ERR_NONE;
+}
+
+inline void
+AnnotatorTokenizer::addNewTokenAnnotation(
+  TyDocIndex           tyBeginPos,
+  TyDocIndex           tyEndPos
+) {
+  // If we should filter punctuation chars (in TSE mode we have to do that!)
+  if (    iv_bIgnorePunctuationTokens
+          && (tyEndPos == tyBeginPos+1) // length == 1
+          && iv_clTokenProperties.hasSpecial()
+     ) {
+    return;
+  }
+
+  // Create new Annotation of type Token
+  lowlevel::TyFS tyNewToken = iv_pFSHeap->createFSWithSize( iv_tyTokenType, iv_tyTokenTypeSize );
+
+  // Set the TokenNumber Attribute for the new Token Annotation
+  iv_pFSHeap->setFeatureWithOffset( tyNewToken, iv_tySofaFeatureOffset, lowlevel::FSHeap::getAsFS((int) iv_pCASImpl->getSofaNum()) );
+  iv_pFSHeap->setFeatureWithOffset( tyNewToken, iv_tyBeginPositionFeatureOffset, lowlevel::FSHeap::getAsFS((int) tyBeginPos) );
+  iv_pFSHeap->setFeatureWithOffset( tyNewToken, iv_tyEndPositionFeatureOffset, lowlevel::FSHeap::getAsFS((int) tyEndPos) );
+  iv_pFSHeap->setFeatureWithOffset( tyNewToken, iv_tyTokenNbrFeatureOffset, lowlevel::FSHeap::getAsFS( (int) iv_uiTokenNbr) );
+
+  unsigned long ulTokProp = iv_clTokenProperties.to_ulong();
+// **why this?**    assert( sizeof(unsigned long) <= sizeof(lowlevel::TyFS) );
+  iv_pFSHeap->setFeatureWithOffset( tyNewToken, iv_tyTokenPropertiesFeatureOffset, (lowlevel::TyFS) ulTokProp);
+
+  // add to index
+  iv_pIndexRepository->add(tyNewToken);
+  ++iv_uiTokenNbr;
+}
+
+inline void
+AnnotatorTokenizer::addNewSentenceAnnotation(
+  TyDocIndex           tyBeginPos,
+  TyDocIndex           tyEndPos
+) {
+  if (   (!iv_bIsSentenceReq)
+         || (tyEndPos == tyBeginPos+1) // length == 1
+     ) {
+    return;
+  }
+
+  // Create new Annotation of type Sentence
+  lowlevel::TyFS tyNewSentence = iv_pFSHeap->createFSWithSize( iv_tySentenceType, iv_tySentenceTypeSize );
+
+  // Set the SentenceNumber Attribute for the new Sentence Annotation
+  iv_pFSHeap->setFeatureWithOffset( tyNewSentence, iv_tySofaFeatureOffset, lowlevel::FSHeap::getAsFS((int) iv_pCASImpl->getSofaNum()) );
+  iv_pFSHeap->setFeatureWithOffset( tyNewSentence, iv_tyBeginPositionFeatureOffset, lowlevel::FSHeap::getAsFS((int)tyBeginPos) );
+  iv_pFSHeap->setFeatureWithOffset( tyNewSentence, iv_tyEndPositionFeatureOffset, lowlevel::FSHeap::getAsFS((int)tyEndPos) );
+  iv_pFSHeap->setFeatureWithOffset( tyNewSentence, iv_tySentenceNbrFeatureOffset, lowlevel::FSHeap::getAsFS( (int) iv_uiSentenceNbr) );
+
+  // add to index
+  iv_pIndexRepository->add(tyNewSentence);
+}
+
+inline void
+AnnotatorTokenizer::addNewParagraphAnnotation(
+  TyDocIndex           tyBeginPos,
+  TyDocIndex           tyEndPos
+) {
+  if (   (!iv_bIsParagraphReq)
+         || (tyEndPos == tyBeginPos+1) // length == 1
+     ) {
+    return;
+  }
+  // Create new Annotation of type Paragrah
+  lowlevel::TyFS tyNewParagraph = iv_pFSHeap->createFSWithSize( iv_tyParagraphType, iv_tyParagraphTypeSize );
+
+  // Set the ParagraphNumber Attribute for the new Paragraph Annotation
+  iv_pFSHeap->setFeatureWithOffset( tyNewParagraph, iv_tySofaFeatureOffset, lowlevel::FSHeap::getAsFS((int) iv_pCASImpl->getSofaNum()) );
+  iv_pFSHeap->setFeatureWithOffset( tyNewParagraph, iv_tyBeginPositionFeatureOffset, lowlevel::FSHeap::getAsFS((int)tyBeginPos) );
+  iv_pFSHeap->setFeatureWithOffset( tyNewParagraph, iv_tyEndPositionFeatureOffset, lowlevel::FSHeap::getAsFS((int)tyEndPos) );
+  iv_pFSHeap->setFeatureWithOffset( tyNewParagraph, iv_tyParagraphNbrFeatureOffset, lowlevel::FSHeap::getAsFS( (int) iv_uiParagraphNbr) );
+
+  // add to index
+  iv_pIndexRepository->add(tyNewParagraph);
+}
+
+int AnnotatorTokenizer::tokenCallback(
+  unsigned long location,
+  unsigned long length,
+  TokenProperties & rclTokenProperties,
+  bool bNewPara,
+  bool bNewSent
+) {
+  // compute begin and end index of new token
+  TyDocIndex uiTokenStartIndex = (TyDocIndex) location;
+  TyDocIndex uiTokenEndIndex   = uiTokenStartIndex + (TyDocIndex) (length);
+  iv_clTokenProperties = rclTokenProperties;
+
+  if ( (bNewPara || bNewSent) &&  iv_bIsSentenceReq) {
+
+    // new paragaph means no explicit new sentence - end current sentence anyway
+    addNewSentenceAnnotation(iv_uiSentenceStartIndex, uiTokenStartIndex );
+
+    // new sentence starts at beginning of current word
+    iv_uiSentenceStartIndex = uiTokenStartIndex;
+    ++iv_uiSentenceNbr;
+
+    // reset token number
+    if (iv_bUseRelativeTokenAndSentenceNumbers) {
+      iv_uiTokenNbr = iv_cuiCOUNTER_START;
+    }
+  }
+
+  // new paragraph started
+  if ( bNewPara && iv_bIsParagraphReq) {
+
+    // new paragraph is from StartParagraphIndex to EndLastWordIndex
+    addNewParagraphAnnotation(iv_uiParagraphStartIndex, uiTokenStartIndex );
+
+    // new start of paragraph is at beginning of current word
+    iv_uiParagraphStartIndex = uiTokenStartIndex;
+    ++iv_uiParagraphNbr;
+
+    // reset sentence number
+    if (iv_bUseRelativeTokenAndSentenceNumbers) {
+      iv_uiSentenceNbr = iv_cuiCOUNTER_START;
+      assert( iv_uiTokenNbr == iv_cuiCOUNTER_START );
+    }
+  }
+
+  // finally, mark new token
+  addNewTokenAnnotation(uiTokenStartIndex, uiTokenEndIndex );
+
+  return 0;
+}
+
+/** call the UIMA Annotator to perform its duty based on a UIMA engine
+    and return a UIMA error code */
+TyErrorId
+AnnotatorTokenizer::process(
+  CAS & tcas,
+  const ResultSpecification & crclTargetSet
+) {
+  util::Trace                  clTrace(util::enTraceDetailMedium, UIMA_TRACE_ORIGIN, iv_iTraceCompID);
+
+  iv_pCASImpl = & uima::internal::CASImpl::promoteCAS(tcas);
+  iv_pFSHeap = & iv_pCASImpl->getHeap();
+  iv_pIndexRepository = & iv_pCASImpl->getIndexRepository();
+
+
+  UIMA_TIMING(iv_clTotalTimer.start());
+
+#ifdef DEBUG_VERBOSE
+  UIMA_TPRINT( "ResultSpec" );
+  crclTargetSet.print(cout);
+#endif
+
+  uima::lowlevel::TypeSystem const & lolTS = iv_pCASImpl->getHeap().getTypeSystem();
+  Type tokType = uima::internal::FSPromoter::promoteType( iv_tyTokenType, lolTS);
+  Type sentType = uima::internal::FSPromoter::promoteType( iv_tySentenceType, lolTS);
+  Type parType = uima::internal::FSPromoter::promoteType( iv_tyParagraphType, lolTS);
+  Feature stemFeature = uima::internal::FSPromoter::promoteFeature( iv_stemFeature, lolTS );
+
+  // Check the target AT set: can contain token/sentence/paragraph
+  iv_bIsTokenReq    = crclTargetSet.shouldBeCreatedByAnnotator( tokType );
+  iv_bIsSentenceReq = crclTargetSet.shouldBeCreatedByAnnotator( sentType );
+  iv_bIsParagraphReq= crclTargetSet.shouldBeCreatedByAnnotator( parType );
+  iv_stemsRequired = crclTargetSet.shouldBeCreatedByAnnotator( stemFeature );
+
+  // if none of them is required, why are we beeing called?
+  assert(iv_bIsTokenReq || iv_bIsSentenceReq || iv_bIsParagraphReq);
+
+  iv_uiTokenNbr     = iv_cuiCOUNTER_START;
+  iv_uiSentenceNbr  = iv_cuiCOUNTER_START;
+  iv_uiParagraphNbr = iv_cuiCOUNTER_START;
+  iv_uiParagraphStartIndex = 0;
+  iv_uiSentenceStartIndex = 0;
+
+//    setLanguage(tcas.getDocumentAnnotation().getLanguage());
+
+  UnicodeStringRef ulStrDoc(tcas.getDocumentText());
+
+  if (ulStrDoc.length() == 0) {
+    return(TyErrorId)UIMA_ERR_NONE;
+  }
+
+  UIMA_TIMING(iv_clSSTokTimer.start());
+  Tokenizer::process( ulStrDoc.getBuffer(), ulStrDoc.getBuffer()+ulStrDoc.length()-1 );
+  UIMA_TIMING(iv_clSSTokTimer.stop());
+
+  //
+  // terminate both sentence and paragraph up to the end of the document
+  //
+  if (iv_uiSentenceStartIndex < ulStrDoc.length()-1) {
+    addNewSentenceAnnotation(iv_uiSentenceStartIndex, ulStrDoc.length() );
+  }
+
+  if (iv_uiParagraphStartIndex < ulStrDoc.length()-1) {
+    addNewParagraphAnnotation(iv_uiParagraphStartIndex, ulStrDoc.length() );
+  }
+  UIMA_TIMING(iv_clTotalTimer.stop());
+
+  return(TyErrorId)UIMA_ERR_NONE;
+}
+
+
+/* ----------------------------------------------------------------------- */
+/*   Mapping for generic C API wrapper                                     */
+/* ----------------------------------------------------------------------- */
+
+typedef AnnotatorTokenizer UserDefinedAnnotator;
+// define for error/exception info in annotator_generic.inl
+#define UIMA_ANNOTATOR_NAME "annotator_tok"
+
+/* ----------------------------------------------------------------------- */
+/*   Include generic C API wrapper                                         */
+/* ----------------------------------------------------------------------- */
+
+#include "uima/annotator_generic.inl"
+
+/* <EOF> */
+

Propchange: incubator/uima/uimacpp/trunk/src/test/src/annotator_tok.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/uima/uimacpp/trunk/src/test/src/conui.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/conui.cpp?view=auto&rev=503265
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/conui.cpp (added)
+++ incubator/uima/uimacpp/trunk/src/test/src/conui.cpp Sat Feb  3 09:19:12 2007
@@ -0,0 +1,106 @@
+/** @name conui.cpp
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+
+-----------------------------------------------------------------------------
+
+      Contents: functions to let UIMA types interact with util::ConsoleUI
+
+-------------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Include dependencies                                              */
+/* ----------------------------------------------------------------------- */
+
+#include "uima/conui.hpp"
+
+#include "uima/consoleui.hpp"
+#include "uima/engine.hpp"
+#include "uima/api.hpp"
+
+/* ----------------------------------------------------------------------- */
+/*       Constants                                                         */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Forward declarations                                              */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Types / Classes                                                   */
+/* ----------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/*       Implementation                                                    */
+/* ----------------------------------------------------------------------- */
+
+namespace uima {
+
+
+  void uimaToolDisplayException(util::ConsoleUI & rclConsole, const Exception & crclException)
+  /* ----------------------------------------------------------------------- */
+  {
+    rclConsole.formatHeader(_TEXT("Exception"));
+    rclConsole.format(_TEXT("Exception error id"), crclException.getErrorInfo().getErrorId());
+    rclConsole.format(_TEXT("Exception name"), crclException.getName());
+    rclConsole.format(_TEXT("Exception what"), crclException.what());
+    rclConsole.format(_TEXT("Exception message"), crclException.getErrorInfo().getMessage().asString().c_str());
+    rclConsole.formatBool(_TEXT("Exception recoverable"), crclException.getErrorInfo().isRecoverable());
+    const TCHAR * cpszSavePrefix = ErrorInfo::getGlobalErrorInfoIndent();
+    ErrorInfo::setGlobalErrorInfoIndent("  ");
+    rclConsole.getOutputStream() << crclException.getErrorInfo() << endl;
+    ErrorInfo::setGlobalErrorInfoIndent(cpszSavePrefix);
+  }
+
+  void uimaToolDisplayErrorId(util::ConsoleUI const & rclConsole, const TyErrorId utErrorId, const TCHAR * cpszLastErrorMsg)
+  /* ----------------------------------------------------------------------- */
+  {
+    rclConsole.formatHeader(_TEXT("TyErrorId"));
+    rclConsole.format(_TEXT("Error id"), utErrorId);
+    rclConsole.format(_TEXT("Error id"), TextAnalysisEngine::getErrorIdAsCString(utErrorId));
+    if (EXISTS(cpszLastErrorMsg)) {
+      rclConsole.format(_TEXT("Last logged error"), cpszLastErrorMsg);
+    }
+  }
+
+  void uimaToolHandleErrorId(util::ConsoleUI & rclConsole, const TyErrorId utErrorId, const TCHAR * cpszLastErrorMsg, const TCHAR * cpszFunction, TyErrorId utErrorIdExpected)
+  /* ----------------------------------------------------------------------- */
+  {
+    if (EXISTS(cpszFunction)) {
+      rclConsole.format(_TEXT("Function"), cpszFunction);
+    }
+    if (utErrorIdExpected != UIMA_ERR_NONE) {
+      rclConsole.format(_TEXT("Expecting Error id"), utErrorIdExpected);
+      rclConsole.format(_TEXT("Expecting Error id"), TextAnalysisEngine::getErrorIdAsCString(utErrorIdExpected));
+    }
+    if (utErrorId != utErrorIdExpected) {
+      uimaToolDisplayErrorId(rclConsole, utErrorId, cpszLastErrorMsg);
+      UIMA_EXC_THROW_NEW(ConsoleAbortExc,
+                         utErrorId,
+                         UIMA_MSG_ID_EXC_UNEXPECTED_ERROR,
+                         ErrorMessage(UIMA_MSG_ID_EXCON_UNKNOWN_CONTEXT),
+                         ErrorInfo::unrecoverable);
+    }
+    if (EXISTS(cpszFunction)) {
+      rclConsole.formatBool(_TEXT("   Function OK"), true);
+    }
+  }
+
+} // namespace uima
+
+/* <EOF> */
+

Propchange: incubator/uima/uimacpp/trunk/src/test/src/conui.cpp
------------------------------------------------------------------------------
    svn:eol-style = native