/** * 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." ); }
/** * 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." ); }
/** * 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 { String[] prerequisites = annotator.getRequiredViews(); for ( String pre : prerequisites ) if ( !this.getAvailableViews().contains( pre ) ) throw new AnnotatorException("Missing prerequisite: " + pre ); this.viewProviders.put( annotator.getViewName(), annotator ); }
/** * 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 { String[] prerequisites = annotator.getRequiredViews(); for ( String pre : prerequisites ) if ( !this.getAvailableViews().contains( pre ) ) throw new AnnotatorException("Missing prerequisite: " + pre ); this.viewProviders.put( annotator.getViewName(), annotator ); }
@Override public boolean addView(TextAnnotation textAnnotation, String viewName, ResourceManager runtimeAttributes) throws AnnotatorException { boolean isUpdated = false; if (ViewNames.SENTENCE.equals(viewName) || ViewNames.TOKENS.equals(viewName)) return false; if ( !textAnnotation.hasView( viewName ) || forceUpdate ) { isUpdated = true; if ( !viewProviders.containsKey(viewName) ) throw new AnnotatorException( "View '" + viewName + "' cannot be provided by this AnnotatorService." ); Annotator annotator = viewProviders.get( viewName ); for ( String prereqView : annotator.getRequiredViews() ) { addView( textAnnotation, prereqView, runtimeAttributes); } View v = annotator.getView(textAnnotation, runtimeAttributes); textAnnotation.addView( annotator.getViewName(), v ); } if (isUpdated && throwExceptionIfNotCached) throwNotCachedException(textAnnotation.getCorpusId(), textAnnotation.getId(), textAnnotation.getText()); return isUpdated; }
@Override public boolean addView(TextAnnotation textAnnotation, String viewName, ResourceManager runtimeAttributes) throws AnnotatorException { boolean isUpdated = false; if (ViewNames.SENTENCE.equals(viewName) || ViewNames.TOKENS.equals(viewName)) return false; if ( !textAnnotation.hasView( viewName ) || forceUpdate ) { isUpdated = true; if ( !viewProviders.containsKey(viewName) ) throw new AnnotatorException( "View '" + viewName + "' cannot be provided by this AnnotatorService." ); Annotator annotator = viewProviders.get( viewName ); for ( String prereqView : annotator.getRequiredViews() ) { addView( textAnnotation, prereqView, runtimeAttributes); } View v = annotator.getView(textAnnotation, runtimeAttributes); textAnnotation.addView( annotator.getViewName(), v ); } if (isUpdated && throwExceptionIfNotCached) throwNotCachedException(textAnnotation.getCorpusId(), textAnnotation.getId(), textAnnotation.getText()); return isUpdated; }
/** * DOES NOT CACHE THE ADDED VIEW!!! * * @param textAnnotation textAnnotation to be modified * @param viewName name of view to be added * @return 'true' if textAnnotation was modified * @throws AnnotatorException */ @Override public boolean addView(TextAnnotation textAnnotation, String viewName) throws AnnotatorException { boolean isUpdated = false; if (ViewNames.SENTENCE.equals(viewName) || ViewNames.TOKENS.equals(viewName)) return false; if ( !textAnnotation.hasView( viewName ) || forceUpdate ) { isUpdated = true; if ( !viewProviders.containsKey(viewName) ) throw new AnnotatorException( "View '" + viewName + "' cannot be provided by this AnnotatorService." ); Annotator annotator = viewProviders.get( viewName ); for ( String prereqView : annotator.getRequiredViews() ) { addView( textAnnotation, prereqView ); } View v = annotator.getView(textAnnotation); textAnnotation.addView( annotator.getViewName(), v ); } if (isUpdated && throwExceptionIfNotCached) throwNotCachedException(textAnnotation.getCorpusId(), textAnnotation.getId(), textAnnotation.getText()); return isUpdated; }
/** * DOES NOT CACHE THE ADDED VIEW!!! * * @param textAnnotation textAnnotation to be modified * @param viewName name of view to be added * @return 'true' if textAnnotation was modified * @throws AnnotatorException */ @Override public boolean addView(TextAnnotation textAnnotation, String viewName) throws AnnotatorException { boolean isUpdated = false; if (ViewNames.SENTENCE.equals(viewName) || ViewNames.TOKENS.equals(viewName)) return false; if ( !textAnnotation.hasView( viewName ) || forceUpdate ) { isUpdated = true; if ( !viewProviders.containsKey(viewName) ) throw new AnnotatorException( "View '" + viewName + "' cannot be provided by this AnnotatorService." ); Annotator annotator = viewProviders.get( viewName ); for ( String prereqView : annotator.getRequiredViews() ) { addView( textAnnotation, prereqView ); } View v = annotator.getView(textAnnotation); textAnnotation.addView( annotator.getViewName(), v ); } if (isUpdated && throwExceptionIfNotCached) throwNotCachedException(textAnnotation.getCorpusId(), textAnnotation.getId(), textAnnotation.getText()); return isUpdated; }
@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; if (ta.hasView(viewName)) return false; if (annotationCache != null && annotationCache.contains(ta)) { TextAnnotation taFromCache = annotationCache.getTextAnnotation(ta); if(taFromCache.getAvailableViews().contains(viewName)) { ta.addView(viewName, taFromCache.getView(viewName)); return false; } } Annotator annotator = viewProviders.get(viewName); for (String prereqView : annotator.getRequiredViews()) isUpdated = addView(ta, prereqView); ta.addView(annotator); if (annotationCache != null ) { if(annotationCache.contains(ta)) annotationCache.updateTextAnnotation(ta); else annotationCache.addTextAnnotation(ta.getCorpusId(), ta); } return isUpdated; }
for (String prereqView : annotator.getRequiredViews()) { addView(textAnnotation, prereqView);
@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; if (ta.hasView(viewName)) return false; if (annotationCache != null && annotationCache.contains(ta)) { TextAnnotation taFromCache = annotationCache.getTextAnnotation(ta); if(taFromCache.getAvailableViews().contains(viewName)) { ta.addView(viewName, taFromCache.getView(viewName)); return false; } } Annotator annotator = viewProviders.get(viewName); for (String prereqView : annotator.getRequiredViews()) isUpdated = addView(ta, prereqView); ta.addView(annotator); if (annotationCache != null ) { if(annotationCache.contains(ta)) annotationCache.updateTextAnnotation(ta); else annotationCache.addTextAnnotation(ta.getCorpusId(), ta); } return isUpdated; }
for (String prereqView : annotator.getRequiredViews()) { addView(textAnnotation, prereqView);