org.hops.lg
Class HopsLang

java.lang.Object
  extended by org.hops.lg.HopsLang
All Implemented Interfaces:
java.io.Serializable

public class HopsLang
extends java.lang.Object
implements java.io.Serializable

HopsLang.java

Version:
3.0 This class allows the OG to get friendly sentences to insert in the front-end documents The OG can get the list of prompts for: - genPrompts: generates Open, Directed and Help message. Main attribute for help message is implicit. - genFreePrompts: where the main attribure for help is explicit - genHelpPrompt: help message. Stores a UserModel setted by the caller, and a hashmap of: - LanguageGenerator objects identified by lang id - known combinations of actions and attributes and its correspondence to a phrase-id - known categoric attributes and the allowed values. - known correspondence between Language attribute names and DM names
Author:
Meritxell Gonzalez
See Also:
Serialized Form

Constructor Summary
HopsLang(java.lang.String[] langsin, java.lang.String path)
          Creates a new instance of HopsLang
 
Method Summary
 java.lang.String generateAddressEnumeration(java.util.ArrayList values, java.lang.String lang)
          Generates an address in corner-format.
 java.lang.String generateDatesEnumeration(java.util.ArrayList values, java.lang.String lang)
          Generates an enumeration os dates using AND link in the two last values.
 java.lang.String generateValuesEnumeration(java.util.ArrayList values, java.lang.String lang)
          Generates an enumaration of values using AND link between the two last values.
 java.lang.String[] genFreePrompts(java.lang.String lang, stackact next_moves, java.lang.String help_attribute)
          generates 3 sentence : open, directed, help The attribute used for generating the help messag is the help_attribute parameter Open and directed messages are generated with fillFreeResponseData.
 java.lang.String genHelpPrompt(java.lang.String lang, java.lang.String attribute)
          generates a sentence giving help for the current attribute.
 java.lang.String[] genPrompts(java.lang.String lang, stackact next_moves)
          generates 3 sentence : open, directed, help.
 java.lang.String getGreetings(java.lang.String lang)
          Returns the Greeting depending on the system hour and the language - Good Morning (6..12) - Good Afternoon (13..17) - Good Evening (18..21) - Good Night (22..6)
 void setUserModel(UserModel _um)
          Set the User Model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HopsLang

public HopsLang(java.lang.String[] langsin,
                java.lang.String path)
Creates a new instance of HopsLang

Parameters:
langsin - the languages identification known
path - the path of the phrases files: {home}/LG/etc
Method Detail

setUserModel

public void setUserModel(UserModel _um)
Set the User Model. The UserModel is mainly used by the LanguageGenerators.

Parameters:
_um - the usermodel

generateDatesEnumeration

public java.lang.String generateDatesEnumeration(java.util.ArrayList values,
                                                 java.lang.String lang)
Generates an enumeration os dates using AND link in the two last values. Dates must in yyyymmdd format and they are translated to the lang format.

Parameters:
values - the values in yyyymmdd format
lang - the language id
Returns:
the sentence with the transalated dates

generateAddressEnumeration

public java.lang.String generateAddressEnumeration(java.util.ArrayList values,
                                                   java.lang.String lang)
Generates an address in corner-format. Maximum of two values are used. Two values are linked with "corner" lexic.

Parameters:
values - the street names
lang - the language used
Returns:
the sentence with one or two address. Ex: smith st. with john st.

generateValuesEnumeration

public java.lang.String generateValuesEnumeration(java.util.ArrayList values,
                                                  java.lang.String lang)
Generates an enumaration of values using AND link between the two last values. Transate the values if available in the lexicon.

Parameters:
values - the values to translate
lang - the language
Returns:
the sentence: value1, value2 and value3.

getGreetings

public java.lang.String getGreetings(java.lang.String lang)
Returns the Greeting depending on the system hour and the language - Good Morning (6..12) - Good Afternoon (13..17) - Good Evening (18..21) - Good Night (22..6)

Parameters:
lang - language identification
Returns:
the sentence

genPrompts

public java.lang.String[] genPrompts(java.lang.String lang,
                                     stackact next_moves)
generates 3 sentence : open, directed, help. The attribute used for generating the help message is the first asking action.

Parameters:
lang - the language identification
next_moves - the moves to generate
Returns:
the Array of sentences ordered: - open - directed - help

genFreePrompts

public java.lang.String[] genFreePrompts(java.lang.String lang,
                                         stackact next_moves,
                                         java.lang.String help_attribute)
generates 3 sentence : open, directed, help The attribute used for generating the help messag is the help_attribute parameter Open and directed messages are generated with fillFreeResponseData. Help message is genered with genHelpPrompt

Parameters:
lang - the language identification
next_moves - the moves to generate
help_attribute - the attribute used for generating the help message
Returns:
the Array of sentences ordered: - open - directed - help

genHelpPrompt

public java.lang.String genHelpPrompt(java.lang.String lang,
                                      java.lang.String attribute)
generates a sentence giving help for the current attribute. First search for a specific help message. If it doesn't exists, then search for a menu-message (only for categoric defined attributes). Finally, a general help message is selected. genMenuPrompts genera 2 frases: word_related i num si NO hi ha help, i el atribut té enumeració de values, s'usa word_related sinó, s'usa un help general

Parameters:
lang - the language identification
attribute - the attribute identification
Returns:
one sentence