def search_menu(self): """ Search menu provides 6 options 1 - Search by date 2 - Search by date range 3 - Search by time 4 - Search by contains (this is the "exact search") 5 - Search by pattern 6 - Return to main menu """ while True: choice = menu.make(menu.search) if choice == 1: # search by exact date found_tasks = search.Search().search_by_date(self.task_list) elif choice == 2: # search by range of dates found_tasks = search.Search().search_by_date_range( self.task_list) elif choice == 3: # search by time found_tasks = search.Search().search_by_time(self.task_list) elif choice == 4: # exact string search found_tasks = search.Search().search_by_contains( self.task_list) elif choice == 5: # pattern search found_tasks = search.Search().search_by_pattern(self.task_list) elif choice == 6: return self.main_menu() if found_tasks: self.edit_menu(found_tasks) else: print("No tasks found.") utils.wait() return self.search_menu()
def recherche(self): checked = [] if self.checkBox_1.isChecked(): checked.append(1) if self.checkBox_2.isChecked(): checked.append(2) if self.checkBox_3.isChecked(): checked.append(3) if self.checkBox_4.isChecked(): checked.append(4) if self.checkBox_5.isChecked(): checked.append(5) if self.checkBox_6.isChecked(): checked.append(6) if self.checkBox_7.isChecked(): checked.append(7) searchObj = search.Search([], 'corpusFr/frCorpus.txt', 1) query = self.lineEdit.text() queryToken = searchObj.text2list(query) print(queryToken) queryKeyWords = searchObj.getKeyWords(queryToken) print(queryKeyWords) result = searchObj.getResult(queryKeyWords, 1) data2send = list(result)[:5] self.sendData(data2send, checked, queryToken)
def next_state(self): if self.tag_id == 0 or self.tag_id == 2 or self.tag_id == 9: return turn_tag_position.TurnTagPosition(self.next_input()) elif self.tag_id == 4 or self.tag_id == 7: return search.Search(self.next_input()) else: return Stop(self.next_input())
def move(self, row: int, col: int) -> bool: "makes the move after checking if move is valid" # displaying move # move must be on grid if not rules.Rules().moveIsOnGrid(self._board, row, col): #print("INVALID: move is off grid") return False # move must be available if rules.Rules().moveIsTaken(self._board, row, col): #print("INVALID: move is unavailable") return False # move must have adjacent enemies if not rules.Rules().moveHasAdjacentEnemies(self._board, row, col, self.get_enemy_kind()): #print("INVALID: no adjacent opponents") return False # move must have flippable enemies if not rules.Rules().moveHasFlippableEnemies(self._board, row, col, self.get_ally_kind(), self.get_enemy_kind()): #print("INVALID: no flippable opponents") return False # all conditions are satisfied self._board.set_piece(row, col, self.get_ally_kind()) # flipping pieces pieces = search.Search().getFlippableEnemies(self._board, row, col, self.get_ally_kind(), self.get_enemy_kind()) for piece in pieces: piece.flip() return True
def main(): s = problem.State() inputVar(s) inputRules(s) inputForbidden(s) s.inputConstraints() s.inputHeuristic() print("\nDictionary: " + str(s.dt)) print("Variables: " + str(s.variables)) print("Rules: " + str(s.rules)) print("Rule Conditions: " + str(s.rule_conditions)) print("Rule costs: " + str(s.rule_cost)) print("Forbidden States: " + str(s.forbidden)) print("Constraints: " + str(s.constraints)) print("Heuristic function: " + str(s.heuristic)) s.inputStartState() s.inputGoalState() print("\nStart: " + str(s.dt)) print("Goal: " + str(s.goal)) print() f = search.Search(s) print(f.aSearch())
def recherche(self): checked = [] if self.checkBox_1.isChecked(): checked.append(1) if self.checkBox_2.isChecked(): checked.append(2) if self.checkBox_3.isChecked(): checked.append(3) if self.checkBox_4.isChecked(): checked.append(4) if self.checkBox_5.isChecked(): checked.append(5) if self.checkBox_6.isChecked(): checked.append(6) if self.checkBox_7.isChecked(): checked.append(7) searchObj = search.Search([], 'corpus/arCorpus.txt', 2) queryToken = ingredient print("Words: ", queryToken) queryKeyWords = searchObj.getKeyWords(queryToken) print("keyWords: ", queryKeyWords) checked, result = searchObj.getResult(queryKeyWords, 2, checked) self.sendData(result)
def recherche(self): self.labelLoad.setVisible(True) checked = [] if self.checkBox_1.isChecked(): checked.append(1) if self.checkBox_2.isChecked(): checked.append(2) if self.checkBox_3.isChecked(): checked.append(3) if self.checkBox_4.isChecked(): checked.append(4) if self.checkBox_5.isChecked(): checked.append(5) if self.checkBox_6.isChecked(): checked.append(6) if self.checkBox_7.isChecked(): checked.append(7) searchObj = search.Search([], 'corpusFr/frCorpus.txt', 1) queryToken = ingredient print(queryToken) queryKeyWords = searchObj.getKeyWords(queryToken) print(queryKeyWords) result = searchObj.getResult(queryKeyWords, 1) data2send = list(result) self.sendData(data2send, checked, queryKeyWords) self.labelLoad.setVisible(False)
def search_view(request): search_query = get_string(request, 'query') tag_cloud = '' top_senders = '' expanded_html = '' s = search.Search(request.GET.items()) if len(s.get_query_set()) == 1: expanded_html = get_expanded_html(s.get_query_set()[0], s) elif len(s.get_query_set()) != 0: tag_cloud = tags.search_results_to_tag_cloud_html(s.get_query_set(), s) top_senders = people.search_results_to_top_senders_html( s.get_query_set(), s) strRequestURL = "http://" + request.META['HTTP_HOST'] + s.get_rss_url() t = loader.get_template('search.html') c = RequestContext( request, { 'query_name': s.get_form_query_name(), 'hidden_form': s.get_hidden_form_html(), 'search_html': s.get_html(), 'tag_cloud': tag_cloud, 'top_senders': top_senders, 'expanded_html': expanded_html, 'results': s.get_query_set(), 'rssFeedURL': strRequestURL, }) response = HttpResponse(t.render(c)) if request.GET.has_key('recipient-2'): response.set_cookie('team', request.GET['recipient-2']) return response
def __init__(self): self.email = input('Enter your email address: ') self.pw = input('Enter your password: '******'Enter the item: ') search.Search(self.s, self.email, self.pw) while True: pass
def recherche(self): checked = [] if self.checkBox_1.isChecked(): checked.append(1) if self.checkBox_2.isChecked(): checked.append(2) if self.checkBox_3.isChecked(): checked.append(3) if self.checkBox_4.isChecked(): checked.append(4) if self.checkBox_5.isChecked(): checked.append(5) if self.checkBox_6.isChecked(): checked.append(6) if self.checkBox_7.isChecked(): checked.append(7) searchObj = search.Search([], 'corpus/arCorpus.txt', 2) query = self.lineEdit.text() queryToken = searchObj.text2list(query) queryKeyWords = searchObj.getKeyWords(queryToken) checked, result = searchObj.getResult(queryKeyWords , 2) self.sendData(result, checked)
def main(): print(WGPSEC_BANNER) user_cookie = login() if user_cookie is None: return page_size = 10 # settings: page size if not os.path.exists('pageSize.cfg'): with open('pageSize.cfg', 'w') as f: page_size = input('输入你想查询的默认条数:') f.write(page_size) f.close() else: # print('token验证成功') with open('pageSize.cfg', 'r+') as f: page_size = int(f.read()) f.close() if int(page_size) > 99: print('查询的条数超过100,请手动修改pageSize.cfg文件,建议改为99,避免出错') return parser = argparse.ArgumentParser() parser.description = ('嗨!你好!\n' '当你看到这里的时候,很高兴你已经成为了我们的一员!\n' '当你第一次运行的时候需要你输入一次你的cookie,方便我们认证,只需要一次哦!') arg_group = parser.add_mutually_exclusive_group() arg_group.add_argument('-c', '--city', type=str, help="查询的城市") arg_group.add_argument('-i', '--ip', type=str, help="查询的IP") arg_group.add_argument('-t', '--title', type=str, help="查询网站标题") parser.add_argument("-p", '--port', type=int, help="查询开放特定端口") args = parser.parse_args() se = search.Search(user_cookie, page_size) if args.city: se.city(args.city) elif args.ip: if args.ip == '127.0.0.1': print('输入的是局域网地址,无法查询') return else: se.host(args.ip) elif args.title: se.title(args.title) elif args.port: if int(args.port) > 65535 or int(args.port) < 0: print('输入的端口范围不正确') return else: se.port(args.port) elif args.ip and args.port: se.ip_port(args.ip, args.port)
def doOnlineSearche(self, event): queryKeyWords = '-'.join(self.keywords) import webbrowser new = 2 url = "http://www.marmiton.org/recettes/recherche.aspx?type=all&aqt=" + queryKeyWords webbrowser.get(using='chromium-browser').open(url, new=new) searchObj = search.Search([], 'corpusFr/frCorpus.txt', 1) searchObj.updateCorpus(url)
def moveHasAdjacentEnemies(self, board: board.Board, row: int, column: int, enemy_kind: str) -> bool: "takes in the enemy str to check if there are adjacent enemies at row & col of the board" pieces = search.Search().getAdjacentEnemies(board, row, column, enemy_kind) if len(pieces) > 0: return True return False
class Command(BaseCommand): help = 'Reindex everything.' args = '' option_list = BaseCommand.option_list + ( make_option('-C', '--check-just-read', action='store_true', dest='check', default=False, help='Check snippets utf-8'), make_option('-c', '--check', action='store_true', dest='check2', default=False, help='Check snippets utf-8 by walking through index'), ) def handle(self, *args, **opts): from catalogue.models import Book import search if opts['check']: sfn = glob(settings.SEARCH_INDEX + 'snippets/*') print sfn for fn in sfn: print fn bkid = int(path.basename(fn)) with open(fn) as f: cont = f.read() try: uc = cont.decode('utf-8') except UnicodeDecodeError, ude: print "error in snippets %d" % bkid if opts['check2']: s = search.Search() reader = s.searcher.getIndexReader() numdocs = reader.numDocs() for did in range(numdocs): doc = reader.document(did) if doc and doc.get('book_id'): bkid = int(doc.get('book_id')) #import pdb; pdb.set_trace() stdout.write("\r%d / %d" % (did, numdocs)) stdout.flush() ss = doc.get('snippet_position') sl = doc.get('snippet_length') if ss and sl: snips = Snippets(bkid) try: txt = snips.get((ss, sl)) assert len(txt) == sl except UnicodeDecodeError, ude: stdout.write("\nerror in snippets %d\n" % bkid) raise ude stdout.write("\ndone.\n")
def moveHasFlippableEnemies(self, board: board.Board, row: int, column: int, ally_kind: str, enemy_kind: str) -> bool: "checks if the move has enemies nearby to flip" pieces = search.Search().getFlippableEnemies(board, row, column, ally_kind, enemy_kind) if len(pieces) > 0: return True return False
class RegisterUser: global display display = lcddriver.lcd() srh = search.Search() enr = enroll.Enroll() def __init__(self): pass def main(self): b = False timeStamp = time.time() while (time.time() - timeStamp) <= 120: display.lcd_clear() display.lcd_display_string("Put Authorizer's", 1) display.lcd_display_string("Finger", 2) a = self.srh.main() if a[0] != 404 and a[0] != 304: try: fp = open('records.txt', 'r') for line in fp: arg1, arg2 = line.split(',') if arg1 == str(a[1]) and arg2 == (str(a[2]) + "\n"): b = True break else: b = False finally: fp.close() break else: pass if b: timeStamp = time.time() while (time.time() - timeStamp) <= 120: display.lcd_clear() display.lcd_display_string("Put New Finger", 1) c = self.srh.main() if c[0] == 404: pass elif c[0] == 304: self.enr.main(1) break else: display.lcd_clear() display.lcd_display_string("Already", 1) display.lcd_display_string("Registered", 2) time.sleep(2) display.lcd_clear() break else: display.lcd_clear() display.lcd_display_string("Finger Isn't", 1) display.lcd_display_string("Authorized", 2) time.sleep(2) display.lcd_clear()
def search_with_google(self, event=None): '''Search selected text with Google search engine''' text = self.get_selected_text().strip().strip('\n') if text: self.master.after(250, lambda: search.Search(self.master).open_link(f'https://www.google.com/search?q={text}')) else: messagebox.showerror('ZPAD', 'You need to select text to make search')
def get_search(type): termino = request.args.get('term') searchObj = search.Search() entidades, pagination = searchObj.get_results_contrataciones(termino, 1, 5) list = [] for e in entidades: list.append(e.descripcion) return json.dumps(list)
def getRecipeTitle(self, idRecipe): searchObj = search.Search([], 'corpus/arCorpus.txt', 1) title = searchObj.idSearchData(idRecipe, 1) cat = searchObj.idSearchData(idRecipe, 2) ing = searchObj.idSearchData(idRecipe, 3) prep = searchObj.idSearchData(idRecipe, 4) eng = searchObj.idSearchData(idRecipe, 5) inf = searchObj.idSearchData(idRecipe, 6) return title, cat, ing, prep, eng, inf
def Search(self): turn = self.turn.get() if turn == '黒番': children = search.Search(self.black, self.white, self.param.get(), self.trial.get(), self.core.get(), seed) #self.turn.set('白番') elif turn == '白番': children = search.Search(self.white, self.black, self.param.get(), self.trial.get(), self.core.get(), seed) #self.turn.set('黒番') children.sort(key=lambda x: x['pass']) for child in children: print('{} {:.3f}-{:.3f}'.format(child['move'], min(child['rate']), max(child['rate']))) print() return children
def run_search(job_title, location, search_title): datab = sqlite3.connect(db.information['db_name']) db_cursor = datab.cursor() #Listing attribute string oldq = ''' UPDATE listing SET job_exp = '{}', job_type = '{}', salary_est = '{}' WHERE hash_val = (SELECT hash_val FROM junction WHERE search_hash = '{}') ''' q = ''' UPDATE listing SET job_exp = '{}', job_type = '{}', salary_est = '{}' WHERE hash_val IN (SELECT hash_val FROM junction WHERE search_hash = '{}') ''' #180 searches per user search! Lets do this. job_exp = ['entry_level', 'mid_level', 'senior_level'] job_salaries = ['$14,000', '$30,000', '$50,000', '$70,000', '$90,000'] job_types = [ 'fulltime', 'contract', 'internship', 'temporary', 'parttime', 'commission' ] for sal in job_salaries: for typ in job_types: for xp in job_exp: search_options = { 'search_title': '', 'search_value': '', 'job_location': '', 'job_salary_est': '', 'limit': '', 'job_type': '', 'job_experience': '', 'website_url': '', 'global_db_name': 'zyber.db' } search_options['search_title'] = search_title search_options['search_value'] = job_title search_options['job_location'] = location search_options['job_salary_est'] = sal search_options['job_type'] = typ search_options['job_experience'] = xp search_ob = search.Search(search_options) search_ob.search() db_cursor.execute(q.format(xp, typ, sal, search_ob.search_hash)) datab.commit()
def parse(self): for f in self.read: file = open(f, 'r') self.search = s.Search(file) folder = self.create_folder() product = 'NULL' for line in file: if is_header(line): product = self.find_product(line) if product != 'NULL': self.search.make_file_name(product) self.write(line, folder, product) print('File finished')
def next_state(self): input_state = self.current_input[2] # this is a string if input_state == "Drive": return Drive(self.next_input()) elif input_state == "Search": return search.Search(self.next_input()) elif input_state == "PrepareToCatch": return PrepareToCatch(self.next_input()) elif input_state == "DriveUntilTagDistance": return drive_tag_distance.DriveUntilTagDistance(self.next_input()) else: print "DriveDistance --> Stop()" return Stop(self.next_input())
def taskE(pages, index, directory): print('\n' + 'Aufgabe e)') searcher = search.Search(index, pages) # Single search result1 = searcher.searchWithCosine(['tokens']) result2 = searcher.searchWithCosine(['index']) result3 = searcher.searchWithCosine(['classification']) # Multiple Search (and) result4 = searcher.searchWithCosine(['tokens', 'classification']) results = [result1, result2, result3, result4] filepath = directory + '/tfidf-search' searcher.resultsToFile(results, filepath) print('Suchergebnisse unter : ' + filepath + '.txt\'') return searcher
def main(args): criteria = { 'country': args.c, 'currency': args.x, 'location': args.l, 'locationType': 'AIRPORT', 'oneWay': args.o, 'sig': args.s } search_engine = search.Search(criteria) search_engine.begin()
def __init__(self, src_lang: str = 'en', trg_lang: str = 'de', vocab_size: int = 37000, d_model: int = 512, nhead: int = 8, num_encoder_layers: int = 6, num_decoder_layers: int = 8, dim_feedforward: int = 2048, dropout: float = 0.1, activation: str = 'relu', warmup: int = 4000, bpe_file: str = '../data/wmt14.en-de/share.bpe.37000', lenpen: float = 0.6, beam_size: int = 4, ckpt_steps: int = 1500): super().__init__() self.src_lang = src_lang self.trg_lang = trg_lang self.vocab_size = vocab_size self.d_model = d_model self.nhead = nhead self.num_encoder_layers = num_encoder_layers self.num_decoder_layers = num_decoder_layers self.dim_feedforward = dim_feedforward self.dropout = dropout self.activation = activation self.warmup = warmup self.bpe_file = bpe_file self.lenpen = lenpen self.beam_size = beam_size self.ckpt_steps = ckpt_steps self.model = model.Transformer( vocab_size=self.vocab_size, d_model=self.d_model, nhead=self.nhead, num_encoder_layers=self.num_encoder_layers, num_decoder_layers=self.num_decoder_layers, dim_feedforward=self.dim_feedforward, dropout=self.dropout, activation=self.activation, ) self.train_acc = pl.metrics.Accuracy() self.val_acc = pl.metrics.Accuracy() self.search = search.Search(self.model, lenpen=self.lenpen)
def __init__(self, parent): super(QWidget, self).__init__(parent) self.layout = QVBoxLayout(self) #Initializing tab screen self.tabs = QTabWidget() self.tab1 = contest.Contests(self) self.tab2 = search.Search(self) self.tab3 = notifier.Notifier(self, parent) self.tab4 = settings.Settings(self, parent) self.tabs.resize(1000, 700) #Adding tabs self.tabs.addTab(self.tab1, string_contests) self.tabs.addTab(self.tab2, string_search) self.tabs.addTab(self.tab3, string_notifications) self.tabs.addTab(self.tab4, string_settings) self.layout.addWidget(self.tabs) self.setLayout(self.layout)
def main(): n = 8 if len(sys.argv) == 2 and isSquareRoot(int(sys.argv[1]) + 1): n = int(sys.argv[1]) initMode = input( "\nWelcome to Bertie Woosters " + str(n) + "-puzzle solver.\n" + "Type '1' to use a default puzzle, or '2' to enter your own puzzle, or '3' to generate random puzzle.\n" ) print("----------------------------------------\n") p = puzzle.Puzzle(int(math.sqrt(n + 1))) if initMode == '1': p.deffault() elif initMode == '2': p.setPuzzle() elif initMode == '3': p.randomPuzzle() else: sys.exit(0) print("This is the puzzle:") p.showPuzzle() print("----------------------------------------") print( "\nEnter your choice of algorithm:\n 1. Uniform Cost Search.\n 2. A* with the Misplaced Tile heuristic.\n" " 3. A* with the Manhattan distance heuristic.") mode = input() print("----------------------------------------\n") s = search.Search(p) goal = s.run(mode) print("----------------------------------------\n") if goal is not None: print( "\n To solve this problem the search algorithm expanded a total of " + str(s.numOfNodes) + " nodes.") print( " The maximum number of nodes in the queue at any one time was " + str(s.maxQueueSize)) print(" The depth of the goal node was " + str(s.depth)) else: print("\n Can not find the goal!")
def next_state(self): if self.current_input == 0: return search.Search(self.next_input()) elif self.current_input == 5: return Release(self.next_input()) elif self.current_input == 6: return PrepareToCatch(self.next_input()) elif self.current_input == 8: return PrepareToCatch(self.next_input()) elif self.current_input == 9: return PrepareToCatch(self.next_input()) return Stop(self.next_input())
def search_entries(self): """Search all available entries based on user criterias.""" search_options = { "by date": ["date", "by_date"], "by time spent": ["time spent", "by_time_spent"], "exact": ["exact", "exact"], "regex": ["regex", "regex"] } search_engine = search.Search(self.log_connection.get_entries()) print(self.SEPARATOR, "Please select a method to search for entries.") for key, value in search_options.items(): print("Type {} to search using {}.".format(value[0], key)) search_selection = input("Selection:") if search_selection.lower() == "date": search_results = self._search_date(search_engine) if isinstance(search_results, list) and len(search_results) > 0: for each in search_results: print(each) else: print(search_results) elif search_selection.lower() == "time spent": search_results = self._search_time_spent(search_engine) if isinstance(search_results, list) and len(search_results) > 0: for each in search_results: print(each) else: print(search_results) elif search_selection.lower() == "exact": search_results = self._search_exact(search_engine) if isinstance(search_results, list) and len(search_results) > 0: for each in search_results: print(each) else: print(search_results) elif search_selection.lower() == "regex": search_results = self._search_regex(search_engine) if isinstance(search_results, list) and len(search_results) > 0: for each in search_results: print(each) else: print(search_results) else: print("That is not a valid selection.") self.search_entries()