package org.studiorailgun.conversation.evaluators.greet;

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

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

/**
 * 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){
        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 Quote constructGreeting(Conversation conversation){
        Quote response = new Quote("Hello");
        return response;
    }

}
