HI adam lally,
i have gone through that particular section,i have
given code like this
PrintAnnotations.*printAnnotations*(aCAS, out);
FSIndex fsIndex = aCAS.getAnnotationIndex();
aCAS.getJCas().getJFSIndexRepository().getIndex("TestType", TestType.*type*
);
//JCas jc=aCAS.getJCas();
//jc.getJFSIndexRepository().getIndex("allEvents", TestType.type);
Iterator<DocumentAnnotation> itr = fsIndex.iterator();
*while*(itr.hasNext())
{
DocumentAnnotation annot = (DocumentAnnotation)itr.next();
out.println("Test UIMA Servlet Begin::"+annot.getBegin()+"<br>");
out.println("Test UIMA Servlet End::"+annot.getEnd()+"<br>");
out.println("Test UIMA Servlet Content::"+annot.getCoveredText()+"<br>");
out.println("Test UIMA Servlet End::"+annot.getType()+"<br>");
}
aCAS.reset();
but again i am geting same thing an out put like this::::::::::::::
Test UIMA Servlet Begin::0
Test UIMA Servlet End::348
Test UIMA Servlet Content::Hi welcome to UIMA?what it mean?who is working on
this? UIMA stands for unstructured information management
architecture.asper my knowledge Michael who is working on it from long
time and adam who
also works on the same topic. and who is this vijay? he is started learning
this one month back.And sunil is his guide to show the path to him.
Test UIMA Servlet End::uima.tcas.DocumentAnnotation:::::::::::::::::
in tomcat i am getting an error like
*
java.lang.ClassCastException*: com.iton.uima.TestTypestep :5
at com.iton.uima.Clases.ExampleApplication.processFile(*
ExampleApplication.java:169*)
at com.iton.uima.Clases.ExampleApplication.testAnnotation(*
ExampleApplication.java:99*)
at com.iton.uima.Clases.ExampleApplication.main(*ExampleApplication.java:33*
)
i have been trying to rectify it but not getting it.insted of
DocumentAnnotation i have tried TestType also.
can u look in to it...........here i will provide my class here
vijay
On 9/21/07, Adam Lally <[EMAIL PROTECTED]> wrote:
>
> Vijay,
>
> On 9/21/07, vijay vijay <[EMAIL PROTECTED]> wrote:
> > here i have one more douat i have been working on
> how
> > to develop uima annotator as webapplication?in this process i have
> reached
> > where i am able to get the output when i call the servlet in IE
> > webbrowser,but iam getting out put like this
> >
> ><snip/>
> >
> > insted of getting only annotattors i am getting whole thing.
> > here my question is why i am getting an out put like this.
> >
>
> Read this section of the manual:
>
> http://incubator.apache.org/uima/downloads/releaseDocs/2.2.0-incubating/docs/html/tutorials_and_users_guides/tutorials_and_users_guides.html#ugr.tug.aae.reading_results_previous_annotators
>
> Also be sure to do what it says in look at the example code for the
> MeetingAnnotator.
>
> Basically, right now you are running some code that gets an FSIterator
> that returns everything in the CAS, and then you are just outputting
> every FeatureStructure as a String. You'll need to change this to
> iterate only over the types you're interested in, and produce output
> in the format you would like to see.
>
> Read the manual, look through the examples, and do some
> trial-and-error, modifying your code to see what happens.
>
> -Adam
>
package com.iton.uima;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Iterator;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.cas.CASException;
import com.ibm.uima.cas.FSIndex;
import com.ibm.uima.cas.Type;
import com.ibm.uima.examples.PrintAnnotations;
import com.ibm.uima.jcas.impl.JCas;
import com.ibm.uima.jcas.tcas.DocumentAnnotation;
import com.ibm.uima.resource.ResourceSpecifier;
import com.ibm.uima.util.XMLInputSource;
import com.iton.uima.Clases.ExampleApplication;
import com.iton.uima.Clases.SampleAnnotator;
public class Test extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintStream stream = new
PrintStream(response.getOutputStream());
try
{
File taeDescriptor = new File("descriptor\\aeDescriptor.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"});
ae.reconfigure();
//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, stream);
}
}
}
ae.destroy();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
private static void processFile( File aFile, AnalysisEngine aAE,
CAS aCAS, PrintStream out)
throws IOException,CASException,
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, out);
FSIndex fsIndex = aCAS.getAnnotationIndex();
aCAS.getJCas().getJFSIndexRepository().getIndex("TestType", TestType.type);
//JCas jc=aCAS.getJCas();
//jc.getJFSIndexRepository().getIndex("allEvents",
TestType.type);
Iterator<DocumentAnnotation> itr = fsIndex.iterator();
while(itr.hasNext())
{
DocumentAnnotation annot = (DocumentAnnotation)itr.next();
out.println("Test UIMA Servlet
Begin::"+annot.getBegin()+"<br>");
out.println("Test UIMA Servlet
End::"+annot.getEnd()+"<br>");
out.println("Test UIMA Servlet
Content::"+annot.getCoveredText()+"<br>");
out.println("Test UIMA Servlet
End::"+annot.getType()+"<br>");
}
//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();
}
}
}
}