Class TreeEngine
- java.lang.Object
-
- com.aquima.interactions.dtree.impl.TreeEngine
-
- All Implemented Interfaces:
ITreeEngine
public class TreeEngine extends Object implements ITreeEngine
Decision tree engine implementation, which hold the various (static) definitions of the defined decision trees.- Since:
- 5.0
- Author:
- F. van der Meer
-
-
Constructor Summary
Constructors Constructor Description TreeEngine(IParserFactory parser, IComposer composer, IMetaModel metamodel, ITreeEngineDS datasource)
Constructs the tree engine with the required arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ITreeResponse
evaluateWith(String treeName, IAnswers answers, InferenceContext context)
Evaluate a decision tree with the context passed.protected DecisionTree
getInternalTreeByName(String name)
IDecisionTree
getTreeByName(String name)
Retrieves the tree by it's name.String[]
getTreeNames()
Retrieves the tree names.ISearchResult
searchDecisionTrees(String searchText, ILanguage language, int maximumResults, double theshold)
This function will search all Decision Trees and try to find the best matching tree matching to the symptomText.ISearchResult
searchDecisionTrees(String searchText, ILanguage language, int maximumResults, double theshold, boolean returnNonExposedTrees)
This function will search all Decision Trees and try to find the best matching tree matching to the symptomText.
-
-
-
Constructor Detail
-
TreeEngine
public TreeEngine(IParserFactory parser, IComposer composer, IMetaModel metamodel, ITreeEngineDS datasource) throws InitializationException
Constructs the tree engine with the required arguments.- Parameters:
metamodel
- The meta model definitions.parser
- Parser factory that should be used to create expression parsers.composer
- The composer containing asset and container definitions.datasource
- The data-source containing the information of the decision trees that need to be added.- Throws:
InitializationException
- This exception is thrown when the tree engine could not be initialized due to a fatal exception.
-
-
Method Detail
-
getTreeByName
public IDecisionTree getTreeByName(String name) throws DecisionTreeException
Description copied from interface:ITreeEngine
Retrieves the tree by it's name.- Specified by:
getTreeByName
in interfaceITreeEngine
- Parameters:
name
- The name of the decision tree that is requested.- Returns:
- the decision tree when found.
- Throws:
DecisionTreeException
- when the tree could not be found.
-
getInternalTreeByName
protected DecisionTree getInternalTreeByName(String name)
-
evaluateWith
public ITreeResponse evaluateWith(String treeName, IAnswers answers, InferenceContext context) throws AppException
Description copied from interface:ITreeEngine
Evaluate a decision tree with the context passed. The answers interface will instruct the tree engine to skip asking certain questions and continue down the tree until it can find an answer.- Specified by:
evaluateWith
in interfaceITreeEngine
- Parameters:
treeName
- The decision tree that should be evaluated.answers
- The answers that have been given so far.context
- current context.- Returns:
- The response can never be null
- Throws:
AppException
- This exception is throw when the tree could not be evaluated.
-
searchDecisionTrees
public ISearchResult searchDecisionTrees(String searchText, ILanguage language, int maximumResults, double theshold)
Description copied from interface:ITreeEngine
This function will search all Decision Trees and try to find the best matching tree matching to the symptomText. Standard this function will return up matching decision trees.- Specified by:
searchDecisionTrees
in interfaceITreeEngine
- Parameters:
searchText
- A symptom text of at least 1 character.language
- The language that should be used when searching for a matching symptom.maximumResults
- indicates what the maximum results count should be, this number is expected to be 1 or larger.theshold
- the minimum score of the matched decision tree- Returns:
- A search result object holding the matching trees and their scores.
-
searchDecisionTrees
public ISearchResult searchDecisionTrees(String searchText, ILanguage language, int maximumResults, double theshold, boolean returnNonExposedTrees)
Description copied from interface:ITreeEngine
This function will search all Decision Trees and try to find the best matching tree matching to the symptomText. Standard this function will return up matching decision trees.- Specified by:
searchDecisionTrees
in interfaceITreeEngine
- Parameters:
searchText
- A symptom text of at least 1 character.language
- The language that should be used when searching for a matching symptom.maximumResults
- indicates what the maximum results count should be, this number is expected to be 1 or larger.theshold
- the minimum score of the matched decision treereturnNonExposedTrees
- boolean whether to return decision trees that are not exposed as a webservice.- Returns:
- A search result object holding the matching trees and their scores.
-
getTreeNames
public String[] getTreeNames()
Description copied from interface:ITreeEngine
Retrieves the tree names.- Specified by:
getTreeNames
in interfaceITreeEngine
- Returns:
- the names of all the decision trees, never null, may be an empty array.
-
-