package org.studiorailgun.ai.conversation.parser.bank;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;

/**
 * A lemma lookup bank
 */
public class LemmaBank {

    /**
     * The map of word -> lemma
     */
    static Map<String,String> wordLemmaMap;

    /**
     * Initializes the lemma bank
     */
    public static void init(){
        wordLemmaMap = new HashMap<String,String>();
        try {
            String lemmaData = Files.readString(new File("./data/dictionary/verbs.csv").toPath());
            String[] lines = lemmaData.split("\n");
            for(int i = 1; i < lines.length; i++){
                String[] items = lines[i].split(",");
                wordLemmaMap.put(items[0],items[1]);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    /**
     * Gets the lemma of a word
     * @param word The word
     * @return The lemma of the word
     */
    public static String getLemma(String word){
        return wordLemmaMap.get(word);
    }

}
