search

Termination Criteria for Bidirectional Search

有些话、适合烂在心里 提交于 2019-12-17 16:16:11
问题 According to most of the reading I have done, a bidirectional search algorithm is said to terminate when the "forward" and "backward" frontiers first intersect. However, in Section 3.4.6 of Artificial Intelligence: A Modern Approach , Russel and Norvig state: Bidirectional search is implemented by replacing the goal test with a check to see whether the frontiers of the two searches intersect; if they do, a solution has been found. It is important to realize that the first solution found may

Algorithm for multiple word matching in text

五迷三道 提交于 2019-12-17 16:13:13
问题 I have a large set of words (about 10,000) and I need to find if any of those words appear in a given block of text. Is there a faster algorithm than doing a simple text search for each of the words in the block of text? 回答1: input the 10,000 words into a hashtable then check each of the words in the block of text if its hash has an entry. Faster though I don't know, just another method (would depend on how many words you are searching for). simple perl examp: my $word_block = "the guy went

Search spreadsheet by column, return rows

旧街凉风 提交于 2019-12-17 15:36:44
问题 I'm trying to find the best script in terms of runtime to complete a task. I've got a decently large spreadsheet where I need to check values in certain known columns, and depending on a match case it returns that row. Ideally I'd like a new spreadsheet containing the returned rows. I've got the spreadsheet opened by ID and I've got the sheet & range, but not sure the most efficient way to search through the specific columns and grabbing not just that value but the entire row. 回答1: You can

A range intersection algorithm better than O(n)?

扶醉桌前 提交于 2019-12-17 15:29:01
问题 Range intersection is a simple, but non-trivial problem. Its has been answered twice already: Find number range intersection Comparing date ranges The first solutions is O(n) and the second solution is for a database (which is less than O(n) of course). I have the same problem, but for a large n and I am not within a database. This problem seems to be very similar to Store 2D points for quick retrieval of those inside a rectangle but I don't see how it maps. So what data structure would you

grep, but only certain file extensions

耗尽温柔 提交于 2019-12-17 15:00:36
问题 I am working on writing some scripts to grep certain directories, but these directories contain all sorts of file types. I want to grep just .h and .cpp for now, but maybe a few others in the future. So far I have: { grep -r -i CP_Image ~/path1/; grep -r -i CP_Image ~/path2/; grep -r -i CP_Image ~/path3/; grep -r -i CP_Image ~/path4/; grep -r -i CP_Image ~/path5/;} | mailx -s GREP email@domain.com Can anyone show me how I would now add just the specific file extensions? 回答1: Just use the -

Using named parameters with PDO for LIKE

廉价感情. 提交于 2019-12-17 12:15:14
问题 I am trying to search the name field in my database using LIKE . If I craft the SQL 'by hand` like this: $query = "SELECT * \n" . "FROM `help_article` \n" . "WHERE `name` LIKE '%how%'\n" . ""; $sql = $db->prepare($query); $sql->setFetchMode(PDO::FETCH_ASSOC); $sql->execute(); Then it will return relevant results for 'how'. However, when I turn it into a prepared statement: $query = "SELECT * \n" . "FROM `help_article` \n" . "WHERE `name` LIKE '%:term%'\n" . ""; $sql->execute(array(":term" =>

Numpy: For every element in one array, find the index in another array

帅比萌擦擦* 提交于 2019-12-17 10:36:13
问题 I have two 1D arrays, x & y, one smaller than the other. I'm trying to find the index of every element of y in x. I've found two naive ways to do this, the first is slow, and the second memory-intensive. The slow way indices= [] for iy in y: indices += np.where(x==iy)[0][0] The memory hog xe = np.outer([1,]*len(x), y) ye = np.outer(x, [1,]*len(y)) junk, indices = np.where(np.equal(xe, ye)) Is there a faster way or less memory intensive approach? Ideally the search would take advantage of the

A* heuristic, overestimation/underestimation?

前提是你 提交于 2019-12-17 10:33:16
问题 I am confused about the terms overestimation/underestimation. I perfectly get how A* algorithm works, but i am unsure of the effects of having a heuristic that overestimate or underestimate. Is overestimation when you take the square of the direct birdview-line? And why would it make the algorithm incorrect? The same heuristic is used for all nodes. Is underestimation when you take the squareroot of the direct birdview-line? And why is the algorithm still correct? I can't find an article

grep for special characters in Unix

自古美人都是妖i 提交于 2019-12-17 10:13:18
问题 I have a log file (application.log) which might contain the following string of normal & special characters on multiple lines: *^%Q&$*&^@$&*!^@$*&^&^*&^& I want to search for the line number(s) which contains this special character string. grep '*^%Q&$*&^@$&*!^@$*&^&^*&^&' application.log The above command doesn't return any results. What would be the correct syntax to get the line numbers? 回答1: Tell grep to treat your input as fixed string using -F option. grep -F '*^%Q&$*&^@$&*!^@$*&^&^*&^&

android search dialog customization

让人想犯罪 __ 提交于 2019-12-17 10:03:00
问题 After several searches I couldn't figure out how to customize the search dialog (the top search bar that appears when you click the search button). I want to change the background color of the search bar. I got articles on how to customize a title bar. But that doesn't work for search bar. Any helpful pointers please... 回答1: It seems that it's not customizable: https://groups.google.com/forum/?fromgroups=#!topic/android-developers/ZqZ-KZPLGtk 来源: https://stackoverflow.com/questions/13936674