def listOutput(NLUOutput,DMOutput): # DMOutput should be [list:SIZE,question:FLAG] resultNum = DMOutput['list'] #return listSize #different response depending on size if isinstance(resultNum, long): resultNum = int(resultNum) rstring = "" filePath = path.dirname(__file__)+'/prs/' if resultNum < 0: print "NLG Error: List Size less than zero" elif resultNum == 1: rstring += nlgu.get_random_line(filePath+"one_result.txt") elif resultNum == 0: rstring += nlgu.get_random_line(filePath+"no_result.txt") elif resultNum < 60: rstring += nlgu.get_random_line(filePath+"multi_result.txt").format(nlgu.int_to_english(resultNum)) elif resultNum < 101: rstring += nlgu.get_random_line(filePath+"multi_result.txt").format(resultNum) else: print resultNum rstring += nlgu.get_random_line(filePath+"multi_result.txt").format(getRandomQuantifier()) DMOutput['question'] == 'MORE_PREF' if resultNum == 0: rstring += " Type 'reset' to start over." # This should be removed elif DMOutput.has_key("question"): rstring += ' '+questionToUser(NLUOutput,DMOutput) else: rstring += "\n" return rstring
def listOutput(NLUOutput,DMOutput): # DMOutput should be [list:SIZE,question:FLAG] resultNum = DMOutput['list'] #return listSize #different response depending on size if isinstance(resultNum, long): resultNum = int(resultNum) rstring = "" filePath = path.dirname(__file__)+'/prs/' if resultNum < 0: logging.debug( "NLG Error: List Size less than zero") elif resultNum == 1: rstring += nlgu.get_random_line(filePath+"one_result.txt") elif resultNum == 0: rstring += nlgu.get_random_line(filePath+"no_result.txt") elif resultNum < 60: rstring += nlgu.get_random_line(filePath+"multi_result.txt").format(nlgu.int_to_english(resultNum)) elif resultNum < 101 or (NLUOutput[0].has_key('request') and NLUOutput[0]['request']=='COUNT'): rstring += nlgu.get_random_line(filePath+"multi_result.txt").format(resultNum) else: rstring += nlgu.get_random_line(filePath+"multi_result.txt").format(getRandomQuantifier()) if not DMOutput.has_key('question'): DMOutput['question'] == 'MORE_PREF' if resultNum == 0: rstring += " Type 'reset' to start over." # This should be removed elif DMOutput.has_key("question"): rstring += ' '+questionToUser(NLUOutput,DMOutput) else: rstring += "\n" return rstring
def getPrintSentence(itemType, subjectList): subjectString = "_".join(subjectList) if len(subjectList) > 0: subjectString += "_" elif len(subjectList) == 0 and itemType != "director": itemType = "default" fileName = path.dirname(__file__) + "/prs/" + subjectString + itemType + "_sentences.txt" rstring = nlgu.get_random_line(fileName) if rstring == "": print "ERROR" return rstring
def getPrintSentence(itemType, subjectList): subjectString = "_".join(subjectList) if len(subjectList) > 0: subjectString += '_' elif len(subjectList) == 0 and itemType != "director": itemType = "default" fileName = path.dirname( __file__) + '/prs/' + subjectString + itemType + '_sentences.txt' rstring = nlgu.get_random_line(fileName) if rstring == "": print "ERROR" return rstring