Class TheWorksExample

    • Constructor Detail

      • TheWorksExample

        public TheWorksExample()
    • Method Detail

      • getMinimumApiVersion

        public String getMinimumApiVersion()
        Get the minimum version of the nzilbb.ag API supported by the serializer.
        Specified by:
        getMinimumApiVersion in class Annotator
        Returns:
        Minimum version of the nzilbb.ag API supported by the serializer.
        See Also:
        Constants.VERSION
      • getAnnotatorId

        public String getAnnotatorId()
        This class implements its own version of Annotator.getAnnotatorId() which is not necessary unless there's a class-name clash with some other annotator.

        If such a class exists, you would need this method to return something other than getClass().getSimpleName().

        Overrides:
        getAnnotatorId in class Annotator
        Returns:
        The annotator's ID.
      • setRdbConnectionFactory

        public void setRdbConnectionFactory​(ConnectionFactory db)
                                     throws SQLException
        Sets the information required for connecting to the relational database.

        This is automatically called if the annotator is annotated with UsesRelationalDatabase, providing the implementation with access to a relational database.

        Overrides:
        setRdbConnectionFactory in class Annotator
        Parameters:
        db - Factory for making new connections to the database.
        Throws:
        SQLException - If the annotator can't connect to the given database.
      • uninstall

        public void uninstall()
        Runs any processing required to uninstall the annotator.

        In this case, the table created in rdbConnectionFactory() is DROPped.

        Overrides:
        uninstall in class Annotator
      • getConfig

        public String getConfig()
        Provides the overall configuration of the annotator.

        This implementation uses Annotator.beanPropertiesToQueryString() to generate the string from the current bean properties.

        Overrides:
        getConfig in class Annotator
        Returns:
        The overall configuration of the annotator, which will be passed to the config/index.html configuration webapp, if any. This configuration may be null, or a string that serializes the annotators configuration state in any encoding the implementor prefers. The resulting string must be interpretable by the config/index.html webapp.
        See Also:
        setConfig(String), Annotator.beanPropertiesToQueryString()
      • setConfig

        public void setConfig​(String config)
                       throws InvalidConfigurationException
        Specifies the overall configuration of the annotator, and runs any processing required to install the annotator.

        This processing is assumed to be synchronous (this method doesn't return until it's complete) and long-running, so the MonitorableTask methods should provide a way for the caller to monitor/cancel processing - i.e. the Annotator class should provide an indication of progress by calling Annotator.setPercentComplete(Integer) and should regularly check Annotator.isCancelling() to determine if installation should be stopped.

        If the user should provide information before this method is called, a config web-app must be provided to implement the user interface, which sets any required configuration by invoking methods of the annotator as required, and invoking setConfig when configuration is ready.

        If the configuration needs to be persistent between installing the annotator the first time and subsequently upgrading it, then it is the annotator's responsibility to serialize it in a form which can be retrieved for a later call to getConfig().

        This implementation uses Annotator.beanPropertiesFromQueryString(String) to configure the bean properties from the query string.

        Overrides:
        setConfig in class Annotator
        Throws:
        InvalidConfigurationException
        See Also:
        getConfig(), Annotator.beanPropertiesFromQueryString(String)
      • getInputLayer

        public String getInputLayer()
        Getter for inputLayer: ID of input layer.
        Returns:
        ID of input layer.
      • setInputLayer

        public TheWorksExample setInputLayer​(String newInputLayer)
        Setter for inputLayer: ID of input layer.
        Parameters:
        newInputLayer - ID of input layer.
      • getOutputLayer

        public String getOutputLayer()
        Getter for outputLayer: ID of output layer.
        Returns:
        ID of output layer.
      • setOutputLayer

        public TheWorksExample setOutputLayer​(String newOutputLayer)
        Setter for outputLayer: ID of output layer.
        Parameters:
        newOutputLayer - ID of output layer.
      • transform

        public Graph transform​(Graph graph)
                        throws TransformationException
        Transforms the graph. In this case, the graph is simply summarized, by counting all tokens of each word type, and printing out the result to stdout.
        Specified by:
        transform in interface GraphTransformer
        Parameters:
        graph - The graph to transform.
        Returns:
        The changes introduced by the tranformation.
        Throws:
        TransformationException - If the transformation cannot be completed.
      • getReverse

        public Boolean getReverse()
        Getter for reverse: Reverse annotation labels setting.
        Returns:
        Reverse annotation labels setting.
      • setReverse

        public void setReverse​(Boolean newReverse)
        Setter for reverse: Reverse annotation labels setting.
        Parameters:
        newReverse - Reverse annotation labels setting.
      • getLeftPadding

        public int getLeftPadding()
        Getter for leftPadding: How many spaces to add on the left.
        Returns:
        How many spaces to add on the left.
      • setLeftPadding

        public TheWorksExample setLeftPadding​(int newLeftPadding)
        Setter for leftPadding: How many spaces to add on the left.
        Parameters:
        newLeftPadding - How many spaces to add on the left.
      • getRightPadding

        public Integer getRightPadding()
        Getter for rightPadding: How many spaces to add on the right.
        Returns:
        How many spaces to add on the right.
      • setRightPadding

        public TheWorksExample setRightPadding​(Integer newRightPadding)
        Setter for rightPadding: How many spaces to add on the right.
        Parameters:
        newRightPadding - How many spaces to add on the right.
      • setPadding

        public void setPadding​(int leftPadding,
                               int rightPadding)
        Sets the padding.
        Parameters:
        leftPadding -
        rightPadding -
      • getPrefix

        public String getPrefix()
        Getter for prefix: Prefix to add.
        Returns:
        Prefix to add.
      • setPrefix

        public TheWorksExample setPrefix​(String newPrefix)
        Setter for prefix: Prefix to add.
        Parameters:
        newPrefix - Prefix to add.
      • getLabelConfidence

        public Double getLabelConfidence()
        Getter for labelConfidence: Value for annotator confidence.
        Returns:
        Value for annotator confidence.
      • setLabelConfidence

        public TheWorksExample setLabelConfidence​(Double newLabelConfidence)
        Setter for labelConfidence: Value for annotator confidence.
        Parameters:
        newLabelConfidence - Value for annotator confidence.
      • uploadFile

        public String uploadFile​(File file)
        Accepts an uploaded file.
        Parameters:
        file - The file uploaded by the webapp.
        Returns:
        null if upload was successful, an error message otherwise.
      • getSimulatedInstallationDuration

        public Integer getSimulatedInstallationDuration()
        Getter for simulatedInstallationDuration: How long, in seconds, the #setConfig(String) method should take to return.
        Returns:
        How long, in seconds, the #setConfig(String) method should take to return.
      • setSimulatedInstallationDuration

        public TheWorksExample setSimulatedInstallationDuration​(Integer newSimulatedInstallationDuration)
        Setter for simulatedInstallationDuration: How long, in seconds, the #setConfig(String) method should take to return.
        Parameters:
        newSimulatedInstallationDuration - How long, in seconds, the #setConfig(String) method should take to return.