string-matching

android < 2.3 and java.text.Normalizer

安稳与你 提交于 2019-12-19 17:32:29
问题 What's the best alternative to to java.text.Normalizer in android versions previous than 2.3? http://developer.android.com/reference/java/text/Normalizer.html I need to match Strings like perché perchè perche thanks Nicola 回答1: I have two solutions: 1.) Get the source for Normalizer from here and here. (it's a few thousand lines) 2.) Build a simple translation HashMap yourself. Maybe your will have just French users for some time? This is a suboptimal solution but practical until your app

android < 2.3 and java.text.Normalizer

荒凉一梦 提交于 2019-12-19 17:31:04
问题 What's the best alternative to to java.text.Normalizer in android versions previous than 2.3? http://developer.android.com/reference/java/text/Normalizer.html I need to match Strings like perché perchè perche thanks Nicola 回答1: I have two solutions: 1.) Get the source for Normalizer from here and here. (it's a few thousand lines) 2.) Build a simple translation HashMap yourself. Maybe your will have just French users for some time? This is a suboptimal solution but practical until your app

Good algorithm for matching names?

好久不见. 提交于 2019-12-19 10:07:46
问题 I'm developing an app for mobile phones that syncs the contacts with the facebook account. So basically I have a list of my contacts names and a list of my facebook friends and I want to get the best possible matching between the two lists. Of course i can write something basic myself, but maybe there is a known algorithm out there that gets really good results. What do you think? 回答1: Maybe you can try Levenshtein distance 回答2: Soundex 回答3: You might find the results the MITRE name matching

Check substring match of a word in a list of words

安稳与你 提交于 2019-12-19 04:08:17
问题 I want to check if a word is in a list of words. word = "with" word_list = ["without", "bla", "foo", "bar"] I tried if word in set(list) , but it is not yielding the wanted result due to the fact in is matching string rather than item. That is to say, "with" is a match in any of the words in the word_list but still if "with" in set(list) will say True . What is a simpler way for doing this check than manually iterate over the list ? 回答1: You could do: found = any(word in item for item in

Algorithm to match one input file with given numbers of file

时光怂恿深爱的人放手 提交于 2019-12-19 02:39:31
问题 I had an interview last week. I was stuck in one of the question in algorithm round. I answered that question, but the interviewer did not seem convinced. That's why I am sharing the same. Please tell me any optimized method for this question, so that it will help me in future interviews. Question :- There are 20 text files given, all files are ASCII text files, having size less than 10^9 bytes. There is one input also given, this is also one ASCII file , say, input.txt. Our task is to

Create a unique ID by fuzzy matching of names (via agrep using R)

本秂侑毒 提交于 2019-12-18 13:17:23
问题 Using R, I am trying match on people's names in a dataset structured by year and city. Due to some spelling mistakes, exact matching is not possible, so I am trying to use agrep() to fuzzy match names. A sample chunk of the dataset is structured as follows: df <- data.frame(matrix( c("1200013","1200013","1200013","1200013","1200013","1200013","1200013","1200013", "1996","1996","1996","1996","2000","2000","2004","2004","AGUSTINHO FORTUNATO FILHO","ANTONIO PEREIRA NETO","FERNANDO JOSE DA COSTA"

Delete duplicate strings in string array

我的梦境 提交于 2019-12-18 12:12:54
问题 I am making a program based on string processing in Java in which I need to remove duplicate strings from a string array. In this program, the size of all strings are same. The 'array' which is a string array contains a number of strings in which two strings resemble each other. So using the below code the duplicate string must get removed but it is not removed. How to remove the duplicate strings? I am using the following code. for(int s=0;s<array.length-1;s++) { for(int m=0;m<array.length;m

XPath partial of attribute known

ⅰ亾dé卋堺 提交于 2019-12-18 11:53:39
问题 I know the partial value of an attribute in a document, but not the whole thing. Is there a character I can use to represent any value? For example, a value of a label for an input is "A. Choice 1". I know it says "Choice 1", but not whether it will say "A. " or "B. " before the "Choice 1". Below is the relevant HTML. There are other attributes for the input and the label, but they are not the same every time the page is rendered, so I can't use them as references: <tr> <td><input type=

Removing an item from list matching a substring

我的未来我决定 提交于 2019-12-18 11:05:54
问题 How do I remove an element from a list if it matches a substring? I have tried removing an element from a list using the pop() and enumerate method but seems like I'm missing a few contiguous items that needs to be removed: sents = ['@$\tthis sentences needs to be removed', 'this doesnt', '@$\tthis sentences also needs to be removed', '@$\tthis sentences must be removed', 'this shouldnt', '# this needs to be removed', 'this isnt', '# this must', 'this musnt'] for i, j in enumerate(sents): if

How to replace all matching characters except the first occurrence

ⅰ亾dé卋堺 提交于 2019-12-17 21:28:15
问题 I am trying to use regex to compare a string in JavaScript. I want to replace all '.'s and '%'s with empty character '' but the catch is I don't want to replace the first occurrence of '.' . value.replace(/\%\./g, ''); Expected result like below: .4.5.6.7. ==> .4567 4.5667.444... ==> 4.56667444 ..3445.4 ==> .34454 回答1: You can pass in a function to replace , and skip the first match like this: var i = 0; value.replace(/[\.\%]/g, function(match) { return match === "." ? (i++ === 0 ? '.' : '')