def main():
    problem = raw_input(
    )  #This asks for am input from the users and accepts it as string
    problem_as_list = problem.split(
    )  #This splits the string received on the basis of blankspace
    operable_problem = [int(k) for k in problem_as_list
                        ]  #Converts that string list into an interger list
    start_time = time.time()
    if (0 in operable_problem):
        c = search.check(
            operable_problem
        )  # c is a boolean variable that stores if the input has a solution or not.
        if (c == True):
            print("Solution exists")
            game = State(
                operable_problem
            )  #This ststement will convert our input into a customized data-structure State
            result = search.find(
                game)  #This will run bfs function in search.py file.
            final_pos = result.position
            nodes_expanded = result.nodes_expanded
            print "Time taken", time.time() - start_time
            p = psutil.Process(os.getpid())
            print "Memory consumed", str(
                p.memory_info()[0] / float(2**20)) + "KB"
            print "Number of times node was expanded", nodes_expanded
            print "Path or moves to take in order to reach goal state", path(
                final_pos)
        else:
            print("There is no solution to this puzzle")

    else:
        print("Can't find a solution")
Пример #2
0
def find_anime(message: Message, bot=None):
    search_guesses = search.find(message.text)[:6:]
    search_result = search_guesses.pop(0)
    message_text = ""
    if len(search_guesses) > 0:
        message_text += "<b>Perhaps you meant:</b>"
        for search_guess in search_guesses:
            related_title = db.get_first_title(search_guess)
            message_text += f'\n{related_title}'
        message_text += '\n\n'
    titles = db.get_meta_by_id(search_result)['titles'].split(',')
    message_text += f"Is it <b>{titles[0]}</b>?"
    release_date = db.get_meta_by_id(search_result)['release_date']
    message_text += f'\nYear: {release_date}\n\n'
    if len(titles) > 1:
        message_text += '<b>Alternative titles:</b>\n'
        for title_ind in range(1, len(titles)):
            message_text += f'{titles[title_ind]}\n'
    markup = types.ReplyKeyboardMarkup(row_width=2)
    yes_button = types.KeyboardButton('Yes')
    no_button = types.KeyboardButton('No')
    exit_button = types.KeyboardButton('Exit removing mode')
    markup.add(no_button, yes_button, exit_button)
    anime_poster = db.get_poster(search_result)
    if anime_poster:
        bot.send_photo(message.chat.id, anime_poster)
    user_answer = bot.send_message(message.chat.id, message_text, reply_markup=markup)
    bot.register_next_step_handler(user_answer, process_user_search_answer, search_result, bot=bot)
Пример #3
0
def answer(question = None, answer = None, error = None):
    question = request.form["question_input"]
    if ("who" not in question.lower() and "when" not in question.lower()):
        return render_template("input.html", error = "Error: Invalid question. Must contain who or when.")
    s = search.find(question)
    answer = s
    return render_template("output.html", question=question, answer=answer)
Пример #4
0
def c():
    if request.method == 'GET':
        name = request.args.get('song_data')
        sugg_list = find(
            name
        )  #['hello','hello','hello','hello','hello','hello','hello','hello','hello','hello']
        print(sugg_list)
        return jsonify({'list': sugg_list, 'size': len(sugg_list)})
Пример #5
0
def answer(question=None, answer=None, error=None):
    question = request.form["question_input"]
    if ("who" not in question.lower() and "when" not in question.lower()):
        return render_template(
            "input.html",
            error="Error: Invalid question. Must contain who or when.")
    s = search.find(question)
    answer = s
    return render_template("output.html", question=question, answer=answer)
Пример #6
0
def do_search():
    query = request.query.query.lower()
    max_results = MAX_SEARCH_RESULTS
    skip = int(request.query.get('skip',0))
    paths = []
    for username in prioritized_users(USERS_DB):
        paths.append(op.join(DATA_DIR,username))
    
    res=[]    
    for line in search.find(query,paths,max_res = max_results + skip)[skip:]:
        username,_,path=line.partition(' ')
        res.append((username,path))
    
    return json.dumps({ 'success':bool(res), 'data':res },encoding='latin-1')
Пример #7
0
    def compareLists(self):
        # verify inputs
        if(self.pathExato.text()!= ""):
            if(self.pathVestibular.text()!= ""):

                if(self.rbUfscar.isChecked()):
                    if str(self.pathVestibular.text()).endswith('.pdf'):
                        search.find(self.pathExato.text(),
                                    self.pathVestibular.text(),
                                    search.readUfscar)
                    else:
                        self.extensionError("pdf")
                elif(self.rbUnicamp.isChecked()):
                    if str(self.pathVestibular.text()).endswith('.txt'):
                        search.find(self.pathExato.text(),
                                    self.pathVestibular.text(),
                                    search.readUnicamp)
                    else:
                         self.extensionError("txt")
                elif(self.rbUsp.isChecked()):
                    if str(self.pathVestibular.text()).endswith('.txt'):
                        search.find(self.pathExato.text(),
                                    self.pathVestibular.text(),
                                    search.readUsp)
                    else:
                          self.extensionError("txt")
                elif(self.rbUnesp.isChecked()):
                    if str(self.pathVestibular.text()).endswith('.pdf'):
                        search.find(self.pathExato.text(),
                                    self.pathVestibular.text(),
                                    search.readUnesp)
                    else:
                          self.extensionError("pdf")

            else:
                QMessageBox.critical(None,"Erro",                                     "Selecione o arquivo de vestibular ")
        else:
            QMessageBox.critical(None,"Erro",
            "Selecione o arquivo de alunos")
Пример #8
0
    def compareLists(self):
        # verify inputs
        if (self.pathExato.text() != ""):
            if (self.pathVestibular.text() != ""):

                if (self.rbUfscar.isChecked()):
                    if str(self.pathVestibular.text()).endswith('.pdf'):
                        search.find(self.pathExato.text(),
                                    self.pathVestibular.text(),
                                    search.readUfscar)
                    else:
                        self.extensionError("pdf")
                elif (self.rbUnicamp.isChecked()):
                    if str(self.pathVestibular.text()).endswith('.txt'):
                        search.find(self.pathExato.text(),
                                    self.pathVestibular.text(),
                                    search.readUnicamp)
                    else:
                        self.extensionError("txt")
                elif (self.rbUsp.isChecked()):
                    if str(self.pathVestibular.text()).endswith('.txt'):
                        search.find(self.pathExato.text(),
                                    self.pathVestibular.text(), search.readUsp)
                    else:
                        self.extensionError("txt")
                elif (self.rbUnesp.isChecked()):
                    if str(self.pathVestibular.text()).endswith('.pdf'):
                        search.find(self.pathExato.text(),
                                    self.pathVestibular.text(),
                                    search.readUnesp)
                    else:
                        self.extensionError("pdf")

            else:
                QMessageBox.critical(None, "Erro",
                                     "Selecione o arquivo de vestibular ")
        else:
            QMessageBox.critical(None, "Erro", "Selecione o arquivo de alunos")
Пример #9
0
def query(file_url):
    text, numPage = parsePdf(file_url)

    def listToString(s):
        # initialize an empty string
        str1 = ""

        # traverse in the string
        for j in range(0, len(s)):
            str1 += s[j]

        return str1

    text = listToString(text)

    s = ob.tokenize(text)
    for i in range(len(s)):
        s[i] = s[i].lower()
    di = {}
    for word in s:
        if word not in sw:
            # word = ps.stem(word)
            if word in di:
                di[word] += 1
            else:
                di[word] = 1

    k = Counter(di)
    high = k.most_common(5)

    query = " "
    for i in high:
        print(i[0], " :", i[1], " ")
        query = query + " " + i[0]

    results = find(query, 20)
    return results
Пример #10
0
    print("="*30)
    print(*arg, **kwargs)
    print("="*30)

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description="Compress video files.")
    parser.add_argument("ROOT", help="Where to begin the search for video files.")

    args = parser.parse_args()
    ROOT = os.path.abspath(args.ROOT)
    if not os.path.isdir(ROOT):
        raise(Exception("Please check the root path. %s" % ROOT))

    try:
        # Collect information!
        video_files = list(search.find(ROOT, MOVIE_EXT))
        if video_files:

            # Create a landing area for the original videos
            complete_path = os.path.join(ROOT, COMPLETE)
            if not os.path.isdir(complete_path):
                os.mkdir(complete_path)

            before_size = 0
            after_size = 0

            errors = [] # Collect any errors

            for raw_video in video_files:
                try:
                    # Actually compress the video
Пример #11
0
 def result(self):
     area = self.lineEdit_area.text()
     month = self.lineEdit_month.text()
     ans = search.find(area, month)
     self.lineEdit_2.setText(ans)
Пример #12
0
def main():

    print "[HW CarSpider ver 1.0]"

    parser=argparse.ArgumentParser()


    parser.add_argument('mode',help='choose operation type start,search or book',
                      choices=['start','st', 'search','se',
                       'book','bo','details','de'])
    parser.add_argument('domain',help='chose domain')
    parser.add_argument('-f','--firefox',help='firefox webbrowser',action='store_true')
    parser.add_argument('-c','--chrome',help='chrome webbrowser',action='store_true')
    parser.add_argument('-i','--ie',help='Internet Explorer webbrowser',action='store_true')
    parser.add_argument('-a','--air',help='Airport search',action='store',default = main_config["default_loc"], nargs = '?')
    parser.add_argument('-l','--city',help='Local town/city search',action='store_true')
    parser.add_argument('-z','--zip',help='Local zip search',action='store_true')
    parser.add_argument('-r','--rand',help='Random local/air search',action='store_true')
    parser.add_argument('-o','--oway',help='One-way search',action='store_true')
    parser.add_argument('-e','--exchange',help='Specify currency(exchange) \
    in format e.g. usd, eur. Special formats rnd = random currenct,\
     otr - any currency except of usd, gbp,eur')
    parser.add_argument('-v','--visa',help='Visa card booking',action='store_true')
    parser.add_argument('-m','--mc',help='Mastercard/maestro booking',action='store_true')
    parser.add_argument('-g','--gmail',help='Gmail confirmation email',action='store_true')
    parser.add_argument('-y','--yahoo',help='Yahoo confirmation email',action='store_true')
    parser.add_argument('-j','--json',help='JSON file with parameters')
    #parser.add_argument('--emul',help='Switch rest simulator',choices = ['on','off'])


    args=parser.parse_args()



    urls = intl_urls
    if args.domain not in intl_urls:
       sys.exit("Domain "+args.domain+" in settings!")
    else:
       url = intl_urls[args.domain]

    drivers=[]

    if args.json:
       path = main_config["scenarios_dir"] + "/" + args.json + ".json"
       print path
       print os.listdir(os.curdir)
       with open (path) as js:
         row = json.load(js)
       scenario = row['scenario']
    else:
         scenario = []
         if args.firefox: scenario.append({"browser":"firefox"})
         if args.chrome: scenario.append({"browser":"chrome"})
         if args.ie: scenario.append({"browser":"ie"})
         if not args.firefox and not args.chrome and not args.ie:
            scenario.append({"browser":main_config["default_browser"]})
         for br in scenario:
            #print args.air
            if args.city:
                br["pickup_loc"] = "city"
            elif args.zip:
                br["pickup_loc"] = "zip"
            elif args.rand:
                br["pickup_loc"] = random.choice(["zip","city","air"])
            elif args.air == None:
                br["pickup_loc"] = "air"
            elif args.air != None:
                br["pickup_loc"] = args.air.upper()


            if args.oway:
                if args.city:
                   br["dropoff_loc"] = "city"
                elif args.zip:
                     br["dropoff_loc"] = "zip"
                elif args.rand:
                     br["dropoff_loc"] = random.choice(["zip","city","air"])
                elif args.air == None:
                     br["dropoff_loc"] = "air"
                elif args.air != None:
                     br["dropoff_loc"] = args.air.upper()


            if args.exchange:
               br["currency"] = args.exchange

            if args.gmail: br["email_type"] = "gmail"
            if args.yahoo: br["email_type"] = "yahoo"
            if args.visa: br["card_vendor"] = "visa"
            if args.mc: br["card_vendor"] = "mc"

            if not args.gmail and not args.yahoo:
               br["email_type"] = main_config["default_email"]
            if not args.visa and not args.mc:
               br["card_vendor"] = main_config["default_card"]


    print scenario
    #sys.exit()


    i = 0
    for entity in scenario:
       if args.mode == 'book' and (not entity.has_key("email_type")  or
       not entity.has_key("card_vendor") ):
           sys.exit("Please specify email type and card vendor for booking!")
       driver = show(entity,i)
       i +=1
       drivers.append(driver)

    if args.mode == 'start' or args.mode == 'st':
       find(url,drivers,scenario, False)
    elif args.mode == 'search' or args.mode == 'se':
       find(url,drivers,scenario, True)
       results = IntlResults(drivers,scenario)
    elif args.mode == 'details' or args.mode == 'de':
       find(url,drivers,scenario, True)
       results = IntlResults(drivers,scenario,"rand")
       book = IntlBook(drivers,scenario)
       book.fill()
    elif args.mode == 'book' or args.mode == 'bo':
       find(url,drivers,scenario, True)
       results = IntlResults(drivers,scenario,"rand")
       book = IntlBook(drivers,scenario)
       book.fill(True)
Пример #13
0
def b():
    if request.method == 'GET':
        name = request.args.get('song_name')
        sugg_list = find(name)
        return jsonify({'sugg': sugg_list})
Пример #14
0
from recaudio import rec
from rectotext import rec_to_text
from search import find
from gtts import gTTS
import os
import pygame
import time

rec('record.wav')
question = rec_to_text()
answer = find(question)
tts = gTTS(text=answer, lang='en')
tts.save("good.mp3")
pygame.init()
pygame.mixer.music.load("good.mp3")
pygame.mixer.music.play()
time.sleep(5)