Search in sources :

Example 26 with ResourceManager

use of edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager in project cogcomp-nlp by CogComp.

the class LemmatizerTATest method stanfordTest.

@Test
public void stanfordTest() {
    Properties props = new Properties();
    // set non-default lemmatizer constructor params
    props.setProperty(LemmatizerConfigurator.USE_STNFRD_CONVENTIONS.key, LemmatizerConfigurator.TRUE);
    // since we are calling
    props.setProperty(LemmatizerConfigurator.IS_LAZILY_INITIALIZED.key, LemmatizerConfigurator.FALSE);
    ResourceManager rm = new LemmatizerConfigurator().getConfig(new ResourceManager(props));
    IllinoisLemmatizer lem = new IllinoisLemmatizer(new LemmatizerConfigurator().getConfig(rm));
    String lemma = lem.getLemma("me", "PRP");
    assertTrue(lemma.equals("i"));
}
Also used : ResourceManager(edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager) Properties(java.util.Properties) Test(org.junit.Test)

Example 27 with ResourceManager

use of edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager in project cogcomp-nlp by CogComp.

the class CuratorFactoryTest method testGetIndividualTextAnnotationViews.

@Test
public void testGetIndividualTextAnnotationViews() throws IOException {
    // if we are running the test on Semaphore, ignore this test, since Gurobi is not provided on Semaphore.
    if (System.getenv().containsKey("CI") && System.getenv().get("CI").equals("true") && System.getenv().containsKey("SEMAPHORE") && System.getenv().get("SEMAPHORE").equals("true") && System.getenv().containsKey("CIRCLECI") && System.getenv().get("CIRCLECI").equals("true")) {
        System.out.println("Running the test on Semaphore. Skipping this test  . . . ");
    } else {
        TextAnnotation ta = null;
        try {
            ResourceManager rm = new ResourceManager(CONFIG_FILE);
            ta = curator.createBasicTextAnnotation("test", "0", text);
            for (String viewName : rm.getCommaSeparatedValues(CuratorConfigurator.VIEWS_TO_ADD.key)) curator.addView(ta, viewName);
        } catch (AnnotatorException e) {
            e.printStackTrace();
            fail(e.getMessage());
        } catch (IllegalArgumentException e) {
            // If this is a "connection timeout" exception we can ignore it
            if (e.getMessage().contains("Connection timed out"))
                return;
        }
        testViews(ta);
    }
}
Also used : AnnotatorException(edu.illinois.cs.cogcomp.annotation.AnnotatorException) ResourceManager(edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) Test(org.junit.Test)

Example 28 with ResourceManager

use of edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager in project cogcomp-nlp by CogComp.

the class ExternalAnnotatorServiceFactory method buildPipeline.

/**
     * create an AnnotatorService with components specified by the ResourceManager (to override
     * defaults in {@link ExternalToolsConfigurator}
     *
     * @param rm non-default config options
     * @return AnnotatorService with specified NLP components
     * @throws IOException
     * @throws AnnotatorException
     */
public static BasicAnnotatorService buildPipeline(ResourceManager rm) throws IOException, AnnotatorException {
    // Merges default configuration with the user-specified overrides.
    ResourceManager fullRm = (new ExternalToolsConfigurator()).getConfig(rm);
    Boolean splitOnDash = fullRm.getBoolean(ExternalToolsConfigurator.SPLIT_ON_DASH);
    boolean isSentencePipeline = fullRm.getBoolean(ExternalToolsConfigurator.USE_SENTENCE_PIPELINE.key);
    TextAnnotationBuilder taBldr = new TokenizerTextAnnotationBuilder(new StatefulTokenizer(splitOnDash));
    Map<String, Annotator> annotators = buildAnnotators();
    return isSentencePipeline ? new SentencePipeline(taBldr, annotators, fullRm) : new BasicAnnotatorService(taBldr, annotators, fullRm);
}
Also used : TokenizerTextAnnotationBuilder(edu.illinois.cs.cogcomp.nlp.utility.TokenizerTextAnnotationBuilder) TokenizerTextAnnotationBuilder(edu.illinois.cs.cogcomp.nlp.utility.TokenizerTextAnnotationBuilder) StatefulTokenizer(edu.illinois.cs.cogcomp.nlp.tokenizer.StatefulTokenizer) ExternalToolsConfigurator(edu.illinois.cs.cogcomp.pipeline.common.ExternalToolsConfigurator) ResourceManager(edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager)

Aggregations

ResourceManager (edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager)28 Properties (java.util.Properties)14 Test (org.junit.Test)8 TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)6 StatefulTokenizer (edu.illinois.cs.cogcomp.nlp.tokenizer.StatefulTokenizer)5 TokenizerTextAnnotationBuilder (edu.illinois.cs.cogcomp.nlp.utility.TokenizerTextAnnotationBuilder)5 AnnotatorException (edu.illinois.cs.cogcomp.annotation.AnnotatorException)4 ChunkerAnnotator (edu.illinois.cs.cogcomp.chunker.main.ChunkerAnnotator)3 DepAnnotator (edu.illinois.cs.cogcomp.depparse.DepAnnotator)3 NERAnnotator (edu.illinois.cs.cogcomp.ner.NERAnnotator)3 PipelineConfigurator (edu.illinois.cs.cogcomp.pipeline.common.PipelineConfigurator)3 Stanford331Configurator (edu.illinois.cs.cogcomp.pipeline.common.Stanford331Configurator)3 POSAnnotator (edu.illinois.cs.cogcomp.pos.POSAnnotator)3 PrepSRLAnnotator (edu.illinois.cs.cogcomp.prepsrl.PrepSRLAnnotator)3 POSTaggerAnnotator (edu.stanford.nlp.pipeline.POSTaggerAnnotator)3 ParserAnnotator (edu.stanford.nlp.pipeline.ParserAnnotator)3 IOException (java.io.IOException)3 TextAnnotationBuilder (edu.illinois.cs.cogcomp.annotation.TextAnnotationBuilder)2 SpanLabelView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.SpanLabelView)2 InFile (edu.illinois.cs.cogcomp.ner.IO.InFile)2