HI
*Michael Baessler*
i got the source code(UIMA EXAMPLES)
for what i am loking for.
Adam amd matt are helping me.i will send u my ExampleApplication which is
copied from source code of ExampleApplication.it is working but it is not
reading what i want.
so Michael if u have time just go through it tell me what to do.
My exact douat is here
ae.setConfigParameterValue("StringsToAnnotate", *new* String[]
{"Michael","UIMA","Vijay"});
here i am frowarding it as configaration parameter but it is not reading
these strings.insted it is reading from the analysis enginne where i have i
given name of the class file the class and string i have given it there.
thank u
vijay
On 9/17/07, Michael Baessler <[EMAIL PROTECTED]> wrote:
> Sorry I can't find your posting. Where do you have added your
> requirements?
>
> -- Michael
>
> Danai Wiriyayanyongsuk wrote:
> > Sorry for taking a while for posting. It is now posted in the page. All
> > comments/suggestions/discussions are very welcome.
> >
> > Thanks,
> > Danai Wiriyayanyongsuk
> >
> > On 9/1/07, Michael Baessler <[EMAIL PROTECTED]> wrote:
> >
> >> Since this is a new requirement for UIMA can you please add it with
> some
> >> information to the
> >> UIMA wiki? There is a section where we gather UIMA requirements.
> >> http://cwiki.apache.org/confluence/display/UIMA/UIMA+Requirements
> >>
> >> Thanks!
> >>
> >> -- Michael
> >>
>
package com.iton.uima;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import com.ibm.uima.UIMAFramework;
import com.ibm.uima.analysis_engine.AnalysisEngine;
import com.ibm.uima.analysis_engine.AnalysisEngineProcessException;
import com.ibm.uima.cas.CAS;
import com.ibm.uima.resource.ResourceSpecifier;
import com.ibm.uima.util.XMLInputSource;
import com.ibm.uima.examples.PrintAnnotations;
/**
* An example application that reads documents from files, sends them
* though an Analysis Engine, and prints all discovered annotations to
* System.out.
* <p>
* The application takes two arguments:
* <ol type="1">
* <li>The path to an XML descriptor for the Analysis Engine to be executed</li>
* <li>An input directory containing files to be processed</li>
* </ol>
*/
public class ExampleApplication
{
/**
* Main program.
*
* @param args Command-line arguments - see class description
*/
public static void main(String[] args)
{
try
{
File taeDescriptor = new File("descriptor\\AnalysisEngine.xml");
File inputDir = new File("input");
String file1 = "output.txt";
String file2 = "package.html";
System.out.println("file is:"+file1);
System.out.println("file 2 is :"+file2);
//Read and validate command line arguments
boolean validArgs = false;
/*if (args.length == 2)
{
taeDescriptor = new File(file1);
inputDir = new File(file2);
validArgs = taeDescriptor.exists() && !taeDescriptor.isDirectory() &&
inputDir.isDirectory();
}*/
//System.out.println("length is:"+args.length);
{
//get Resource Specifier from XML file
XMLInputSource in = new XMLInputSource(taeDescriptor);
ResourceSpecifier specifier =
UIMAFramework.getXMLParser().parseResourceSpecifier(in);
//for debugging, output the Resource Specifier
//System.out.println(specifier);
//create Analysis Engine
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
ae.setConfigParameterValue("StringsToAnnotate", new String[]
{"Michael","UIMA","Vijay"});
//create a CAS
CAS cas = ae.newCAS();
//get all files in the input directory
File[] files = inputDir.listFiles();
if (files == null)
{
System.out.println("No files to process");
}
else
{
//process documents
for(int i = 0; i < files.length; i++)
{
if (!files[i].isDirectory())
{
processFile(files[i], ae, cas);
}
}
}
ae.destroy();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
/**
* Prints usage message.
*/
private static void printUsageMessage()
{
System.err.println("Usage: java com.ibm.uima.example.ExampleApplication "
+ "</exampleApplication/descriptor/AnalysisEngine.xml>
</exampleApplication/input> </exampleApplication/output>");
}
/**
* Processes a single XML file and prints annotations to System.out
*
* @param aFile file to process
* @param aAE Analysis Engine that will process the file
* @param aCAS CAS that will be used to hold analysis results
*/
private static void processFile( File aFile, AnalysisEngine aAE,
CAS aCAS)
throws IOException, AnalysisEngineProcessException
{
System.out.println("Processing file " + aFile.getName());
FileInputStream fis = null;
try
{
//read file
fis = new FileInputStream(aFile );
byte[] contents = new byte[(int)aFile.length() ];
fis.read( contents );
String document = new String(contents, "UTF-8");
document = document.trim();
//put document text in CAS
aCAS.setDocumentText(document);
//process
aAE.process(aCAS);
//print annotations to System.out
PrintAnnotations.printAnnotations(aCAS, System.out);
//reset the CAS to prepare it for processing the next document
aCAS.reset();
}
finally
{
try
{
if ( fis != null )
fis.close();
}
catch( Exception ex )
{
ex.printStackTrace();
}
}
}
}