def review(DB, wlist): shuffle(wlist) for windex in wlist: study_word(DB, windex, review_time) if do_exit: return wordlist.finish_review() wordlist.writestat()
def learn(DB, wlist): wsum = len(wlist) ## r2 cycle no = 0 # index of wlist r2_count = (wsum / r2_wcount + 1 if wsum % r2_wcount != 0 else wsum + r2_wcount) for i in range(r2_count): r2_wlist = (wlist[no:no+r2_wcount] if no+r2_wcount < wsum else wlist[no:]) no += len(r2_wlist) ## r1 cycle r2_sum = len(r2_wlist) r1_no = 0 r1_count = (r2_sum / r1_wcount + 1 if r2_sum % r1_wcount != 0 else r2_sum / r1_wcount) for j in range(r1_count): r1_wlist = (r2_wlist[r1_no:r1_no+r1_wcount] if r1_no+r1_wcount < len(r2_wlist) else r2_wlist[r1_no:]) r1_no += len(r1_wlist) shuffle(r1_wlist) print '\n\n\rCycle 1, NO. {0}'.format(j) for windex in r1_wlist: study_word(DB, windex, learn_time) if do_exit: return shuffle(r1_wlist) print '\n\n\rCycle 1 Review' for windex in r1_wlist: study_word(DB, windex, review_time) if do_exit: return ## review r2 words shuffle(r2_wlist) print '\n\n\rCycle 2, NO. {0}'.format(i) for windex in r2_wlist: study_word(DB, windex, review_time) if do_exit: return # end of round 2 cycle # wordlist.finish_learn() wordlist.writestat()
def learn(DB, wlist): wsum = len(wlist) ## r2 cycle no = 0 # index of wlist r2_count = (wsum / r2_wcount + 1 if wsum % r2_wcount != 0 else wsum + r2_wcount) for i in range(r2_count): r2_wlist = (wlist[no:no + r2_wcount] if no + r2_wcount < wsum else wlist[no:]) no += len(r2_wlist) ## r1 cycle r2_sum = len(r2_wlist) r1_no = 0 r1_count = (r2_sum / r1_wcount + 1 if r2_sum % r1_wcount != 0 else r2_sum / r1_wcount) for j in range(r1_count): r1_wlist = (r2_wlist[r1_no:r1_no + r1_wcount] if r1_no + r1_wcount < len(r2_wlist) else r2_wlist[r1_no:]) r1_no += len(r1_wlist) shuffle(r1_wlist) print '\n\n\rCycle 1, NO. {0}'.format(j) for windex in r1_wlist: study_word(DB, windex, learn_time) if do_exit: return shuffle(r1_wlist) print '\n\n\rCycle 1 Review' for windex in r1_wlist: study_word(DB, windex, review_time) if do_exit: return ## review r2 words shuffle(r2_wlist) print '\n\n\rCycle 2, NO. {0}'.format(i) for windex in r2_wlist: study_word(DB, windex, review_time) if do_exit: return # end of round 2 cycle # wordlist.finish_learn() wordlist.writestat()
# Filename: study.sh # Author: LIU Yang # Create Time: Mon Aug 19 21:55:58 HKT 2013 # License: LGPL v2.0+ # Contact Me: [email protected] # Brief: Use this to learn new words import shelve, sys, getopt import wordlist, learn_interface mode = "learn" # Handling options shortargs = "r" longargs = ["review"] opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs) for opt, value in opts: if opt in ["-r", "--review"]: mode = "review" # Prepare data db_name = wordlist.stat["use_dict"] db = shelve.open(db_name) wlist, partlist = wordlist.generate_wordlist(mode) # Start learning learn_interface.study(mode, db, wlist) wordlist.writestat() db.close()
# Filename: study.sh # Author: LIU Yang # Create Time: Mon Aug 19 21:55:58 HKT 2013 # License: LGPL v2.0+ # Contact Me: [email protected] # Brief: Use this to learn new words import shelve, sys, getopt import wordlist, learn_interface mode = 'learn' # Handling options shortargs = 'r' longargs = ['review'] opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs) for opt, value in opts: if opt in ['-r', '--review']: mode = 'review' # Prepare data db_name = wordlist.stat['use_dict'] db = shelve.open(db_name) wlist, partlist = wordlist.generate_wordlist(mode) # Start learning learn_interface.study(mode, db, wlist) wordlist.writestat() db.close()