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 17:46:15 UTC
svn commit: r503238 [1/2] - /incubator/uima/uimacpp/trunk/examples/src/
Author: eae
Date: Sat Feb 3 08:46:13 2007
New Revision: 503238
URL: http://svn.apache.org/viewvc?view=rev&rev=503238
Log:
Initial entry
Added:
incubator/uima/uimacpp/trunk/examples/src/
incubator/uima/uimacpp/trunk/examples/src/DaveDetector.cpp (with props)
incubator/uima/uimacpp/trunk/examples/src/DaveDetector.mak
incubator/uima/uimacpp/trunk/examples/src/DaveDetector.vcproj (with props)
incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.cpp (with props)
incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.mak
incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.vcproj (with props)
incubator/uima/uimacpp/trunk/examples/src/SimpleTextSegmenter.mak
incubator/uima/uimacpp/trunk/examples/src/SimpleTextSegmenter.vcproj (with props)
incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp (with props)
incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.mak
incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.vcproj (with props)
incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp (with props)
incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.mak
incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.vcproj (with props)
incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp (with props)
incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.mak
incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.vcproj (with props)
incubator/uima/uimacpp/trunk/examples/src/SofaStreamHandlerFile.mak
incubator/uima/uimacpp/trunk/examples/src/SofaStreamHandlerFile.vcproj (with props)
incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.cpp (with props)
incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.mak
incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.vcproj (with props)
incubator/uima/uimacpp/trunk/examples/src/all.mak
incubator/uima/uimacpp/trunk/examples/src/uimacpp-examples.sln (with props)
Added: incubator/uima/uimacpp/trunk/examples/src/DaveDetector.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/DaveDetector.cpp?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/DaveDetector.cpp (added)
+++ incubator/uima/uimacpp/trunk/examples/src/DaveDetector.cpp Sat Feb 3 08:46:13 2007
@@ -0,0 +1,123 @@
+/*
+ * 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 "uima/api.hpp"
+using namespace uima;
+
+class DaveDetector : public Annotator {
+private:
+ Type david;
+ CAS *tcas;
+ icu::UnicodeString us_DaveString;
+
+public:
+
+ DaveDetector(void) {
+ cout << "DaveDetector: Constructor" << endl;
+ }
+
+ ~DaveDetector(void) {
+ cout << "DaveDetector: Destructor" << endl;
+ }
+
+ /** */
+ TyErrorId initialize(AnnotatorContext & rclAnnotatorContext) {
+ cout << "DaveDetector: initialize()" << endl;
+
+
+ if (!rclAnnotatorContext.isParameterDefined("DaveString") ||
+ rclAnnotatorContext.extractValue("DaveString", us_DaveString) != UIMA_ERR_NONE) {
+ /* log the error condition */
+ rclAnnotatorContext.getLogger().logError("Required configuration parameter \"DaveString\" not found in component descriptor");
+ cout << "DaveDetector::initialize() - Error. See logfile." << endl;
+ return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
+ }
+
+ /* log the configuration parameter setting */
+ rclAnnotatorContext.getLogger().logMessage("DaveString = '" + us_DaveString + "'");
+
+ cout << "DaveDetector::initialize() .. us_DaveString.getBuffer: "
+ << us_DaveString << endl;
+
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+ /** */
+ TyErrorId typeSystemInit(TypeSystem const & crTypeSystem) {
+ cout << "DaveDetector:: typeSystemInit()" << endl;
+ david = crTypeSystem.getType("org.apache.uima.examples.David");
+ if (!david.isValid()) {
+ getAnnotatorContext().getLogger().logError("Error getting Type object for org.apache.uima.examples.David");
+ cout << "DaveDetector::typeSystemInit - Error. See logfile" << endl;
+ return (TyErrorId)UIMA_ERR_RESMGR_INVALID_RESOURCE;
+ }
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+ /** */
+ TyErrorId destroy() {
+ cout << "DaveDetector: destroy()" << endl;
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+ /** */
+ TyErrorId process(CAS & tcas, ResultSpecification const & crResultSpecification) {
+ cout << "DaveDetector::process() begins" << endl;
+ FSIndexRepository & indexRep = tcas.getIndexRepository();
+
+ /* This is a shallow pointer object containing a reference to document text*/
+ UnicodeStringRef ulstrDoc = tcas.getDocumentText();
+ /* Conventional pointer to mark beginning of the buffer*/
+ const UChar * cpszDocTextBegin = ulstrDoc.getBuffer();
+ /* Pointer to the document text remaining to be scanned */
+ const UChar * remainingTextP = cpszDocTextBegin;
+ /* Pointer to the match string */
+ const UChar * DaveStringP = us_DaveString.getBuffer();
+ /* Get number of Unicode chars (UTF-16 code units) of a couple strings */
+ size_t uiDocLen = ulstrDoc.length();
+ size_t uiMatchLen = us_DaveString.length();
+ size_t remainingLen = uiDocLen;
+
+ cout << "DaveDetector::process() .. uiDocLen: " << uiDocLen << endl;
+ getAnnotatorContext().getLogger().logMessage("process called");
+
+ UChar * gotDaveP;
+ while ( NULL !=
+ (gotDaveP = u_strFindFirst(remainingTextP, remainingLen, DaveStringP, uiMatchLen)) ) {
+ size_t uiExprBeginPos = gotDaveP - cpszDocTextBegin;
+ size_t uiExprEndPos = uiExprBeginPos + uiMatchLen;
+ remainingLen = uiDocLen - uiExprBeginPos;
+ remainingTextP = gotDaveP + uiMatchLen;
+
+ cout << "DaveDetector::process() .. Gotta Dave begin: " << uiExprBeginPos << " end: "
+ << uiExprEndPos << " remaining: " << remainingLen << endl;
+
+ AnnotationFS fsNewExp =
+ tcas.createAnnotation(david, uiExprBeginPos, uiExprEndPos);
+ indexRep.addFS(fsNewExp);
+ }
+
+ cout << "DaveDetector::process() ends" << endl;
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+};
+
+// This macro exports an entry point that is used to create the annotator.
+
+MAKE_AE(DaveDetector);
Propchange: incubator/uima/uimacpp/trunk/examples/src/DaveDetector.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/examples/src/DaveDetector.mak
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/DaveDetector.mak?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/DaveDetector.mak (added)
+++ incubator/uima/uimacpp/trunk/examples/src/DaveDetector.mak Sat Feb 3 08:46:13 2007
@@ -0,0 +1,25 @@
+#####################################
+# UNIX Makefile for a UIMACPP annotator
+#####################################
+
+# name of the annotator to be created
+TARGET_FILE=DaveDetector
+
+# list of user's object files to be linked when building the annotator
+OBJS=DaveDetector.o
+
+#Use this var to pass additional user-defined parameters to the compiler
+USER_CFLAGS=
+
+#Use this var to pass additional user-defined parameters to the linker
+USER_LINKFLAGS=
+
+# Set DEBUG=1 for a debug build (if not 1 a ship build will result)
+DEBUG=1
+
+# Set DLL_BUILD=1 to build an annotator (shared library)
+# if not 1 an executable binary will be built
+DLL_BUILD=1
+
+# include file with generic compiler instructions
+include $(UIMACPP_HOME)/lib/base.mak
Added: incubator/uima/uimacpp/trunk/examples/src/DaveDetector.vcproj
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/DaveDetector.vcproj?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/DaveDetector.vcproj (added)
+++ incubator/uima/uimacpp/trunk/examples/src/DaveDetector.vcproj Sat Feb 3 08:46:13 2007
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="DaveDetector"
+ ProjectGUID="{69C8A769-7CEC-4D2A-B189-FE19606577B7}"
+ RootNamespace="DaveDetector"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(InputDir)"
+ IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ MinimalRebuild="TRUE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libapr$(APR_VER).lib xerces-c_2.lib icuuc.lib uimaD.lib"
+ OutputFile="$(OutDir)/DaveDetector.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/$(TargetName).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="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="TRACEOFF;NDEBUG;WIN32;_WINDOWS;_USRDLL"
+ MinimalRebuild="FALSE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libapr$(APR_VER).lib xerces-c_2.lib icuuc.lib uima.lib"
+ OutputFile="$(OutDir)/DaveDetector.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="FALSE"
+ ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/$(TargetName).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=".\DaveDetector.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/examples/src/DaveDetector.vcproj
------------------------------------------------------------------------------
svn:eol-style = CRLF
Added: incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.cpp?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.cpp (added)
+++ incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.cpp Sat Feb 3 08:46:13 2007
@@ -0,0 +1,233 @@
+/*
+ * 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 "uima/api.hpp"
+#include "uima/dirwalk.hpp"
+#include "uima/filename.hpp"
+#include "uima/xmlwriter.hpp"
+
+#include <sys/stat.h>
+using namespace uima;
+/**
+ * An example application that reads documents from files, sends them
+ * though a Text Analysis Engine, and prints all discovered annotations to
+ * the console.
+ * <p>
+ * The application takes two arguments:
+ * <ol type="1">
+ * <li>The path to an XML descriptor for the TAE to be executed</li>
+ * <li>An input directory containing files to be processed</li>
+ * <li>Optionally, the logging level</li>
+ * </ol>
+ *
+ *
+ */
+
+/**
+* Main program.
+*
+* @param args Command-line arguments - see class description
+*/
+
+/* Little helper routine to check and report errors.
+ This routine just does a hard program exit for any failure! */
+static void CheckError(TyErrorId utErrorId,
+ const AnalysisEngine & crEngine);
+static void CheckError(ErrorInfo const &);
+
+void processFile (std::string filename, AnalysisEngine * pEngine, CAS * tcas);
+
+void tell() {
+ cerr << "Usage: ExampleApplication UimaCppDescriptor InputFileOrDirectory <-l LogLevel>" << endl;
+}
+
+int main(int argc, char * argv[]) {
+ try {
+ int loglevel = -1;
+
+ /* check the number of command line args */
+ if (argc != 3 && argc != 5 ) {
+ tell();
+ return 1;
+ }
+
+ if (argc == 5) {
+ if (!strcmp(argv[3], "-l")) {
+ loglevel = atoi(argv[4]);
+ if (loglevel < LogStream::EnMessage) {
+ cerr << "LogLevel less than minimum value (Message) = " << LogStream::EnMessage << endl;
+ return 1;
+ }
+ if (loglevel > LogStream::EnError) {
+ cerr << "LogLevel greater than maximum value (Error) = " << LogStream::EnError << endl;
+ return 1;
+ }
+ } else {
+ cerr << "Inexpected option: " << argv[3] << endl;
+ tell();
+ return 1;
+ }
+ }
+
+ /* Create/link up to a resource manager instance (singleton) */
+ (void) ResourceManager::createInstance("UIMACPP_EXAMPLE_APPLICATION");
+
+ if (loglevel >= 0) {
+ ResourceManager::getInstance().setLoggingLevel((LogStream::EnEntryType)loglevel);
+ }
+
+ TyErrorId utErrorId; // Variable to store return codes
+ ErrorInfo errorInfo; // Variable to stored detailed error info
+ /* Initialize engine with filename of config-file */
+ AnalysisEngine * pEngine =
+ Framework::createAnalysisEngine(argv[1], errorInfo);
+ CheckError(errorInfo);
+
+ /* Get a new CAS */
+ CAS* tcas = pEngine->newCAS();
+
+ /* process input xcas */
+ util::DirectoryWalk dirwalker(argv[2]);
+ if (dirwalker.isValid()) {
+
+ util::Filename infile(argv[2],"FilenamePlaceHolder");
+ while (dirwalker.isValid()) {
+ // Process all files or just the ones with matching suffix
+ if ( dirwalker.isFile() &&
+ dirwalker.matchesWildcardPattern("*.txt") ) {
+ infile.setNewName(dirwalker.getNameWithoutPath());
+ std::string afile(infile.getAsCString());
+
+ //process the file
+ processFile(afile, pEngine, tcas);
+
+ //reset the cas
+ tcas->reset();
+ }
+ //get the next xcas file in the directory
+ dirwalker.setToNext();
+ }
+ } else {
+ /* If has no directory entries then probably a file */
+ cout << "ExampleApplication: processing file " << argv[2] << endl;
+ std::string afile(argv[2]);
+ //process the cas
+ processFile(afile, pEngine, tcas);
+ }
+
+ /* call collectionProcessComplete */
+ utErrorId = pEngine->collectionProcessComplete();
+
+ /* Free ressorces */
+ utErrorId = pEngine->destroy();
+ CheckError(utErrorId, *pEngine);
+
+ delete tcas;
+ delete pEngine;
+ } catch (Exception e) {
+ cout << "ExampleApplication " << e << endl;
+ }
+ /* If we got this far everything went OK */
+ cout << "ExampleApplication: processing finished sucessfully! " << endl;
+
+ return(0);
+}
+
+/* Little helper routine to check and report errors.
+ This routine just does a hard program exit for any failure!
+*/
+static void CheckError(TyErrorId utErrorId,
+ const AnalysisEngine & crEngine) {
+ if (utErrorId != UIMA_ERR_NONE) {
+ cerr << endl << " *** ExampleApplication - Error info:" << endl;
+ cerr << "Error number : "
+ << utErrorId << endl;
+ cerr << "Error string : "
+ << AnalysisEngine::getErrorIdAsCString(utErrorId) << endl;
+ const TCHAR* errStr = crEngine.getAnnotatorContext().getLogger().getLastErrorAsCStr();
+ if (errStr != NULL)
+ cerr << " Last logged message : " << errStr << endl;
+ exit((int)utErrorId);
+ }
+}
+
+/* Similar routine as above just with error info objects instead of err-ids.
+This routine just does a hard program exit for any failure!
+*/
+static void CheckError(ErrorInfo const & errInfo) {
+ if (errInfo.getErrorId() != UIMA_ERR_NONE) {
+ cerr << endl << " *** ExampleApplication - Error info:" << endl
+ << "Error string : "
+ << AnalysisEngine::getErrorIdAsCString(errInfo.getErrorId())
+ << errInfo << endl; /* (errInfo starts with a newline) */
+ exit((int)errInfo.getErrorId());
+ }
+}
+
+void processFile (std::string filename, AnalysisEngine * pEngine, CAS * tcas ) {
+ cout << "processing file " << filename << endl;
+ try {
+
+ /* read in file contents and set CAS Document text */
+ FILE * pFile = fopen(filename.c_str(),"rb");
+ int filesize;
+ if (pFile == NULL) {
+ cerr << "ExampleApplication: Error reading file " << filename << endl;
+ exit(-1);
+ }
+
+ /* allocate buffer for file contents */
+ struct stat fstat;
+ stat(filename.c_str(), &fstat);
+ filesize = fstat.st_size;
+ char * pBuffer = new char[filesize+1];
+ if (pBuffer == NULL) {
+ cerr << "ExampleApplication: Error allocating buffer to hold contents of file " << filename << endl;
+ exit(-1);
+ }
+
+ /* read the file */
+ size_t numread = fread(pBuffer,1,filesize,pFile);
+ fclose(pFile);
+
+ /* convert to unicode and set tcas document text*/
+ UnicodeString ustrInputText(pBuffer, filesize, "utf-8");
+
+ tcas->setDocumentText(ustrInputText.getBuffer(), ustrInputText.length(), true);
+
+ delete pBuffer;
+ /* process the CAS */
+ TyErrorId utErrorId = ((AnalysisEngine*)pEngine)->process(*tcas);
+ CheckError(utErrorId, *pEngine);
+
+ /* serialize the cas to stdout */
+ cout << "ExampleApplication: write out cas after processing file " << filename << endl << endl;
+ XCASWriter writer(*tcas, true);
+ writer.write(cout);
+ cout << endl;
+
+ } catch (Exception e) {
+ cout << "ExampleApplication: " << e << endl;
+ }
+}
+
+/* <EOF> */
+
+
+
Propchange: incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.mak
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.mak?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.mak (added)
+++ incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.mak Sat Feb 3 08:46:13 2007
@@ -0,0 +1,25 @@
+#####################################
+# UNIX Makefile for a UIMACPP application
+#####################################
+
+# name of the annotator to be created
+TARGET_FILE=ExampleApplication
+
+# list of user's object files to be linked when building the application
+OBJS=ExampleApplication.o
+
+#Use this var to pass additional user-defined parameters to the compiler
+USER_CFLAGS=
+
+#Use this var to pass additional user-defined parameters to the linker
+USER_LINKFLAGS=
+
+# Set DEBUG=1 for a debug build (if not 1 a ship build will result)
+DEBUG=1
+
+# Set DLL_BUILD=1 to build an annotator (shared library)
+# if not 1 an executable binary will be built
+DLL_BUILD=0
+
+# include file with generic compiler instructions
+include $(UIMACPP_HOME)/lib/base.mak
Added: incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.vcproj
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.vcproj?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.vcproj (added)
+++ incubator/uima/uimacpp/trunk/examples/src/ExampleApplication.vcproj Sat Feb 3 08:46:13 2007
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="ExampleApplication"
+ ProjectGUID="{9F230EC0-DB18-46AC-BB02-DC1E6974A463}"
+ RootNamespace="ExampleApplication"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(InputDir)"
+ IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ IgnoreStandardIncludePath="FALSE"
+ MinimalRebuild="TRUE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="xerces-c_2.lib icuuc.lib uimaD.lib libapr$(APR_VER).lib"
+ OutputFile="$(OutDir)\ExampleApplication.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+ SubSystem="1"
+ 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="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="TRACEOFF;NDEBUG;WIN32;_CONSOLE"
+ MinimalRebuild="FALSE"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="xerces-c_2.lib icuuc.lib uima.lib libapr$(APR_VER).lib"
+ OutputFile="$(OutDir)\ExampleApplication.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="FALSE"
+ ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ 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="ExampleApplication.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/examples/src/ExampleApplication.vcproj
------------------------------------------------------------------------------
svn:eol-style = CRLF
Added: incubator/uima/uimacpp/trunk/examples/src/SimpleTextSegmenter.mak
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SimpleTextSegmenter.mak?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SimpleTextSegmenter.mak (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SimpleTextSegmenter.mak Sat Feb 3 08:46:13 2007
@@ -0,0 +1,25 @@
+#####################################
+# UNIX Makefile for a UIMACPP annotator
+#####################################
+
+# name of the annotator to be created
+TARGET_FILE=SimpleTextSegmenter
+
+# list of user's object files to be linked when building the annotator
+OBJS=SimpleTextSegmenter.o
+
+#Use this var to pass additional user-defined parameters to the compiler
+USER_CFLAGS=
+
+#Use this var to pass additional user-defined parameters to the linker
+USER_LINKFLAGS=
+
+# Set DEBUG=1 for a debug build (if not 1 a ship build will result)
+DEBUG=1
+
+# Set DLL_BUILD=1 to build an annotator (shared library)
+# if not 1 an executable binary will be built
+DLL_BUILD=1
+
+# include file with generic compiler instructions
+include $(UIMACPP_HOME)/lib/base.mak
Added: incubator/uima/uimacpp/trunk/examples/src/SimpleTextSegmenter.vcproj
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SimpleTextSegmenter.vcproj?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SimpleTextSegmenter.vcproj (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SimpleTextSegmenter.vcproj Sat Feb 3 08:46:13 2007
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="SimpleTextSegmenter"
+ ProjectGUID="{69C8A769-7CEC-4D2A-B189-FE19606577B7}"
+ RootNamespace="SimpleTextSegmenter"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(InputDir)"
+ IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ MinimalRebuild="TRUE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libapr$(APR_VER).lib xerces-c_2.lib icuuc.lib uimaD.lib"
+ OutputFile="$(OutDir)/SimpleTextSegmenter.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/$(TargetName).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="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="TRACEOFF;NDEBUG;WIN32;_WINDOWS;_USRDLL"
+ MinimalRebuild="FALSE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libapr$(APR_VER).lib xerces-c_2.lib icuuc.lib uima.lib"
+ OutputFile="$(OutDir)/SimpleTextSegmenter.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="FALSE"
+ ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/$(TargetName).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/examples/src/SimpleTextSegmenter.vcproj
------------------------------------------------------------------------------
svn:eol-style = CRLF
Added: incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp Sat Feb 3 08:46:13 2007
@@ -0,0 +1,138 @@
+/*
+ * 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 "uima/api.hpp"
+using namespace uima;
+
+
+class SofaDataAnnotator : public Annotator {
+private:
+ AnnotatorContext * pAnc;
+ Type annot;
+public:
+
+ SofaDataAnnotator(void) {
+ cout << "SofaDataAnnotator: Constructor" << endl;
+ }
+
+ ~SofaDataAnnotator(void) {
+ cout << "SofaDataAnnotator: Destructor" << endl;
+ }
+
+ /** */
+ TyErrorId initialize(AnnotatorContext & rclAnnotatorContext) {
+ cout << "SofaDataAnnotator: initialize()" << endl;
+
+ // Save the annotator context for use in process()
+ pAnc = &rclAnnotatorContext;
+
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+
+ TyErrorId typeSystemInit(TypeSystem const & crTypeSystem) {
+ cout << "SofaDataAnnotator: typeSystemInit()" << endl;
+ annot = crTypeSystem.getType("uima.tcas.Annotation");
+ return(TyErrorId)UIMA_ERR_NONE;
+ }
+
+ /** */
+ TyErrorId destroy() {
+ cout << "SofaDataAnnotator: destroy()" << endl;
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+ // Look for "EnglishDocument" sofa and read it as a stream
+ 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);
+ /** get the handle to the index repository */
+ FSIndexRepository & indexRep = tcas->getIndexRepository();
+
+ /** get the handle to the sofa data stream */
+ SofaDataStream * pStream = textSofa.getSofaDataStream();
+ /** open the stream */
+ int rc = pStream->open();
+ if (rc != 0) {
+ cout << "open failed " << rc << endl;
+ return (TyErrorId)UIMA_ERR_USER_ANNOTATOR_COULD_NOT_PROCESS;
+ }
+ /** get the total stream size */
+ size_t streamSize = pStream->getTotalStreamSizeInBytes();
+
+ /** read file contents into a buffer */
+ char * pBuffer = new char[streamSize+1];
+ memset(pBuffer,'\n' ,streamSize+1);
+ int elementsize=1;
+ pStream->read(pBuffer, elementsize, streamSize);
+
+ cout << endl;
+ cout.write(pBuffer, streamSize);
+ cout << endl;
+
+ /** convert to unicode */
+ UnicodeString ustrInputText(pBuffer, streamSize+1, "utf-8");
+
+ /** find tokens and annotate */
+ UnicodeString delim(" ");
+ UChar *myLocalSaveState;
+ UChar * pInputText = (UChar*) ustrInputText.getBuffer();
+ const UChar * pToken = pInputText;
+ const UChar * pNextToken = u_strtok_r((UChar*) pInputText, delim.getBuffer(), &myLocalSaveState);
+ int start = 1;
+ int tokenlength=0;
+ int nTokens = 0;
+ while ( (pNextToken=u_strtok_r(NULL, delim.getBuffer(), &myLocalSaveState)) ) {
+ tokenlength = pNextToken - pToken;
+ AnnotationFS annotFS = tcas->createAnnotation(annot, start, start+tokenlength-2);
+ indexRep.addFS(annotFS);
+ ++nTokens;
+ start += tokenlength;
+ pToken = pNextToken;
+ }
+ /* last token */
+ tokenlength = pNextToken - pToken;
+ AnnotationFS annotFS = tcas->createAnnotation(annot, start, streamSize);
+ indexRep.addFS(annotFS);
+ ++nTokens;
+ cout << endl << " Annotated " << nTokens << " tokens." << endl << endl;
+
+ /** close the stream */
+ pStream->close();
+ delete pStream;
+ delete pBuffer;
+
+ cout << "SofaDataAnnotator: process() ends" << endl;
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+};
+
+// This macro exports an entry point that is used to create the annotator.
+
+MAKE_AE(SofaDataAnnotator);
Propchange: incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.mak
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.mak?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.mak (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.mak Sat Feb 3 08:46:13 2007
@@ -0,0 +1,25 @@
+#####################################
+# UNIX Makefile for a UIMACPP annotator
+#####################################
+
+# name of the annotator to be created
+TARGET_FILE=SofaDataAnnotator
+
+# list of user's object files to be linked when building the annotator
+OBJS=SofaDataAnnotator.o
+
+#Use this var to pass additional user-defined parameters to the compiler
+USER_CFLAGS=
+
+#Use this var to pass additional user-defined parameters to the linker
+USER_LINKFLAGS=
+
+# Set DEBUG=1 for a debug build (if not 1 a ship build will result)
+DEBUG=1
+
+# Set DLL_BUILD=1 to build an annotator (shared library)
+# if not 1 an executable binary will be built
+DLL_BUILD=1
+
+# include file with generic compiler instructions
+include $(UIMACPP_HOME)/lib/base.mak
Added: incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.vcproj
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.vcproj?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.vcproj (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaDataAnnotator.vcproj Sat Feb 3 08:46:13 2007
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="SofaDataAnnotator"
+ ProjectGUID="{69C8A769-7CEC-4D2A-B189-FE19606577B7}"
+ RootNamespace="DaveDetector"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(InputDir)"
+ IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ MinimalRebuild="TRUE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libapr$(APR_VER).lib xerces-c_2.lib icuuc.lib uimaD.lib"
+ OutputFile="$(OutDir)/SofaDataAnnotator.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/$(TargetName).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="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="TRACEOFF;NDEBUG;WIN32;_WINDOWS;_USRDLL"
+ MinimalRebuild="FALSE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libapr$(APR_VER).lib xerces-c_2.lib icuuc.lib uima.lib"
+ OutputFile="$(OutDir)/SofaDataAnnotator.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="FALSE"
+ ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/$(TargetName).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=".\SofaDataAnnotator.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/examples/src/SofaDataAnnotator.vcproj
------------------------------------------------------------------------------
svn:eol-style = CRLF
Added: incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp Sat Feb 3 08:46:13 2007
@@ -0,0 +1,180 @@
+/*
+ * 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 "uima/api.hpp"
+using namespace uima;
+
+const UChar * translate(UChar *);
+
+class SofaExampleAnnotator : public Annotator {
+private:
+ Type cross, annot;
+ Feature other;
+ icu::UnicodeString us_SofaString;
+ AnnotatorContext * pAnc;
+
+public:
+
+ SofaExampleAnnotator(void) {
+ cout << "SofaExampleAnnotator: Constructor" << endl;
+ }
+
+ ~SofaExampleAnnotator(void) {
+ cout << "SofaExampleAnnotator: Destructor" << endl;
+ }
+
+ /** */
+ TyErrorId initialize(AnnotatorContext & rclAnnotatorContext) {
+ cout << "SofaExampleAnnotator: initialize()" << endl;
+
+ // Save the annotator context for use in process()
+ pAnc = &rclAnnotatorContext;
+
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+
+ /** */
+ TyErrorId typeSystemInit(TypeSystem const & crTypeSystem) {
+ cout << "SofaExampleAnnotator::typeSystemInit()" << endl;
+
+ // get Type and Feature objects for use in process()
+ annot = crTypeSystem.getType("uima.tcas.Annotation");
+ cross = crTypeSystem.getType("sofa.test.CrossAnnotation");
+ other = cross.getFeatureByBaseName("otherAnnotation");
+ if (!(annot.isValid() && cross.isValid() && other.isValid())) {
+ cout << "SofaExampleAnnotator::typeSystemInit() - Error getting Type or Feature objects" << endl;
+ return (TyErrorId)UIMA_ERR_RESMGR_INVALID_RESOURCE;
+ }
+ return(TyErrorId)UIMA_ERR_NONE;
+ }
+
+
+ /** */
+ TyErrorId destroy() {
+ cout << "SofaExampleAnnotator: destroy()" << endl;
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+ /** */
+ TyErrorId process(CAS & rCAS, ResultSpecification const & crResultSpecification) {
+ 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);
+ 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);
+
+ // Get pointer to the English text document
+ DocumentFS docFS = engTcas->getDocumentAnnotation();
+ UnicodeStringRef engText = docFS.getCoveredText();
+
+ // make copy of document for the u_strtok_r function (100 character limit!)
+ UChar uWork[100];
+ u_strncpy(uWork, engText.getBuffer(), 99);
+
+ // Setup for translated text
+ int germBegin = 0;
+ int germEnd = 0;
+ UChar translation[400];
+ translation[0]=0;
+
+ // get two IR handles for adding annotations to the appropriate view
+ FSIndexRepository & engIndexRep = engTcas->getIndexRepository();
+ FSIndexRepository & germIndexRep = germTcas->getIndexRepository();
+
+ // Parse the English text
+ UChar * next = u_strtok_r(uWork, delimUS.getBuffer(), &myLocalSaveState);
+
+ while (next) {
+ // Create annotation on source text
+ AnnotationFS engAnnot =
+ engTcas->createAnnotation(annot, next-uWork, (next-uWork)+u_strlen(next));
+ engIndexRep.addFS(engAnnot);
+
+ // Translate word-by-word
+ const UChar * gword = translate(next);
+
+ // Accumulate the total translated document
+ if (germBegin > 0) {
+ // if not the first word, add space before
+ u_strncat(translation, delimUS.getBuffer(), 1);
+ germBegin += 1;
+ }
+ u_strcat(translation, gword);
+
+ // Create annotation on output text
+ germEnd = germBegin + u_strlen(gword);
+ AnnotationFS germAnnot = germTcas->createAnnotation(cross, germBegin, germEnd);
+ germIndexRep.addFS(germAnnot);
+ // add link to English text
+ germAnnot.setFSValue(other, engAnnot);
+ germBegin = germEnd;
+
+ next = u_strtok_r(NULL, delimUS.getBuffer(), &myLocalSaveState);
+ }
+ // set documentText with accumulated transation
+ germTcas->setDocumentText( translation, u_strlen(translation), true );
+
+ cout << " German(!) Output: " << germTcas->getDocumentText() << endl;
+
+ cout << "SofaExampleAnnotator: process() ends" << endl;
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+};
+
+
+/** */
+static UnicodeString const uThis("this");
+static UnicodeString const uBeer("beer");
+static UnicodeString const uIs("is");
+static UnicodeString const uDas("das");
+static UnicodeString const uBier("bier");
+static UnicodeString const uIst("ist");
+static UnicodeString const uGut("gut");
+const UChar * translate(UChar * eword) {
+ if (0 == u_strcasecmp(eword, uThis.getBuffer(), 0))
+ return uDas.getBuffer();
+ if (0 == u_strcasecmp(eword, uBeer.getBuffer(), 0))
+ return uBier.getBuffer();
+ if (0 == u_strcasecmp(eword, uIs.getBuffer(), 0))
+ return uIst.getBuffer();
+ return uGut.getBuffer();
+}
+
+// This macro exports an entry point that is used to create the annotator.
+
+MAKE_AE(SofaExampleAnnotator);
Propchange: incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.mak
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.mak?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.mak (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.mak Sat Feb 3 08:46:13 2007
@@ -0,0 +1,25 @@
+#####################################
+# UNIX Makefile for a UIMACPP annotator
+#####################################
+
+# name of the annotator to be created
+TARGET_FILE=SofaExampleAnnotator
+
+# list of user's object files to be linked when building the annotator
+OBJS=SofaExampleAnnotator.o
+
+#Use this var to pass additional user-defined parameters to the compiler
+USER_CFLAGS=
+
+#Use this var to pass additional user-defined parameters to the linker
+USER_LINKFLAGS=
+
+# Set DEBUG=1 for a debug build (if not 1 a ship build will result)
+DEBUG=1
+
+# Set DLL_BUILD=1 to build an annotator (shared library)
+# if not 1 an executable binary will be built
+DLL_BUILD=1
+
+# include file with generic compiler instructions
+include $(UIMACPP_HOME)/lib/base.mak
Added: incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.vcproj
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.vcproj?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.vcproj (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaExampleAnnotator.vcproj Sat Feb 3 08:46:13 2007
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="SofaExampleAnnotator"
+ ProjectGUID="{69C8A769-7CEC-4D2A-B189-FE19606577B7}"
+ RootNamespace="DaveDetector"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(InputDir)"
+ IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ MinimalRebuild="TRUE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(ProjectName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libapr$(APR_VER).lib xerces-c_2.lib icuuc.lib uimaD.lib"
+ OutputFile="$(OutDir)/SofaExampleAnnotator.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/$(TargetName).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="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="TRACEOFF;NDEBUG;WIN32;_WINDOWS;_USRDLL"
+ MinimalRebuild="FALSE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(ProjectName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libapr$(APR_VER).lib xerces-c_2.lib icuuc.lib uima.lib"
+ OutputFile="$(OutDir)/SofaExampleAnnotator.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="FALSE"
+ ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/$(TargetName).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=".\SofaExampleAnnotator.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/examples/src/SofaExampleAnnotator.vcproj
------------------------------------------------------------------------------
svn:eol-style = CRLF
Added: incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp Sat Feb 3 08:46:13 2007
@@ -0,0 +1,223 @@
+/*
+ * 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.
+ */
+
+/**------------------------------------------------------------------------
+ * A simple Multiple SOFA test application
+ * Creates a text SOFA with English text,
+ * calls an annotator that creates a text SOFA with German text,
+ * then dumps all annotations found in both SOFAs
+ *
+ * The application takes no arguments.
+-------------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------- */
+/* Include dependencies */
+/* ----------------------------------------------------------------------- */
+
+#include <stdio.h>
+#include "uima/api.hpp"
+#include "uima/envvars.h"
+#include "unicode/ucnv.h"
+
+using namespace uima;
+
+/* ----------------------------------------------------------------------- */
+/* Implementation */
+/* ----------------------------------------------------------------------- */
+
+/* Little helper routine to check and report errors.
+ This routine just does a hard program exit for any failure! */
+static void CheckError(TyErrorId utErrorId,
+ const AnalysisEngine & crEngine);
+static void CheckError(ErrorInfo const &);
+
+int main(int argc, char * argv[]) {
+ int runQuiet = 0;
+ int runTimes = 1;
+ /* Access the command line arguments. */
+
+ /* filename of descriptor required */
+ /* this must be SofaExampleAnnotator.xml found in */
+ /* $(UIMACPP_HOME)/docs/examples/descriptors */
+ if (argc < 2) {
+ cout << "Usage: SofaExampleApplication pathToSofaExampleAnnotator.xml [Quiet [repeatCount]]" << endl;
+ exit (1);
+ }
+ if (argc > 2) {
+ if ('q' == *argv[2] || 'Q' == *argv[2])
+ runQuiet = 1;
+ }
+ if (argc > 3) {
+ runTimes = atoi(argv[3]);
+ cout << "Running " << runTimes << " times." << endl;
+ }
+
+ /* Create/link up to a resource manager instance (singleton) */
+ (void) ResourceManager::createInstance("SOFA_EXAMPLE_APPLICATION");
+
+ TyErrorId utErrorId; // Variable to store return codes
+ ErrorInfo errorInfo; // Variable to stored detailed error info
+
+ try {
+ /* locate SofaExampleAnnotator.xml descriptor in $(UIMACPP_HOME)/docs/examples/descriptors */
+ string descriptor = "SofaExampleAnnotator.xml";
+ util::EnvironmentVariableQueryOnly uimarootEnvVar(UIMA_ENVVAR_HOME);
+ if (uimarootEnvVar.hasValue()) {
+ descriptor = uimarootEnvVar.getValue();
+ descriptor += "/docs/examples/descriptors/SofaExampleAnnotator";
+ }
+ cout << argv[1] << endl;
+ /* Initialize engine with filename of config-file */
+ AnalysisEngine * pEngine =
+ Framework::createAnalysisEngine(argv[1], errorInfo);
+ CheckError(errorInfo);
+
+ // Construct a Unicode input string out of our single-byte string.
+ UnicodeString ustrInputText("This is a text document for analysis");
+
+ if (!runQuiet)
+ cout << "SofaExampleApplication.cpp: document length= " << ustrInputText.length() << endl;
+
+ // 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");
+
+ //and set the Sofa data with the English document
+ engSofa.setLocalSofaData(ustrInputText);
+// 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;
+
+ // Call the translation annotator
+ utErrorId = ((AnalysisEngine*)pEngine)->process(*aCas);
+ CheckError(utErrorId, *pEngine);
+
+
+ if (!runQuiet)
+ cout << endl << "Retrieving all annotations for the English document:" << endl;
+ CAS* engTcas = aCas->getView(engSofa);
+
+ ANIndex anIdx = engTcas->getAnnotationIndex(
+ engTcas->getTypeSystem().getType("uima.tcas.Annotation"));
+ ANIterator itAn = anIdx.iterator();
+ itAn.moveToFirst();
+ while (itAn.isValid()) {
+ // display the name of the Annotation Type and the covered text
+ if (!runQuiet) {
+ cout << itAn.get().getType().getName() << ": "
+ << itAn.get().getBeginPosition() << ", " << itAn.get().getEndPosition()
+ << " \"" << itAn.get().getCoveredText() << "\"" << endl;
+ }
+ itAn.moveToNext();
+ }
+
+ if (!runQuiet)
+ cout << endl << "Retrieving all annotations for the German document:" << endl;
+ CAS* germTcas = aCas->getView(aCas->getSofa(
+ pEngine->getAnnotatorContext().mapToSofaID("GermanDocument")));
+
+ Type crossType = engTcas->getTypeSystem().getType("sofa.test.CrossAnnotation");
+ Feature otherFeat = crossType.getFeatureByBaseName("otherAnnotation");
+ anIdx = germTcas->getAnnotationIndex(engTcas->getTypeSystem().getType("uima.tcas.Annotation"));
+ itAn = anIdx.iterator();
+ itAn.moveToFirst();
+ while (itAn.isValid()) {
+ // display the name of the Annotation Type and the covered text
+ if (!runQuiet) {
+ cout << itAn.get().getType().getName() << ": "
+ << itAn.get().getBeginPosition() << ", " << itAn.get().getEndPosition()
+ << " \"" << itAn.get().getCoveredText() << "\"";
+ }
+ // if annotation type = CrossAnnotation...
+ if (itAn.get().getType() == crossType) {
+ AnnotationFS otherAn = (AnnotationFS)itAn.get().getFSValue(otherFeat);
+ if (!runQuiet) {
+ cout << " --> otherAnnotation: "
+ << otherAn.getBeginPosition() << ", " << otherAn.getEndPosition()
+ << " \"" << otherAn.getCoveredText() << "\"" << endl;
+ }
+ } else
+ cout << endl;
+ itAn.moveToNext();
+ }
+ if (!runQuiet)
+ cout << endl;
+
+ /* Tell UIMA we are finished with this document */
+ utErrorId = aCas->reset();
+ CheckError(utErrorId, *pEngine);
+ }
+ /* Free ressorces in UIMA */
+ utErrorId = pEngine->destroy();
+ CheckError(utErrorId, *pEngine);
+ delete aCas;
+ delete pEngine;
+
+ /* If we got this far everything went OK */
+ if (!runQuiet)
+ cout << "UIMA processing finished sucessfully! " << endl;
+ } catch (Exception e) {
+ cout << "error " << endl;
+ }
+ return (0);
+}
+
+
+
+/* Little helper routine to check and report errors.
+ This routine just does a hard program exit for any failure!
+*/
+static void CheckError(TyErrorId utErrorId,
+ const AnalysisEngine & crEngine) {
+
+ if (utErrorId != UIMA_ERR_NONE) {
+ cerr << endl << " *** SofaExampleApplication - UIMA Error info:" << endl;
+ cerr << "Error string : "
+ << AnalysisEngine::getErrorIdAsCString(utErrorId) << endl;
+ cerr << "Error number : "
+ << utErrorId << endl;
+ const TCHAR* errStr = crEngine.getAnnotatorContext().getLogger().getLastErrorAsCStr();
+ if (errStr != NULL)
+ cerr << " Last logged message : " <<
+ errStr << endl;
+ exit((int)utErrorId);
+ }
+}
+
+/* Similar routine as above just with error info objects instead of err-ids.
+ This routine just does a hard program exit for any failure!
+*/
+static void CheckError(ErrorInfo const & errInfo) {
+ if (errInfo.getErrorId() != UIMA_ERR_NONE) {
+ cerr << endl << " *** SofaExampleApplication - UIMA Error info:" << endl
+ << "Error string : "
+ << AnalysisEngine::getErrorIdAsCString(errInfo.getErrorId())
+ << errInfo << endl; /* (errInfo starts with a newline) */
+ exit((int)errInfo.getErrorId());
+ }
+
+}
+
+
+
Propchange: incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.mak
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.mak?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.mak (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.mak Sat Feb 3 08:46:13 2007
@@ -0,0 +1,25 @@
+#####################################
+# UNIX Makefile for a UIMACPP application
+#####################################
+
+# name of the annotator to be created
+TARGET_FILE=SofaExampleApplication
+
+# list of user's object files to be linked when building the application
+OBJS=SofaExampleApplication.o
+
+#Use this var to pass additional user-defined parameters to the compiler
+USER_CFLAGS=
+
+#Use this var to pass additional user-defined parameters to the linker
+USER_LINKFLAGS=
+
+# Set DEBUG=1 for a debug build (if not 1 a ship build will result)
+DEBUG=1
+
+# Set DLL_BUILD=1 to build an annotator (shared library)
+# if not 1 an executable binary will be built
+DLL_BUILD=0
+
+# include file with generic compiler instructions
+include $(UIMACPP_HOME)/lib/base.mak
Added: incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.vcproj
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.vcproj?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.vcproj (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaExampleApplication.vcproj Sat Feb 3 08:46:13 2007
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="SofaExampleApplication"
+ ProjectGUID="{9F230EC0-DB18-46AC-BB02-DC1E6974A463}"
+ RootNamespace="SofaExampleApplication"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(InputDir)"
+ IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ IgnoreStandardIncludePath="FALSE"
+ MinimalRebuild="TRUE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="xerces-c_2.lib icuuc.lib uimaD.lib libapr$(APR_VER).lib"
+ OutputFile="$(OutDir)\SofaExampleApplication.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+ SubSystem="1"
+ 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="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="TRACEOFF;NDEBUG;WIN32;_CONSOLE"
+ MinimalRebuild="FALSE"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="xerces-c_2.lib icuuc.lib uima.lib libapr$(APR_VER).lib"
+ OutputFile="$(OutDir)\SofaExampleApplication.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="FALSE"
+ ProgramDatabaseFile="$(OutDir)/$(TargetName).pdb"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ 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="SofaExampleApplication.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/examples/src/SofaExampleApplication.vcproj
------------------------------------------------------------------------------
svn:eol-style = CRLF
Added: incubator/uima/uimacpp/trunk/examples/src/SofaStreamHandlerFile.mak
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaStreamHandlerFile.mak?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaStreamHandlerFile.mak (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaStreamHandlerFile.mak Sat Feb 3 08:46:13 2007
@@ -0,0 +1,25 @@
+#####################################
+# UNIX Makefile for a UIMACPP annotator
+#####################################
+
+# name of the annotator to be created
+TARGET_FILE=SofaStreamHandlerFile
+
+# list of user's object files to be linked when building the annotator
+OBJS=SofaStreamHandlerFile.o
+
+#Use this var to pass additional user-defined parameters to the compiler
+USER_CFLAGS=
+
+#Use this var to pass additional user-defined parameters to the linker
+USER_LINKFLAGS=
+
+# Set DEBUG=1 for a debug build (if not 1 a ship build will result)
+DEBUG=1
+
+# Set DLL_BUILD=1 to build an annotator (shared library)
+# if not 1 an executable binary will be built
+DLL_BUILD=1
+
+# include file with generic compiler instructions
+include $(UIMACPP_HOME)/lib/base.mak
Added: incubator/uima/uimacpp/trunk/examples/src/SofaStreamHandlerFile.vcproj
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/SofaStreamHandlerFile.vcproj?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/SofaStreamHandlerFile.vcproj (added)
+++ incubator/uima/uimacpp/trunk/examples/src/SofaStreamHandlerFile.vcproj Sat Feb 3 08:46:13 2007
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="SofaStreamHandlerFile"
+ ProjectGUID="{69C8A769-7CEC-4D2A-B189-FE19606577B7}"
+ RootNamespace="DaveDetector"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(InputDir)"
+ IntermediateDirectory="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ MinimalRebuild="TRUE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libapr$(APR_VER).lib xerces-c_2.lib icuuc.lib uimaD.lib"
+ OutputFile="$(OutDir)/SofaStreamHandlerFile.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(IntDir)\$(TargetName)"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/$(TargetName).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="$(ConfigurationName)\$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ AdditionalIncludeDirectories=""$(UIMACPP_HOME)\include";"$(UIMACPP_HOME)\include\apr""
+ PreprocessorDefinitions="TRACEOFF;NDEBUG;WIN32;_WINDOWS;_USRDLL"
+ MinimalRebuild="FALSE"
+ ExceptionHandling="TRUE"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ ProgramDataBaseFileName="$(IntDir)/$(TargetName).pdb"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libapr$(APR_VER).lib xerces-c_2.lib icuuc.lib uima.lib"
+ OutputFile="$(OutDir)/SofaStreamHandlerFile.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(UIMACPP_HOME)\lib""
+ GenerateDebugInformation="FALSE"
+ ProgramDatabaseFile="$(IntDir)\$(TargetName)"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/$(TargetName).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/examples/src/SofaStreamHandlerFile.vcproj
------------------------------------------------------------------------------
svn:eol-style = CRLF
Added: incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.cpp?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.cpp (added)
+++ incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.cpp Sat Feb 3 08:46:13 2007
@@ -0,0 +1,148 @@
+/*
+ * 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 "uima/api.hpp"
+#include "uima/dirwalk.hpp"
+#include "uima/xmlwriter.hpp"
+
+using namespace uima;
+
+
+class XCasWriterCasConsumer : public Annotator {
+private:
+ UnicodeString usOutDir;
+ std::string strOutDir;
+ bool writeFile;
+ int docnum;
+
+ /* We have a separate function getConfigValues()
+ for initialize() and reconfigure()
+ */
+ TyErrorId getConfigValues() {
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+
+public:
+
+ XCasWriterCasConsumer(void) {
+ cout << "XCasWriterCasConsumer: Constructor" << endl;
+ }
+
+ ~XCasWriterCasConsumer(void) {
+ cout << "XCasWriterCasConsumer: Destructor" << endl;
+ }
+
+ /** */
+ TyErrorId initialize(AnnotatorContext & rclAnnotatorContext) {
+ cout << "XCasWriterCasConsumer: initialize()" << endl;
+
+ if (rclAnnotatorContext.isParameterDefined("OutputDirectory") &&
+ rclAnnotatorContext.extractValue("OutputDirectory", usOutDir) == UIMA_ERR_NONE) {
+
+ /* log the configuration parameter setting */
+ rclAnnotatorContext.getLogger().logMessage("OutputDirectory = '" + usOutDir + "'");
+
+ /* create the directory if it does not exist */
+ strOutDir = UnicodeStringRef(usOutDir).asUTF8();
+ util::Location location(strOutDir.c_str());
+
+ if (location.isExistent() ) {
+ writeFile=true;
+ } else {
+ location.makeDirectory();
+ }
+ writeFile = true;
+
+ cout << "XCasWriterCasConsumer::initialize() .. creates xcas files in directory "
+ << usOutDir << endl;
+ } else {
+ rclAnnotatorContext.getLogger().logMessage("OutputDirectory not specified. XCAS will be written to stdout.");
+ writeFile=false;
+ cout << "XCasWriterCasConsumer::initialize() .. writes xcas to standard out. "
+ << endl;
+ }
+ docnum=0;
+
+
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+
+ TyErrorId typeSystemInit(TypeSystem const & crTypeSystem) {
+ cout << "XCasWriterCasConsumer: typeSystemInit()" << endl;
+ return(TyErrorId)UIMA_ERR_NONE;
+ }
+
+ /** */
+ TyErrorId destroy() {
+ cout << "XCasWriterCasConsumer: destroy()" << endl;
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+
+ TyErrorId process(CAS & rCAS, const ResultSpecification& spec) {
+ cout << "XCasWriterCasConsumer: process() begins" << endl;
+
+ XCASWriter writer(rCAS, true);
+
+ if (writeFile) {
+ /* construct a filename */
+ stringstream outfn;
+ outfn << strOutDir << "/doc" << docnum++ << ".xcas";
+ outfn << flush;
+ cout << "XCasWriterCasConsumer::process() xcas file " << outfn.str() << endl;
+
+ //open a file stream for output xcas
+ ofstream file;
+ file.open (outfn.str().c_str(), ios::out | ios::binary);
+ if ( !file ) {
+ cerr << "XCasWriterCasConsumer: Error opening output xcas: " << outfn.str() << endl;
+ return(TyErrorId) UIMA_ERR_USER_ANNOTATOR_COULD_NOT_PROCESS;
+ }
+
+ writer.write(file);
+ file.close();
+ } else {
+ cout << endl;
+ writer.write(cout);
+ cout << endl;
+ }
+
+ cout << "XCasWriterCasConsumer: process() ends" << endl;
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+
+ TyErrorId batchProcessComplete() {
+ cout << "XCasWriterCasConsumer: batchProcessComplete()" << endl;
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+ TyErrorId collectionProcessComplete() {
+ cout << "XCasWriterCasConsumer: collectionProcessComplete()" << endl;
+ return (TyErrorId)UIMA_ERR_NONE;
+ }
+
+
+};
+
+// This macro exports an entry point that is used to create the annotator.
+
+MAKE_AE(XCasWriterCasConsumer);
Propchange: incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.mak
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.mak?view=auto&rev=503238
==============================================================================
--- incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.mak (added)
+++ incubator/uima/uimacpp/trunk/examples/src/XCasWriterCasConsumer.mak Sat Feb 3 08:46:13 2007
@@ -0,0 +1,25 @@
+#####################################
+# UNIX Makefile for a UIMACPP annotator
+#####################################
+
+# name of the annotator to be created
+TARGET_FILE=XCasWriterCasConsumer
+
+# list of user's object files to be linked when building the annotator
+OBJS=XCasWriterCasConsumer.o
+
+#Use this var to pass additional user-defined parameters to the compiler
+USER_CFLAGS=
+
+#Use this var to pass additional user-defined parameters to the linker
+USER_LINKFLAGS=
+
+# Set DEBUG=1 for a debug build (if not 1 a ship build will result)
+DEBUG=1
+
+# Set DLL_BUILD=1 to build an annotator (shared library)
+# if not 1 an executable binary will be built
+DLL_BUILD=1
+
+# include file with generic compiler instructions
+include $(UIMACPP_HOME)/lib/base.mak