use of edu.illinois.cs.cogcomp.annotation.AnnotatorException in project cogcomp-nlp by CogComp.
the class CuratorFactoryTest method testGetTextAnnotation.
@Test
public void testGetTextAnnotation() {
// 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 {
ta = curator.createBasicTextAnnotation("test", "0", text);
} 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;
}
assertTrue(ta.hasView(ViewNames.SENTENCE));
assertTrue(ta.hasView(ViewNames.TOKENS));
List<Constituent> tokens = ta.getView(ViewNames.TOKENS).getConstituents();
List<Constituent> sentences = ta.getView(ViewNames.SENTENCE).getConstituents();
assertEquals(NUM_TOKS, tokens.size());
assertEquals(NUM_SENTS, sentences.size());
}
}
use of edu.illinois.cs.cogcomp.annotation.AnnotatorException in project cogcomp-nlp by CogComp.
the class CuratorFactoryTest method testGetAllTextAnnotationViews.
@Test
public void testGetAllTextAnnotationViews() {
// 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 {
ta = curator.createAnnotatedTextAnnotation("test", "0", text);
} 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);
}
}
use of edu.illinois.cs.cogcomp.annotation.AnnotatorException 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);
}
}
use of edu.illinois.cs.cogcomp.annotation.AnnotatorException in project cogcomp-nlp by CogComp.
the class CuratorAnnotatorService method addView.
@Override
public boolean addView(TextAnnotation ta, String viewName) throws AnnotatorException {
if (ViewNames.SENTENCE.equals(viewName) || ViewNames.TOKENS.equals(viewName))
return false;
if (!viewProviders.containsKey(viewName))
throw new AnnotatorException("View " + viewName + " is not supported.");
boolean isUpdated = false;
// AnnotatorService will not support caching
if (ta.hasView(viewName))
return false;
Annotator annotator = viewProviders.get(viewName);
for (String prereqView : annotator.getRequiredViews()) isUpdated = addView(ta, prereqView);
ta.addView(annotator);
// AnnotatorService will not support caching
return isUpdated;
}
Aggregations