Parcourir la source

feat: 随机单词时去除不同词条的同一单词的权重不同问题

SongZihuan il y a 3 ans
Parent
commit
25f662dc34
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2 2
      core/db.py

+ 2 - 2
core/db.py

@@ -336,8 +336,8 @@ class WordDatabase(DataBase):
                 print()
                 return None
             box += 1
-            count = self.search(columns=["COUNT(ID)"], table="Word", where=f"box<={box}")[0][0]
-        get = self.search(columns=["word"], table="Word", where=f"box<={box}",
+            count = self.search(columns=["COUNT(DISTINCT word)"], table="Word", where=f"box<={box}")[0][0]
+        get = self.search(columns=["DISTINCT word"], table="Word", where=f"box<={box}",
                           limit=1, offset=random.randint(0, count - 1))[0][0]
         self.__logger.debug(f"Rand word {self.dict_name} from box: {box} count: {count} get: {get}")
         return self.find_word(get, False)