simplenlg.features.InterrogativeType Maven / Gradle / Ivy
/*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is "Simplenlg".
*
* The Initial Developer of the Original Code is Ehud Reiter, Albert Gatt and Dave Westwater.
* Portions created by Ehud Reiter, Albert Gatt and Dave Westwater are Copyright (C) 2010-11 The University of Aberdeen. All Rights Reserved.
*
* Contributor(s): Ehud Reiter, Albert Gatt, Dave Wewstwater, Roman Kutlak, Margaret Mitchell.
*/
package simplenlg.features;
/**
*
* An enumeration representing the different types of interrogatives or
* questions that SimpleNLG can realise. The interrogative type is recorded in
* the {@code Feature.INTERROGATIVE_TYPE} feature and applies to clauses.
*
*
* @author A. Gatt and D. Westwater, University of Aberdeen.
* @version 4.0
*
*/
public enum InterrogativeType {
/**
* The type of interrogative relating to the manner in which an event
* happened. For example, John kissed Mary becomes
* How did John kiss
* Mary?
*/
HOW,
/**
* A how question related to a predicative sentence, such as John is fine, which becomes How is John?
*/
HOW_PREDICATE,
/**
* This type of interrogative is a question pertaining to the object of a
* phrase. For example, John bought a horse becomes what did
* John buy? while John gave Mary a flower becomes
* What did
* John give Mary?
*/
WHAT_OBJECT,
/**
* This type of interrogative is a question pertaining to the subject of a
* phrase. For example, A hurricane destroyed the house becomes
* what destroyed the house?
*/
WHAT_SUBJECT,
/**
* This type of interrogative concerns the object of a verb that is to do
* with location. For example, John went to the beach becomes
* Where did John go?
*/
WHERE,
/**
* This type of interrogative is a question pertaining to the indirect
* object of a phrase when the indirect object is a person. For example,
* John gave Mary a flower becomes
* Who did John give a flower to?
*/
WHO_INDIRECT_OBJECT,
/**
* This type of interrogative is a question pertaining to the object of a
* phrase when the object is a person. For example,
* John kissed Mary becomes who did John kiss?
*/
WHO_OBJECT,
/**
* This type of interrogative is a question pertaining to the subject of a
* phrase when the subject is a person. For example,
* John kissed Mary becomes Who kissed Mary? while
* John gave Mary a flower becomes Who gave Mary a flower?
*/
WHO_SUBJECT,
/**
* The type of interrogative relating to the reason for an event happening.
* For example, John kissed Mary becomes Why did John kiss
* Mary?
*/
WHY,
/**
* This represents a simple yes/no questions. So taking the example phrases
* of John is a professor and John kissed Mary we can
* construct the questions Is John a professor? and
* Did John kiss Mary?
*/
YES_NO,
/**
* This represents a "how many" questions. For example of
* dogs chased John/em> becomes How many dogs chased John
*/
HOW_MANY;
/**
* A method to determine if the {@code InterrogativeType} is a question
* concerning an element with the discourse function of an object.
*
* @param type
* the interrogative type to be checked
* @return true
if the type concerns an object,
* false
otherwise.
*/
public static boolean isObject(Object type) {
return WHO_OBJECT.equals(type) || WHAT_OBJECT.equals(type);
}
/**
* A method to determine if the {@code InterrogativeType} is a question
* concerning an element with the discourse function of an indirect object.
*
* @param type
* the interrogative type to be checked
* @return true
if the type concerns an indirect object,
* false
otherwise.
*/
public static boolean isIndirectObject(Object type) {
return WHO_INDIRECT_OBJECT.equals(type);
}
/**
* Convenience method to return the String corresponding to the question
* word. Useful, since the types in this enum aren't all simply convertible
* to strings (e.g. WHO_SUBJCT
and WHO_OBJECT
both
* correspond to String Who)
*
* @return the string corresponding to the question word
*/
public String getString() {
String s = "";
switch (this) {
case HOW:
case HOW_PREDICATE:
s = "how";
break;
case WHAT_OBJECT:
case WHAT_SUBJECT:
s = "what";
break;
case WHERE:
s = "where";
break;
case WHO_INDIRECT_OBJECT:
case WHO_OBJECT:
case WHO_SUBJECT:
s = "who";
break;
case WHY:
s = "why";
break;
case HOW_MANY:
s = "how many";
break;
case YES_NO:
s = "yes/no";
break;
}
return s;
}
}