Package edu.neu.ccs.task.dialogue

Source Code of edu.neu.ccs.task.dialogue.Result

package edu.neu.ccs.task.dialogue;

import java.util.List;

import edu.neu.ccs.task.Slot;
import edu.neu.ccs.task.Task;
import edu.neu.ccs.task.TaskModelSet;
import edu.neu.ccs.task.TaskType;

/**
* Represents the result of a user choice or agent utterance, in terms
* of effects on task output slots.  A runtime representation of a
* d:result element.
*
* @author Dan Schulman
* @version $Id: Result.java 728 2009-09-30 20:32:24Z schulman $
*/
public class Result {
  private final String slot;
  private final String value;
 
  public Result(String slot, String value) {
    this.slot = slot;
    this.value = value;
  }

  /**
   * Apply this result ot a task's output slots.
   * @param task a task instance
   */
  public void apply(Task task) {
    task.setSlotValueScript(slot, value, "turn result");
  }
 
  public String getDestination() {
    return slot;
  }
 
  boolean check(TaskModelSet e, String pname, TaskType tt, List<String> errs) {
    String sname = getDestination();
    Slot s = tt.getSlotIfExists(sname);
    if (s == null) {
      errs.add(pname + ": unknown slot " + sname);
      return false;
    } else if ( ! s.isOutput()) {
      errs.add(pname + ": " + sname + " is not an output");
      return false;
    } else
      return true;
   
  }
}
TOP

Related Classes of edu.neu.ccs.task.dialogue.Result

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.