// (c) MIT 2003.  All rights reserved.

// -*-Mode: Java-*- 
// $Id: WSentence.java,v 1.2 2003/03/06 00:40:42 moltmans Exp $
// WSentence.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Thu Feb  3 19:03:17 2000> 
<<<<<<< WSentence.java
// Time-stamp: <2000-04-11 16:39:37 moltmans> 
=======
// Time-stamp: <2000-05-12 16:18:31 moltmans> 
>>>>>>> 1.5
package rec.annotate.widgets;

import java.util.*;
import rec.sys.*;
import rec.util.*;
import rec.annotate.rules.*;
//import rec.speech.*;

/**
 * Sentence widget for further processing by individual recognizers.
 **/
public class WSentence extends Widget
{
  private WUtterance m_utterance;
  private Sentence m_sentenceFact;

  public WSentence( Surface s, WUtterance utterance )
  {
    m_utterance = utterance;
    m_sentenceFact = new Sentence( s, utterance.getTags(),
				   this );
  }

<<<<<<< WSentence.java
  // it is an error for tag to have multiple nouns
  public String getNoun( Tag tag ) 
  {
    if( tag == null )
      return null;
    
    return tag.getText( "noun" );
  }

  public String getSubject() 
  {
    return getNoun( getTag( "subject" ) );
  }

  public boolean hasDirectObject() 
  {
    return getDirectObject() != null;
  }
  
  public String getDirectObject() 
  {
    return getNoun( getTag( "direct_object" ) );
  }

  /** check if subject is "one" **/
  public boolean isOutsideForce() 
  {
    String sub = getSubject();
    return (sub != null) && sub.equals( "one" );
  }  

  public String getVerb()
  {
    return getTextForTag( "verb" );
  }

  public String getPreposition()
  {
    return getTextForTag( "preposition" );
  }

  public boolean hasPrepositionalPhrase() 
  {
    return getPrepositionalPhrase() != null;
  }

  public boolean isPrepositionRotational() 
  {
    Tag prepPhrase = getTag( "prep_phrase" );
    return (prepPhrase != null) && prepPhrase.hasTag( "rotational_prep" );
  }
  
      
    
  
  public String getPrepositionalPhrase()
  {
    return getTextForTag( "prep_phrase" );
  }

    
  public Tag getPrepositionalPhraseTag()
  {
    return getTag( "prep_phrase" );
  }


  public String getObjectOfPreposition()
  {
    return getTextForTag( "object_of_prep" );
  }

  public boolean isCausal() 
  {
    return hasTag( "causal_sentence" );
  }

  public Tag getCause() 
  {
    return getTag( "cause" );
  }

  public Tag getEffect() 
  {
    return getTag( "effect" );
  }
  
=======
>>>>>>> 1.5
  public void makeDefaultSuitcase( Surface s )
  {
    DoTransition dt = new DoTransition(s) {
      public void doDo( )
      {
	Notebook book = m_Surface.getNotebook();
	book.assume( m_sentenceFact, "WSentence heard" );
	book.updateNotes();
      }
      public void doUndo( )
      {
	Notebook book = m_Surface.getNotebook();
	book.retract( m_sentenceFact, "WSentence heard" );
	book.updateNotes();
      }
      public String getAction( )
      {
	return "WSentence: " + m_sentenceFact;
      }
    };
    addToSuitcase( dt );
  }

}

