public class ACPLogic
extends java.util.Observable
Modifier and Type | Class and Description |
---|---|
static class |
ACPLogic.State |
Modifier and Type | Method and Description |
---|---|
void |
changeRanks(java.lang.String sourceName)
Update the ranking of the opening window (source document).
|
void |
chooseSuggestion(Suggestion suggestion)
To inform the system that user has selected a specific suggestion for
machine learning purposes.
|
void |
clearAllData()
Clear all the extracted data from the database This method is called
during the launching and the closing of Java ACP, and when ACPBackground
detect that the Mozilla Firefox plugin is closed.
|
void |
closeDestinationDocument(int id)
Alert the rank manager when a text editor (eg.
|
void |
closeSourceDocument(java.lang.String url)
Remove all the text extracted from the specified opening window (source document).
|
boolean |
editEnableDisableACP(Preference preference) |
boolean |
editUserPreference(Preference preference)
Save the updated user preference to the configuration file.
|
ACPLogic.State |
getCurrentState()
Get the current state of ACP logic.
|
static ACPLogic |
getInstance()
Returns the reference to the single instance of ACPLogic.
|
java.lang.String |
getPreferenceConfigurationFileAbsolutePath()
Retrieve the absolute file path of the configuration file.
|
Preference |
getUserPreference()
Retrieve the user preference from the configuration file.
|
boolean |
initialiseLibraries()
Returns true if it is able to initialise all the libraries successfully.
|
void |
processRawText(java.lang.String rawText,
java.lang.String sourceName,
java.lang.String url)
Process and store the text extracted from opening windows (source document).
|
Suggestion |
requestExtendSuggestion(int id,
int type)
Retrieve the next paragraph, sentence or word based on the current selected suggestion.
|
java.util.List<Suggestion> |
requestSuggestion(java.lang.String userInput,
boolean autoTrigger)
Using prefix search to retrieve a list of suggestions based on the user input.
|
void |
setDestinationDocument(int id)
Inform MLManager the current destination document (eg.
|
void |
storeUserBehaviors()
Store the learned user behaviors to a file.
|
void |
triggerDebugUI()
Display the debug UI for Machine Learning.
|
public static ACPLogic getInstance()
This method is a standard method for singleton class
public boolean initialiseLibraries()
This method may return false if it is unable to initialise a certain library. If that is the case, the program cannot continue executing. The calling method should prompt an error message and quit the system.
public void processRawText(java.lang.String rawText, java.lang.String sourceName, java.lang.String url)
This method does not return any result. However if an error occur, GateException is catch, and since this method is called by a background process, it will be ignored.
rawText
- the content of the source document. For now, it must be HTML document.sourceName
- the name for the source document.url
- the unique identity locator to identify the source document.public java.util.List<Suggestion> requestSuggestion(java.lang.String userInput, boolean autoTrigger)
The result is sorted based on user preference from the PreferenceManager and the user behaviors learned by the machine learning algorithm. This method returns an empty list of suggestions if autoTrigger is true and the actual number of suggestion in the suggestion list exceed the threshold specified in User Preference (Suggestion Threshold).
userInput
- the text entered by user in a text-editor.autoTrigger
- the trigger mode.Suggestion
public void chooseSuggestion(Suggestion suggestion)
suggestion
- the source name of the selected suggestion.public Suggestion requestExtendSuggestion(int id, int type)
id
- the id of the sentence/paragraph it will refer from.type
- the type that user wish to extend next. (Refer to Suggestion constant variable)Suggestion
public void closeSourceDocument(java.lang.String url)
url
- the name of the source document.public void changeRanks(java.lang.String sourceName)
This method is called by ACPBackground class to give higher ranking for source documents which are recently viewed.
sourceName
- the source name of the source document.public Preference getUserPreference()
This method always returns a preference object, whether or not the configuration file exists.
Preference
public boolean editUserPreference(Preference preference)
This method will return true if it successfully update the configuration file.
preference
- the updated user preference options.public boolean editEnableDisableACP(Preference preference)
public java.lang.String getPreferenceConfigurationFileAbsolutePath()
public void storeUserBehaviors()
public void clearAllData()
public void setDestinationDocument(int id)
id
- the unique identity to identify the document.public void triggerDebugUI()
public ACPLogic.State getCurrentState()
ACPLogic.State
public void closeDestinationDocument(int id)
id
- the document id.