package org.studiorailgun.ai.conversation.evaluators.greet;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;

import org.studiorailgun.ai.conversation.tracking.ConvParticipant;
import org.studiorailgun.ai.conversation.tracking.Conversation;
import org.studiorailgun.ai.conversation.tracking.Quote;
import org.studiorailgun.ai.conversation.tracking.Sentence;

/**
 * Evaluates a greeting
 */
public class GreetingEval {

    /**
     * The greeting strings
     */
    private static List<String> greetingStrings = null;

    /**
     * Inits the greeting evaluator
     */
    public static void init(){
        try {
            greetingStrings = Files.readAllLines(new File("./data/sentence_function/greetings.txt").toPath());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    /**
     * Evaluates a greeting
     * @param input The sentence
     */
    public static void evaluate(Conversation conversation, Quote input, Sentence sentence){
        if(greetingStrings.contains(input.getRaw())){
            ConvParticipant other = conversation.getOther();
            if(!conversation.getGreetingData().getHaveGreeted().contains(other)){
                conversation.getGreetingData().getHaveGreeted().add(other);
            }
        }
    }

    /**
     * Constructs a greeting for the other participant
     * @param conversation The conversation
     * @return The greeting
     */
    public static Sentence constructGreeting(Conversation conversation){
        Sentence response = new Sentence("Hello.");
        return response;
    }

}
