edu.cs.ai.kreator.scripting
Class KreatorScriptEngine

java.lang.Object
  extended by edu.cs.ai.kreator.scripting.KreatorScriptEngine

public class KreatorScriptEngine
extends java.lang.Object

The Class KreatorScriptEngine manages a JavaScript-Engine.


Nested Class Summary
 class KreatorScriptEngine.ScriptWorker
          The Class ScriptWorker.
 
Field Summary
static java.lang.String END_OF_COMMAND_LINE
          Represents the delimiter of two commands.
static java.lang.String LINE_COMMENT_START
          Starts a single line comment
static org.apache.log4j.Logger LOG
          The Constant LOG.
 
Constructor Summary
KreatorScriptEngine(ConsolePane consolePane)
          Instantiates a new kreatorScriptEngine.
 
Method Summary
static java.lang.String composeGenerateDataCommand(java.io.File inputFile, java.io.File outputFile, int number, boolean overwriteExisting, boolean addToProject, boolean openfile)
           
static java.lang.String composeLearnParameterCommand(java.io.File sampleFile, java.io.File knowledgebase, ParameterLearner learner, java.io.File outputFile, KnowledgebaseWriter writer, boolean doNotOverwriteExisting, boolean doNotAddToProject, boolean doNotOpenfile)
          Builds a string representing the learnparameter command in appropriate JavaScript syntax.
static java.lang.String composeLearnStructureAndParameterCommand(java.io.File sampleFile, StructureLearner slearner, ParameterLearner plearner, java.io.File outputFile, KnowledgebaseWriter writer, boolean doNotOverwriteExisting, boolean doNotAddToProject, boolean doNotOpenfile)
          Builds a string representing the combined learn command (structure and parameter) in appropriate JavaScript syntax.
static java.lang.String composeLearnStructureCommand(java.io.File sampleFile, StructureLearner learner, java.io.File outputFile, KnowledgebaseWriter writer, boolean doNotOverwriteExisting, boolean doNotAddToProject, boolean doNotOpenfile)
          Builds a string representing the learnstructure command in appropriate JavaScript syntax.
static java.lang.String composeQueryCommand(java.io.File kbaseFile, java.lang.String query)
          Returns a string representing the query command in appropriate JavaScript syntax.
static java.lang.String composeQueryCommand(java.io.File kbaseFile, java.lang.String query, java.util.List<java.io.File> evidenceFiles)
          Returns a string representing the query command in appropriate JavaScript syntax.
static java.lang.String constructPath(java.io.File file)
          Constructs an absolute or relative (to the present working directory) pathname from a file, depending on the configuration option GENERAL__REPORT_ABSOLUTE_PATH.
protected  void done()
          Can be overloaded by utilizing classes to execute code after successful execution of scripts
 void executeScript(java.lang.String script)
          Executes a KreatorScript (and prints the result of the last evaluated script line to the console).
 void executeScript(java.lang.String script, boolean printResult)
          Executes a KreatorScript.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
The Constant LOG.


END_OF_COMMAND_LINE

public static final java.lang.String END_OF_COMMAND_LINE
Represents the delimiter of two commands. Every command should end with this character. Must be the same as in the Krsc.g file.

See Also:
Constant Field Values

LINE_COMMENT_START

public static final java.lang.String LINE_COMMENT_START
Starts a single line comment

See Also:
Constant Field Values
Constructor Detail

KreatorScriptEngine

public KreatorScriptEngine(ConsolePane consolePane)
Instantiates a new kreatorScriptEngine.

Parameters:
consolePane - the consolePane
Method Detail

executeScript

public void executeScript(java.lang.String script,
                          boolean printResult)
Executes a KreatorScript.

Parameters:
script - the KreatorScript
printResult - If true, the result of the last evaluated script line is printed to the console (usually the case if an interactively typed single script command is executed).
If false, the last result is not printed (usually the case if a "full" script (i.e. a script file) is executed.).

executeScript

public void executeScript(java.lang.String script)
Executes a KreatorScript (and prints the result of the last evaluated script line to the console).

Parameters:
script - the KreatorScript

done

protected void done()
Can be overloaded by utilizing classes to execute code after successful execution of scripts


composeQueryCommand

public static java.lang.String composeQueryCommand(java.io.File kbaseFile,
                                                   java.lang.String query,
                                                   java.util.List<java.io.File> evidenceFiles)
Returns a string representing the query command in appropriate JavaScript syntax.

Parameters:
knowledgebase -
query -
evidenceFiles -
Returns:

composeQueryCommand

public static java.lang.String composeQueryCommand(java.io.File kbaseFile,
                                                   java.lang.String query)
Returns a string representing the query command in appropriate JavaScript syntax.

Parameters:
kbaseFile -
query -
Returns:

composeLearnStructureCommand

public static java.lang.String composeLearnStructureCommand(java.io.File sampleFile,
                                                            StructureLearner learner,
                                                            java.io.File outputFile,
                                                            KnowledgebaseWriter writer,
                                                            boolean doNotOverwriteExisting,
                                                            boolean doNotAddToProject,
                                                            boolean doNotOpenfile)
Builds a string representing the learnstructure command in appropriate JavaScript syntax.

Parameters:
sampleFile - the file with the samples for learning.
learner - referencee to the used structure learner.
outputFile - file handle for the output file.
writer - reference to the used Writer for translating the knowledgebase into a file.
doNotOverwriteExisting -
doNotAddToProject -
doNotOpenfile -
Returns:
a string representing the learnstructure command in appropriate JavaScript syntax.

composeLearnParameterCommand

public static java.lang.String composeLearnParameterCommand(java.io.File sampleFile,
                                                            java.io.File knowledgebase,
                                                            ParameterLearner learner,
                                                            java.io.File outputFile,
                                                            KnowledgebaseWriter writer,
                                                            boolean doNotOverwriteExisting,
                                                            boolean doNotAddToProject,
                                                            boolean doNotOpenfile)
Builds a string representing the learnparameter command in appropriate JavaScript syntax.

Parameters:
sampleFile - the file with the samples for learning
knowledgebase - reference to a knowledgebase with structural information.
learner - reference to th euser parameter learner instance.
outputFile - file handle of the output file.
writer - reference to the used Writer for translating the Knowledgebase into a file.
doNotOverwriteExisting -
doNotAddToProject -
doNotOpenfile -
Returns:
a string representing the learnparameter command in appropriate JavaScript syntax.

composeLearnStructureAndParameterCommand

public static java.lang.String composeLearnStructureAndParameterCommand(java.io.File sampleFile,
                                                                        StructureLearner slearner,
                                                                        ParameterLearner plearner,
                                                                        java.io.File outputFile,
                                                                        KnowledgebaseWriter writer,
                                                                        boolean doNotOverwriteExisting,
                                                                        boolean doNotAddToProject,
                                                                        boolean doNotOpenfile)
Builds a string representing the combined learn command (structure and parameter) in appropriate JavaScript syntax.

Parameters:
sampleFile - the file with the samples for learning
slearner - reference to an instance of the used structure learner.
plearner - reference to an instance of the used parameter learner.
outputFile - file handle of the output file.
writer - reference to the used Writer for translating the Knowledgebase into a file.
doNotOverwriteExisting -
doNotAddToProject -
doNotOpenfile -
Returns:
a string representing the combined learn command (structure and parameter) in appropriate JavaScript syntax.

composeGenerateDataCommand

public static java.lang.String composeGenerateDataCommand(java.io.File inputFile,
                                                          java.io.File outputFile,
                                                          int number,
                                                          boolean overwriteExisting,
                                                          boolean addToProject,
                                                          boolean openfile)

constructPath

public static java.lang.String constructPath(java.io.File file)
Constructs an absolute or relative (to the present working directory) pathname from a file, depending on the configuration option GENERAL__REPORT_ABSOLUTE_PATH.

Parameters:
file -
Returns: