def index(): db = os.path.join(os.path.dirname(__file__), 'wiki_links.db') conn = DB_Connection(db) search = GraphSearch(conn) path = search.get_path(29944, 42131) out = "" for i in path: out += i + " -> " return out
def main(): db = os.path.join(os.path.dirname(__file__), 'wiki_links.db') conn = DB_Connection(db) # if the solution above doesn't work, you can hard code the location of the DB here. # conn = DB_Connection('path_to_database_here') try: print "What article would you like to start on?" start, start_id = get_title(conn) except OperationalError: exit("It looks like there was a problem connecting to the database. \nPlease make sure that you have a valid database named wiki_links.db in the same directory as this file.") print "" print "What article would you like to end on?" end, end_id = get_title(conn) print "" print "You are searching for the shortest path between: %s and %s." % (start, end) search = GraphSearch(conn) path = search.get_path(start_id, end_id) print "" print "--------------------- RESULTS ---------------------" print "" # Prints the results onto the screen along with the other names that the article could # potentially be listed under. counter = 1 for article in path: redirects = "" for x in conn.get_redirects(article): redirects += x + ", " redirects = redirects[:-2] print str(counter) + ": " + article + " --- Other Possible titles: (" + redirects + ")\n" counter += 1