Commits

Anonymous committed 70631a2 Draft

[session] added default session length. implemented more clever learning rating change

  • Participants
  • Parent commits 94010da

Comments (0)

Files changed (3)

     reactions[sys.argv[1]](sys.argv[2:])
 
 if __name__ == '__main__':
-    main()
+    try:
+        main()
+    except KeyboardInterrupt:
+        print ""
+        print "bye!"
     def __repr__(self):
         return self.word
 
+    def know(self):
+        self.rating -= 100
+
+    def unknown(self):
+        self.rating += abs(self.rating) if self.rating != 0 else 100
+
+    def postpone(self):
+        self.rating -= 10000
+
 
 # setup elixir
 setup_all()
     Key = promt_word_reaction()
     if Key == 'k':
         print "marked as known"
-        word.rating -= 100
+        word.know()
     elif Key == 'd':
         print "marked as don't known"
-        word.rating += 100
+        word.unknown()
     elif Key == 'p':
         print "word is postponed"
-        word.rating -= 1000
+        word.postpone()
     elif Key == 'q':
         print "bye"
         exit(0)
     session.commit()
 
-def words_session():
+def words_session(wordsToProcess = 50):
     print "===== beginig new word session ====="
-    for word in Word.query.order_by(-Word.rating).all():
+    print "words to process during this session : %d" % (wordsToProcess)
+    for word in Word.query.order_by(-Word.rating).limit(wordsToProcess).all():
         word_session_work(word)
     print "===== session ended - all words are processed ====="