Do I need to rewrite my entire java project if I want to use a single UIMA-dependent library?
Asked Answered
S

1

1

I want to use https://code.google.com/p/heideltime/ in a java project. That code "fits into the UIMA pipeline", which is something I don't understand at all. UIMA looks like it's designed to solve a ton of problems that I don't have, so I'd just like to get the minimal amount of UIMA needed to run that code.

Is there a simple example out there of how I can run a simple UIMA program?

I've added

    <dependency>
        <groupId>org.uimafit</groupId>
        <artifactId>uimafit</artifactId>
        <version>1.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.uima</groupId>
        <artifactId>uimaj-core</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.uima</groupId>
        <artifactId>uimaj-tools</artifactId>
        <version>2.4.0</version>
    </dependency>

to my pom.xml but for some reason maven still won't compile this:

import org.apache.uima.jcas.JCas;
import org.apache.uima.util.Level;
import org.uimafit.component.JCasAnnotator_ImplBase;
import org.uimafit.descriptor.ConfigurationParameter;
import org.uimafit.descriptor.TypeCapability;
import org.uimafit.examples.tutorial.type.RoomNumber;

public class RoomNumberAnnotatorPipeline {

        public static void main(String[] args) throws Exception {
                String text = "The meeting was moved from Yorktown 01-144 to Hawthorne 1S-W33.";
                TypeSystemDescription tsd = createTypeSystemDescription( "org.uimafit.examples.tutorial.type.RoomNumber");
                JCas jCas = createJCas(tsd);
//                jCas.setDocumentText(text);
//                AnalysisEngine analysisEngine = createPrimitive(RoomNumberAnnotator.class, tsd);
//                analysisEngine.process(jCas);
//
//                for (RoomNumber roomNumber : select(jCas, RoomNumber.class)) {
//                        System.out.println(roomNumber.getCoveredText() + "\tbuilding = "
//                                        + roomNumber.getBuilding());
//                }
        }
}


[ERROR] symbol  : class TypeSystemDescription
[ERROR] location: class com.stackoverflow.RoomNumberAnnotatorPipeline

enter image description here

Are UIMA dependencies somehow more substantial than a typical java library? Is it not enough to just pull UIMA from Maven Central and start using their classes in my existing code?

ok, I somehow got this example working (I have no idea what it is, and am still confused why it was not working before) I am still not able to use heideltime:

package org.ryan;

import static org.uimafit.factory.AnalysisEngineFactory.createPrimitive;
import static org.uimafit.factory.JCasFactory.createJCas;
import static org.uimafit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription;
import static org.uimafit.util.JCasUtil.select;

import org.apache.uima.UIMAException;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.uimafit.examples.tutorial.ex1.RoomNumberAnnotator;
import org.uimafit.examples.tutorial.type.RoomNumber;


/**
 * Hello world!
 *
 */
public class UIMAWTF 
{
    public static void main( String[] args ) throws UIMAException
    {
        String text = "The meeting was moved from Yorktown 01-144 to Hawthorne 1S-W33. Today is May 5, 2013.";

        TypeSystemDescription tsd = createTypeSystemDescription("org.uimafit.examples.tutorial.type.RoomNumber");
        JCas jCas = createJCas(tsd);

        jCas.setDocumentText(text);
        AnalysisEngine analysisEngine = createPrimitive(RoomNumberAnnotator.class, tsd);
        analysisEngine.process(jCas);

        for (RoomNumber roomNumber : select(jCas, RoomNumber.class)) {
            System.out.println(roomNumber.getCoveredText() + "\tbuilding = "
                    + roomNumber.getBuilding());
        }   

    }
}

edit Now trying:

HeidelTimeStandalone hts_sci = new HeidelTimeStandalone(Language.ENGLISH, DocumentType.NEWS, OutputType.TIMEML);//, configPath);
dates = hts_sci.process("19-Nov-2013", new Date(2012,01,05), new TimeMLResultFormatter());          

System.out.println(dates);

Getting:

Jul 3, 2013 2:02:41 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone initialize
INFO: HeidelTimeStandalone initialized with language english
Jul 3, 2013 2:02:41 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone readConfigFile
INFO: trying to read in file config.props
java.lang.NullPointerException
    at java.io.Reader.<init>(Reader.java:61)
    at java.io.InputStreamReader.<init>(InputStreamReader.java:55)
    at de.unihd.dbs.uima.annotator.heideltime.resources.GenericResourceManager.readResourcesFromDirectory(GenericResourceManager.java:45)
    at de.unihd.dbs.uima.annotator.heideltime.resources.NormalizationManager.<init>(NormalizationManager.java:58)
    at de.unihd.dbs.uima.annotator.heideltime.resources.NormalizationManager.getInstance(NormalizationManager.java:73)
    at de.unihd.dbs.uima.annotator.heideltime.HeidelTime.initialize(HeidelTime.java:143)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.initialize(HeidelTimeStandalone.java:153)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.<init>(HeidelTimeStandalone.java:128)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.<init>(HeidelTimeStandalone.java:112)
    at com.hrl.issl.osi.date.LocalHeidelTime.main(LocalHeidelTime.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
    at java.lang.Thread.run(Thread.java:662)
Jul 3, 2013 2:02:41 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone initialize
WARNING: HeidelTime could not be initialized
java.lang.NullPointerException
    at org.apache.uima.util.XMLInputSource.<init>(XMLInputSource.java:118)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.initialize(HeidelTimeStandalone.java:163)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.<init>(HeidelTimeStandalone.java:128)
    at de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.<init>(HeidelTimeStandalone.java:112)
    at com.hrl.issl.osi.date.LocalHeidelTime.main(LocalHeidelTime.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
    at java.lang.Thread.run(Thread.java:662)
Jul 3, 2013 2:02:41 PM de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone initialize
WARNING: JCas factory could not be initialized
Saltillo answered 24/6, 2013 at 19:31 Comment(9)
> for some reason maven still won't compile this: What about some error log?Heroism
Right, it's there now.Saltillo
There is no import for TypeSystemDescription - is it a class in the same package?Heroism
According to uima.apache.org/downloads/releaseDocs/2.3.0-incubating/docs/api/… you should import org.apache.uima.resource.metadata.*Heroism
ugh. I assumed it was part of UIMA. grepcode.com/file/repo1.maven.org/maven2/org.uimafit/…Saltillo
It is... but you still have to import it - or name it with full package name - compare your linked sourcesHeroism
Yeah, the problem I have is that maven seems to not find anything UIMA related. I've never had a problem like this with maven before.Saltillo
Did you try with the uimafit import only? It should workDonnydonnybrook
Yes, but it's not doing it. I am really stumped here. I add maven dependencies to my project all the time, with no problems. UIMA is something else.Saltillo
D
2

It says on HeidelTime's homepage

HeidelTime is available as UIMA annotator and as standalone version.

There is a standalone version that I mavenized here. You should be able to hack de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.java's main to fit you needs.

Donnydonnybrook answered 24/6, 2013 at 21:7 Comment(8)
I may have to give that another try. My issue is that I am trying to get this into a mapreduce job, and non-java code makes that real tough for me. Heideltime's "standalone" version requires some perl stuff that I have not figured a way around yet.Saltillo
Also, you mention that you did not use the Standalone version? Do you have an example? I can get some basic UIMA stuff working, but Heideltime is not not mavenized and I still can't figure out if it's written in Java.Saltillo
Thanks, that is really helping me. I have almost got HeidelTime working, but I still can't figure out if it's Java code. I know that the "standalone" version requires that I run some perl (ie "TreeTagger"). Does the UIMA version also share this requirement? I won't be able to use HeidelTime in a mapreduce job if there are perl dependencies.Saltillo
Are you sure you need that component (Treetagger)? Maybe you could use code.google.com/p/tt4j/wiki/Usage instead?Donnydonnybrook
Sorry man but I can't get this standalone version working. Lots of Nullpointer exceptions.Saltillo
How much UIMA stuff do I need to surround Heideltime with to use it? I can't find examples anywhere.Saltillo
@rcompton, I am running the standalone version just fine. It does need a bigger ruleset though, it seems. Renaud, are you working on the software at Uni HD?Outlying
@icedwater, no just a user (I study at EPFL). In fact, I developed a UIMA component to detect any kind of unit of measure, will release it soon.Donnydonnybrook

© 2022 - 2024 — McMap. All rights reserved.