Class ViewCreatorAnnotator

All Implemented Interfaces:
AnalysisComponent

public class ViewCreatorAnnotator extends JCasAnnotator_ImplBase
This annotator can be placed at/near the beginning of a pipeline to ensure that a particular view is created before it is used further downstream. It will create a view for the view name specified by the configuration parameter PARAM_VIEW_NAME if it doesn't exist. One place this is useful is if you are using an annotator that uses the default view and you have mapped the default view into a different view via a sofa mapping. The default view is created automatically - but if you have mapped the default view to some other view, then the view provided to your annotator (when it asks for the default view) will not be created unless you have explicitly created it.
  • Field Details

    • PARAM_VIEW_NAME

      public static final String PARAM_VIEW_NAME
      The parameter name for the name of the viewed to be created by this annotator
      See Also:
  • Constructor Details

    • ViewCreatorAnnotator

      public ViewCreatorAnnotator()
  • Method Details

    • process

      public void process(JCas aJCas) throws AnalysisEngineProcessException
      Description copied from class: JCasAnnotator_ImplBase
      This method should be overriden by subclasses. Inputs a JCAS to the AnalysisComponent. The AnalysisComponent "owns" this JCAS until such time as Annotator_ImplBase.hasNext() is called and returns false (see AnalysisComponent for details).
      Specified by:
      process in class JCasAnnotator_ImplBase
      Parameters:
      aJCas - a JCAS that this AnalysisComponent should process.
      Throws:
      AnalysisEngineProcessException - if a problem occurs during processing
    • createViewSafely

      public static JCas createViewSafely(JCas aJCas, String aViewName) throws AnalysisEngineProcessException
      Provides a simple call that allows you to safely create a view if it has not been created yet. If the view already exists, it is ok to call this method anyways without worrying about checking for this yet.
      Parameters:
      aJCas - the JCas to create the view in
      aViewName - the name of the new view
      Returns:
      true if the view was created as a result of calling this method. false if the view already existed.
      Throws:
      AnalysisEngineProcessException - if the view could not be created or if an existing view with the given name could not be accessed