예제 #1
0
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
예제 #2
0
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.")
예제 #3
0
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.")
예제 #4
0
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")
예제 #5
0
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.")