protected void throwNotCachedException(String corpusId, String docId, String text) throws AnnotatorException { throw new AnnotatorException("text with corpusid '" + corpusId + "', docId '" + docId + "', value '" + text + "' was not in cache, and the field 'throwExceptionIfNotCached' is 'true'."); }
e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); throw new AnnotatorException(e.getMessage());
/** * return the next annotation object. Don't forget to increment currentAnnotationId. * * @return an annotation object. */ @Override public XmlTextAnnotation next() { String data; try { data = LineIO.slurp(currentfile); } catch (FileNotFoundException e1) { this.badFiles.add(this.currentfile); return null; } catch (Throwable e1) { e1.printStackTrace(); return null; } try { XmlTextAnnotation ta = nextAnnotation(data, currentfile); return ta; } catch (AnnotatorException e) { e.printStackTrace(); throw new IllegalStateException(e); } }
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { lazyLoadClusters(brownClustersFile); if (!ta.hasView(viewGenerator.getViewName())) { synchronized (BrownClusterFeatureExtractor.class) { View view = null; try { view = viewGenerator.getView(ta); } catch (AnnotatorException e) { e.printStackTrace(); throw new EdisonException(e.getMessage()); } ta.addView(viewGenerator.getViewName(), view); } } SpanLabelView view = (SpanLabelView) ta.getView(viewGenerator.getViewName()); String word = ta.getToken(wordPosition); // What follows has a subtle bug: view.getLabel only gets the first // label for the word. A word can have multiple brown clusters though! // This has been fixed below. // String cluster = view.getLabel(wordPosition); // // return getBrownClusters(word, cluster); Set<Feature> features = new LinkedHashSet<>(); for (Constituent c : view.getConstituentsCoveringToken(wordPosition)) { String cluster = c.getLabel(); features.addAll(getBrownClusters(word, cluster)); } return features; }
annotator.getView(ta); } catch (AnnotatorException e) { fail("AnnotatorException thrown!\n" + e.getMessage()); tca.deleteTimex(); } catch (AnnotatorException e) { fail("Exception while adding TIMEX3 VIEW " + e.getStackTrace());
annotator.getView(ta); } catch (AnnotatorException e) { fail("AnnotatorException thrown!\n" + e.getMessage());
/** * return the next annotation object. Don't forget to increment currentAnnotationId. * * @return an annotation object. */ @Override public XmlTextAnnotation next() { String data; try { data = LineIO.slurp(currentfile); } catch (FileNotFoundException e1) { this.badFiles.add(this.currentfile); return null; } catch (Throwable e1) { e1.printStackTrace(); return null; } try { XmlTextAnnotation ta = nextAnnotation(data, currentfile); return ta; } catch (AnnotatorException e) { e.printStackTrace(); throw new IllegalStateException(e); } }
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { lazyLoadClusters(brownClustersFile); if (!ta.hasView(viewGenerator.getViewName())) { synchronized (BrownClusterFeatureExtractor.class) { View view = null; try { view = viewGenerator.getView(ta); } catch (AnnotatorException e) { e.printStackTrace(); throw new EdisonException(e.getMessage()); } ta.addView(viewGenerator.getViewName(), view); } } SpanLabelView view = (SpanLabelView) ta.getView(viewGenerator.getViewName()); String word = ta.getToken(wordPosition); // What follows has a subtle bug: view.getLabel only gets the first // label for the word. A word can have multiple brown clusters though! // This has been fixed below. // String cluster = view.getLabel(wordPosition); // // return getBrownClusters(word, cluster); Set<Feature> features = new LinkedHashSet<>(); for (Constituent c : view.getConstituentsCoveringToken(wordPosition)) { String cluster = c.getLabel(); features.addAll(getBrownClusters(word, cluster)); } return features; }
annotator.getView(ta); } catch (AnnotatorException e) { fail("AnnotatorException thrown!\n" + e.getMessage()); tca.deleteTimex(); } catch (AnnotatorException e) { fail("Exception while adding TIMEX3 VIEW " + e.getStackTrace());
annotator.getView(ta); } catch (AnnotatorException e) { fail("AnnotatorException thrown!\n" + e.getMessage());
protected void throwNotCachedException(String corpusId, String docId, String text) throws AnnotatorException { throw new AnnotatorException("text with corpusid '" + corpusId + "', docId '" + docId + "', value '" + text + "' was not in cache, and the field 'throwExceptionIfNotCached' is 'true'."); }
e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); throw new AnnotatorException(e.getMessage());
public void RunPipelineWithCorpusReader(AnnotationReader reader) { Iterator<TextAnnotation> iter = reader.iterator(); boolean replaceExistingViews = false; while (iter.hasNext()) { TextAnnotation ta = iter.next(); try { ta = pipeline.annotateTextAnnotation(ta, replaceExistingViews); } catch (AnnotatorException e) { e.printStackTrace(); logger.error("failed to preprocess ta with id '" + ta.getId() + "'."); } logger.debug("processed file (assumed this is TextAnnotation docid): '" + ta.getId() + "'"); } }
annotator.getView(ta); } catch (AnnotatorException e) { fail("AnnotatorException thrown!\n" + e.getMessage()); tca.addView(ta); } catch (AnnotatorException e) { fail("Exception while adding TIMEX3 VIEW " + e.getStackTrace());
@Override public View getView(TextAnnotation ta) throws AnnotatorException { try { return curatorClient.getTextAnnotationView(ta, viewName); } catch (TException | AnnotationFailedException | SocketException | ServiceUnavailableException e) { throw new AnnotatorException(e.getMessage()); } }
public void RunPipelineWithCorpusReader(AnnotationReader reader) { Iterator<TextAnnotation> iter = reader.iterator(); boolean replaceExistingViews = false; while (iter.hasNext()) { TextAnnotation ta = iter.next(); try { ta = pipeline.annotateTextAnnotation(ta, replaceExistingViews); } catch (AnnotatorException e) { e.printStackTrace(); logger.error("failed to preprocess ta with id '" + ta.getId() + "'."); } logger.debug("processed file (assumed this is TextAnnotation docid): '" + ta.getId() + "'"); } }
annotator.getView(ta); } catch (AnnotatorException e) { fail("AnnotatorException thrown!\n" + e.getMessage()); tca.addView(ta); } catch (AnnotatorException e) { fail("Exception while adding TIMEX3 VIEW " + e.getStackTrace());
/** * Add a new {@link Annotator} to the service. All prerequisite views must already be provided by other annotators * known to this {@link AnnotatorService}. * * @param annotator the {@link Annotator} to be added. * @throws {@link AnnotatorException} if the annotator requires views that cannot be satisfied. */ @Override public void addAnnotator(Annotator annotator) throws AnnotatorException { for ( String prereq : annotator.getRequiredViews() ) if ( !viewProviders.containsKey( prereq ) ) throw new AnnotatorException( "Prerequisite view '" + prereq + "' is not provided by other annotators." ); }
ta = findNextTree(); } catch (AnnotatorException e) { e.printStackTrace(); throw new IllegalStateException(e);
/** * Add a new {@link Annotator} to the service. All prerequisite views must already be provided by other annotators * known to this {@link AnnotatorService}. * * @param annotator the {@link Annotator} to be added. * @throws {@link AnnotatorException} if the annotator requires views that cannot be satisfied. */ @Override public void addAnnotator(Annotator annotator) throws AnnotatorException { for ( String prereq : annotator.getRequiredViews() ) if ( !viewProviders.containsKey( prereq ) ) throw new AnnotatorException( "Prerequisite view '" + prereq + "' is not provided by other annotators." ); }