Class 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 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

      • 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 interface ITreeEngine
        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 interface ITreeEngine
        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 interface ITreeEngine
        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
        returnNonExposedTrees - 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 interface ITreeEngine
        Returns:
        the names of all the decision trees, never null, may be an empty array.