def test7(): prepareDataFolder("Data") saveLinksFromTitlePages(KHOA_HOC, "01/01/2018", "05/01/2018", "Science_Jan2018_Titles.txt", "Data") if not os.path.isdir("Data") or not os.path.isfile("Data/Science_Jan2018_Titles.txt"): print("Test 7 not OK. Please make sure the file is in the folder.") else: pass
def test10(): prepareDataFolder("Data") saveLinksFromTitlePages(KHOA_HOC, "01/01/2018", "02/01/2018", "Science_Jan2018_Titles.txt", "Data") saveArticles("Science_Jan2018_Titles.txt", "Science_Jan2018_Articles.txt", "Data") f = open("Data/Science_Jan2018_Articles.txt").readlines() if len(f) >= 7: print("Test 10 OK.") else: print("Test 10 not OK.")
def test13(): if not os.path.isfile("Data/Science_Jan2018_Articles.txt"): prepareDataFolder("Data") saveLinksFromTitlePages(KHOA_HOC, "01/01/2018", "02/01/2018", "Science_Jan2018_Titles.txt", "Data") saveArticles("Science_Jan2018_Titles.txt", "Science_Jan2018_Articles.txt", "Data") f = open("Data/Science_Jan2018_Articles.txt").readlines() if len(f) < 7: prepareDataFolder("Data") saveLinksFromTitlePages(KHOA_HOC, "01/01/2018", "02/01/2018", "Science_Jan2018_Titles.txt", "Data") saveArticles("Science_Jan2018_Titles.txt", "Science_Jan2018_Articles.txt", "Data") r = readContent("Science_Jan2018_Articles.txt", "Data") if getSimpleWordFrequency(r)["và"] >= 1: print("Test 13 OK.") else: print("Test 13 not OK.")
def test11(): if not os.path.isfile("Data/Science_Jan2018_Articles.txt"): prepareDataFolder("Data") saveLinksFromTitlePages(KHOA_HOC, "01/01/2018", "02/01/2018", "Science_Jan2018_Titles.txt", "Data") saveArticles("Science_Jan2018_Titles.txt", "Science_Jan2018_Articles.txt", "Data") f = open("Data/Science_Jan2018_Articles.txt").readlines() if len(f) < 7: prepareDataFolder("Data") saveLinksFromTitlePages(KHOA_HOC, "01/01/2018", "02/01/2018", "Science_Jan2018_Titles.txt", "Data") saveArticles("Science_Jan2018_Titles.txt", "Science_Jan2018_Articles.txt", "Data") r = readContent("Science_Jan2018_Articles.txt", "Data") if len(r.iloc[0, 0]) > 0 or len(r.iloc[0, 1]) > 0 or len(r.iloc[0, 2]) > 0: print("Test 11 OK") else: print("Test 11 not OK")
def test12(): if not os.path.isfile("Data/Science_Jan2018_Articles.txt"): prepareDataFolder("Data") saveLinksFromTitlePages(KHOA_HOC, "01/01/2018", "02/01/2018", "Science_Jan2018_Titles.txt", "Data") saveArticles("Science_Jan2018_Titles.txt", "Science_Jan2018_Articles.txt", "Data") f = open("Data/Science_Jan2018_Articles.txt").readlines() if len(f) < 7: prepareDataFolder("Data") saveLinksFromTitlePages(KHOA_HOC, "01/01/2018", "02/01/2018", "Science_Jan2018_Titles.txt", "Data") saveArticles("Science_Jan2018_Titles.txt", "Science_Jan2018_Articles.txt", "Data") r = readContent("Science_Jan2018_Articles.txt", "Data") s = addAuthorColumn(r) tester = False for e in s.loc[:, "author"]: if e.find("Phương Hoa") >= 0: tester = True if tester: print("Test 12 OK.") else: print("Test 12 not OK.")