2024-06-03 11:32:49 +08:00
|
|
|
from app.Article import load_text_list_from_db, load_word_list, calculate_coverage
|
2024-05-08 19:30:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
def test_coverage_percentage():
|
|
|
|
try:
|
2024-06-03 11:32:49 +08:00
|
|
|
text_list = load_text_list_from_db("db\wordfreqapp.db")
|
|
|
|
word_set = load_word_list("db\The_Oxford.csv")
|
|
|
|
coverage_percentage = calculate_coverage(text_list, word_set)
|
2024-05-08 19:30:08 +08:00
|
|
|
|
2024-06-03 11:32:49 +08:00
|
|
|
assert 0 <= coverage_percentage <= 100, "Coverage percentage is not within the range [0, 100]"
|
2024-05-08 19:30:08 +08:00
|
|
|
|
2024-06-03 11:32:49 +08:00
|
|
|
print("coverage_percentage:", coverage_percentage)
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2024-05-08 19:30:08 +08:00
|
|
|
|
2024-06-03 11:32:49 +08:00
|
|
|
if __name__ == "__main__":
|
|
|
|
test_coverage_percentage()
|