All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.cmu.sv.system_action.dialog_act.DialogAct Maven / Gradle / Ivy

Go to download

A library that allows rapid prototyping of dialog systems (language understanding, discourse modelling, dialog management, language generation).

There is a newer version: 0.7.0
Show newest version
package edu.cmu.sv.system_action.dialog_act;

import edu.cmu.sv.dialog_state_tracking.DialogState;
import edu.cmu.sv.dialog_state_tracking.DiscourseUnit;
import edu.cmu.sv.semantics.SemanticsModel;
import edu.cmu.sv.system_action.SystemAction;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by David Cohen on 9/2/14.
 *
 * Define the dialog acts for the YODA dialog system
 * Define information to support decision-making by the dialog manager, and to generate NLG input
 *
 * For class bindings, bindings are bound as Class objects
 * For individual bindings, bindings are bound as URIs
 *
 */
public abstract class DialogAct extends SystemAction {
    private Map boundClasses = new HashMap<>();
    private Map boundIndividuals = new HashMap<>();
    private Map boundDescriptions = new HashMap<>();
    private Map boundPaths = new HashMap<>();

    public abstract Map getClassParameters();
    public abstract Map getIndividualParameters();
    public abstract Map getDescriptionParameters();
    public abstract Map getPathParameters();

    public Map getBoundClasses(){return boundClasses;}
    public Map getBoundIndividuals(){return boundIndividuals;}
    public Map getBoundDescriptions(){return boundDescriptions;}
    public Map getBoundPaths(){return boundPaths;}

    public void bindVariables(Map bindings){
        boundClasses = new HashMap<>();
        boundIndividuals = new HashMap<>();
        boundDescriptions = new HashMap<>();
        for (String key : bindings.keySet()){
            if (this.getClassParameters().containsKey(key))
                boundClasses.put(key, bindings.get(key));
            else if (this.getIndividualParameters().containsKey(key))
                boundIndividuals.put(key, bindings.get(key));
            else if (this.getDescriptionParameters().containsKey(key))
                boundDescriptions.put(key, bindings.get(key));
            else if (this.getPathParameters().containsKey(key))
                boundPaths.put(key, bindings.get(key));
            else
                throw new Error("this binding isn't a parameter for this class: "+ key + ", "+this.getClass().getSimpleName());
        }
    }

    public abstract Double reward(DialogState dialogState,
                                  DiscourseUnit discourseUnit);

    public SemanticsModel getNlgCommand(){
        String dA = this.getClass().getSimpleName();
        return new SemanticsModel("{\"dialogAct\":\""+dA+"\"}");
    }

    @Override
    public String toString() {
        return this.getClass().getSimpleName()+ "{" +
                "boundVariables=" + getBoundClasses() + getBoundIndividuals() + getBoundDescriptions() + getBoundPaths() +
                '}';
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy