Beispiel #1
0
def testToProduction():
    count = 0
    db.createTable(
        "/home/pi/Desktop/ReedTheRobot/Databases/reedHeadlines",
        "episode2final", ["id", "headline"],
        ["INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT", "TEXT NOT NULL"])
    while True:
        sample = db.retrieveData(
            "/home/pi/Desktop/ReedTheRobot/Databases/reedHeadlines", "*",
            "episode2", 1, count)
        text = sample[0][1]
        print(text)
        keep = input(
            "Would you like to keep this for the episode? (to terminate enter '0') [Y/N]: "
        )
        if keep == "Y":
            edit = input("Would you like to make any edits? [Y/N]: ")
            if edit == "Y":
                finalText = input("Enter edited headline: ")
            else:
                finalText = text
            db.insertData(
                "/home/pi/Desktop/ReedTheRobot/Databases/reedHeadlines",
                "episode2final", "headline", finalText)
            count += 1
            print("Inserted into final table.")
        elif keep == "0":
            sys.exit()
        else:
            count += 1
            print("Moving to next entry...")
            continue
Beispiel #2
0
def insert(archive):
    length = len(archive)
    print("Inserting headlines...")
    start = time.time()
    for i in range(length):
        db.insertData(database, table, archive[i].text.replace('"', ''))
    end = time.time()
    totalTime = end - start
    final = str(round(totalTime, 4))
    print("Successfully inserted archive headlines in " + final + "s.")
Beispiel #3
0
def getFrontPage():
    rawData = scraper.getBzfdHeadlines()
    database = 'bzfdNews'
    table = 'news'
    db.createTable(database, table)
    length = len(rawData)
    headline = []
    for num in range(length):
        headline.append(rawData[num])
    print("Inserting headlines...")
    for i in range(len(headline)):
        db.insertData(database, table, headline[i].replace('"', ''))
    print("Successfully inserted current headlines.")
Beispiel #4
0
def reedToDB():
    while True:
        num = input("How many samples do you want Reed to store?: ")
        if num == "0":
            break
        else:
            pass
        textArr = returnXSamples(int(num))
        for i in range(len(textArr)):
            print(textArr[i])
            text = textArr[i].replace('"', '')
            db.insertData(
                "/home/pi/Desktop/ReedTheRobot/Databases/reedHeadlines",
                "generatedHeadlines", "headline", text)
Beispiel #5
0
def terminalGenerate():
    while True:
        gen = input("Generate headline? [Y/N]: ")
        if gen == "Y":
            sample = returnSample()
            print(sample)
            insert = input("Insert into database? [Y/N]: ")
            if insert == "Y":
                text = sample.replace('"', '')
                db.insertData(
                    "/home/pi/Desktop/ReedTheRobot/Databases/reedHeadlines",
                    "episode2", "headline", text)
            else:
                continue
        else:
            sys.exit()