def set_end(context, text): canarr = [] if(text == 'person'): canarr.append('On what date was ' + subject + ' born?') canarr.append('On what date did ' + subject + ' die?') canarr.append('How old was ' + subject + ' when he died?') canarr.append('Was ' + subject + ' ever married?') if(text == 'language'): canarr.append('Where is the ' + subject + ' spoken?') canarr.append('What language family is the ' + subject + ' a part of?') canarr.append('Approximately how many people speak the ' + subject + '?') canarr.append('Who speaks the ' + subject + '?') if(text == 'city'): canarr.append('What is the population of ' + subject + '?') canarr.append('In what country is ' + subject + '?') canarr.append('What is the population density of ' + subject + '?') canarr.append('What kind of transportation exists in ' + subject + '?') if(text == 'instrument'): canarr.append('What is the ' + subject + '?') canarr.append('How is the ' + subject + ' played?') canarr.append('How does one play the ' + subject + '?') canarr.append('Does the ' + subject + ' have strings?') testarr = [] holder = [] holder = askfunc.getClassification(article, sentences) testarr = askfunc.printQuests(5,holder) for x in range(0,4): assert testarr[x] == canarr[x]
def set_end(context, d): canarr = [] canarr = askfunc.getClassification(article,sentences) holdarr = [] holdarr = askfunc.printQuests(int(number), canarr) assert len(holdarr) == int(d)
def set_end(context, text): holdarr = [] if (text=="number"): holdarr = askfunc.printQuests(int(-1), []) assert holdarr[0] == "Invalid number of questions entered" elif (text=="sentences"): holdarr = askfunc.getClassification("", sentences) assert holdarr[0] == "There were no sentences found"
def set_end(context): sentences = [] holder = [] questarr = [] ansarr = [] sentences = open("pers_text.txt.sentences").read().split('\n') holder = askfunc.getClassification("pers_text.txt", sentences) questarr = askfunc.printQuests(5, holder) ansarr = askfunc.answerQuests(len(questarr)) assert (len(ansarr) == len(questarr))
def test_class_unmatched( self, mock_classify_article, mock_personQuest, mock_languageQuest, mock_instrumentQuest, mock_cityQuest ): mock_classify_article.return_value = "abcdef" mock = MagicMock() with mock as sentences: value = askfunc.getClassification("abcdef", sentences) assert not mock_personQuest.called assert not mock_languageQuest.called assert not mock_instrumentQuest.called assert not mock_cityQuest.called
import re import classify import pronounce import evaluate import askfunc article = sys.argv[1] nquestions = int(sys.argv[2]) sentname = article + '.sentences' sentfile = open(sentname) sentences = sentfile.read().split('\n') sentfile.close() cannedarray=[] cannedarray = askfunc.getClassification(article, sentences) askfunc.printQuests(nquestions, cannedarray) questionarray=[] f = open(sentname) text=f.read() f.seek(0) num=0 appos = [] current = '' record = 0 scorearray=[] citycount=0 for line in f: #print line
def test_class_city(self, mock_classify_article, mock_cityQuest): mock_classify_article.return_value = "city" mock = MagicMock() with mock as sentences: value = askfunc.getClassification("city", sentences) mock_cityQuest.assert_called()
def test_class_instrument(self, mock_classify_article, mock_instrumentQuest): mock_classify_article.return_value = "instrument" mock = MagicMock() with mock as sentences: value = askfunc.getClassification("instrument", sentences) mock_instrumentQuest.assert_called()
def test_class_language(self, mock_classify_article, mock_languageQuest): mock_classify_article.return_value = "language" mock = MagicMock() with mock as sentences: value = askfunc.getClassification("language", sentences) mock_languageQuest.assert_called()