package org.studiorailgun.conversation.evaluators;

import org.studiorailgun.conversation.categorization.SentenceFunctionCategorizor;
import org.studiorailgun.conversation.evaluators.goal.GoalEval;
import org.studiorailgun.conversation.evaluators.greet.GreetingEval;
import org.studiorailgun.conversation.evaluators.query.QueryEval;
import org.studiorailgun.conversation.evaluators.synthesis.ResponseEval;
import org.studiorailgun.conversation.tracking.Conversation;
import org.studiorailgun.conversation.tracking.Quote;

/**
 * Evaluates a sentence based on data about the sentence
 */
public class EvaluationTree {
    
    /**
     * Evaluates a quote
     * @param quote The quote
     */
    public static Quote evaluate(Conversation conversation, Quote quote){
        //parse data about the quote
        SentenceFunctionCategorizor.categorize(quote);

        //perform actions based on the tree
        switch(quote.getFunction()){
            case UTILITY: {
                GreetingEval.evaluate(conversation, quote);
            } break;
            case QUERY: {
                QueryEval.evaluate(conversation, quote);
            } break;
            default: {
                throw new UnsupportedOperationException("Unsupported quote function: " + quote.getFunction());
            }
        }

        //evaluate the AI's current goal in the conversation
        GoalEval.evaluate(conversation);

        //synthesize language based on the results of the actions performed
        Quote response = ResponseEval.evaluate(conversation);

        return response;
    }

}
