Internal Interfaces¶
poetic.exceptions Module¶
Module for custom exceptions.
The exceptions module includes custom classes for specific errors in the poetic package. This is not part of the public interface.
-
exception
poetic.exceptions.InputLengthError(message: Optional[str] = None)¶ Bases:
ExceptionRaises Input Length Error.
This exception is used in the Predictor class for the input length of 0.
- Parameters
message (str) – The error message to display.
-
exception
poetic.exceptions.ModelShapeError(message: Optional[str] = None)¶ Bases:
ExceptionRaises exception for unsupported keras model.
This exception is used for when the custom keras model is incompatible with the package’s toolchains. Currently, preprocess() method of the Predictor class raises this exception. To avoid this error, use default settings or check documentation for supported models.
- Parameters
message (str) – The error message to display.
-
exception
poetic.exceptions.SingletonError(message: Optional[str] = None)¶ Bases:
ExceptionRaises exception for instantiating Singleton class already in existence.
This exception is used for any singleton class in the package. When the singleton class already has an instance and the constructor is explicitly called, this exception will be thrown. To avoid this exception, use the get_instance() method instead of instantiating the class.
- Parameters
message (str) – The error message to display.
-
exception
poetic.exceptions.UnsupportedConfigError(message: Optional[str] = None)¶ Bases:
ExceptionRaises Unsupported Configuration Error.
This exception is used in the _Arguments class for checking unsupported commandline flags.
- Parameters
message (str) – The error message to display.
poetic.gui Module¶
Module for Poetry Predictor GUI.
This module includes the class and methods for poetic’s desktop Tkinter GUI. As an internal interface, this is not intended or recommended for being used as an import. To run the GUI, follow the given examples or refer to the documentation.
Examples
Simply run the GUI:
python -m poetic
Make prediction and launch GUI by adding the -g or --GUI flag:
python -m poetic -s "This is poetic." -o "<PATH>" -g
-
class
poetic.gui.GUI(predictor: Optional[poetic.Predictor.predictor] = None)¶ Bases:
objectLaunches the GUI, which is equivalent to launching it through the command line.
poetic.util._Arguments Class¶
poetic.predictor.Predictions Class¶
-
class
poetic.predictor.Predictions(results: List[List[float]], sentences: Optional[List[str]])¶ Bases:
poetic.results.DiagnosticsClass for prediction results from Predictor class.
This class inherets from
Diagnosticsclass of theresultsmodule, and it is intended for being internally called by the Predictor class. To directly access the Diagnostics class’s functionality, use it instead.- Parameters
results (list(list(float))) – The prediction results predicted with Keras models.
sentences (list(str), optional) – A list of strings to represent tokenized sentences predicted by the
Predictorclass.
-
predictions¶ Predictions of poetic scores.
- Type
list
-
sentences¶ Sentences associated with the predictions.
- Type
list
-
diagnostics¶ A dictionary of diagnostics statistics, including sentence count, five number summary, and the predictions themselves.
- Type
dict