package org.studiorailgun.conversation.synthesis;

import org.studiorailgun.Globals;
import org.studiorailgun.knowledge.Node;
import org.studiorailgun.knowledge.query.InstanceQuery;
import org.studiorailgun.knowledge.query.PossessionQuery;

/**
 * Synthesizes text for a noun stack
 */
public class NounStackSynthesizer {
    
    /**
     * Synthesizes a noun to describe this node
     * @param noun The node
     * @return The synthesized text
     */
    public static String synthesize(Node node, boolean possessive){
        String rVal = "";


        Node mostSpecificConcept = InstanceQuery.getMostSpecificConcept(node);
        rVal = mostSpecificConcept.getName();

        if(possessive){
            rVal = rVal.toLowerCase();
            Node possessor = PossessionQuery.getPossessor(node);
            if(possessor == Globals.web.getAnchors().getSelfNode()){
                rVal = "My " + rVal;
            }
        }

        return rVal;
    }

}
