def printMessage(self): if self._wasCorrect: if not self._wasFullyCorrect: printInCol('blue','It is actually spelled '+self._name+'.') else: printInCol('red','Wrong, the correct city is '+self._name+'.')
def printStats(qdb): print("") printInCol("green", "Learnt this session: " + str(learnt)) printInCol("red", "Forgotten this session: " + str(forgotten) + "\n") printInCol("blue", "Total: " + str(len(qdb.tot))) r, low, up = qdb.getActuallyKnownRatio() printInCol( "green", "Known, [%.0f%%" % (low * 100) + ", %.0f%%]" % (up * 100) + " %d%% c.i.: " % (questionDB.conf * 100) + str(len(qdb.known)), ) printInCol("yellow", "Active: " + str(len(qdb.active))) printInCol("red", "Never tried: " + str(len(qdb.untried)))
import os from colorPrint import printInCol from voice import get_google_voice def charToFileName(c): return reduce(lambda a, b: a + b, [str(ord(x)) + "_" for x in c])[:-1] + ".mp3" if __name__ == "__main__": with open(os.path.join(os.path.dirname(__file__), "data", "putonghua"), "r") as charFile: ql = [l.replace("\t", "").rstrip("\n").rsplit(",") for l in charFile if l[0] != "#"] for q in ql: print q[0] if get_google_voice(q[0], "zh-CN", "data/putonghuaListen/" + charToFileName(q[0])): printInCol("green", "Ok!") else: printInCol("red", "Error!")
inp = raw_input() except (KeyboardInterrupt, EOFError): running = False break if len(inp) > 0 and inp[0] == ":": command = inp[1:] if command == "again": continue elif command == "exit": running = False break elif command == "stat": printStats(qdb) elif command == "undo": if len(qdb.hist) == 0: printInCol("red", "No answers to undo...") if len(inp) > 0 and inp[0] == ":": command = inp[1:] if command in ["again", "a"]: continue if command in ["last", "l"]: if oldQId == None: printInCol("red", "This was the first question during this session...") else: qId = oldQId elif command == "exit": running = False break elif command == "stat": printStats(qdb) elif command in ["undo", "u"]:
def printMessage(self): if not self._wasCorrect: printInCol('red','Wrong, the correct answer is: '+self._answer+'.')
def pose(self): printInCol('yellow',self._question)
def printMessage(self): if not self._wasCorrect: printInCol('red','Wrong, the correct answer is: '+self._answer+'.') printInCol('blue','Character: '+self._char+'\nPinyin: '+self._pinyin)
def printMessage(self): if not self._wasCorrect: printInCol("red", "Wrong, this character is in English: " + self._answer + ".") printInCol("blue", "Pinyin: " + self._pinyin)