+ 1

about string matching: I want to match 2 strings and output should be true if any portion of the strings are matched.

i have a two input string str1 = nsubjpass(intended-3, It-1) auxpass(intended-3, was-2) root(ROOT-0, intended-3) mark(allow-5, to-4) xcomp(intended-3, allow-5) amod(code-7, existing-6) str2 = nsubjpass(intended-3, It-1) auxpass(intended-3, is-2) root(ROOT-0, intended-3) mark(help-5, to-4) xcomp(intended-3, help-5) compound(code-8, reuse-6) and output should be Exact matching or (100%) matching is nsubjpass(intended-3, It-1) root(ROOT-0, intended-3) 75% matching is [ auxpass(intended-3, is-2) auxpass(intended-3, is-2)] [ mark(help-5, to-4), mark(help-5, to-4)] ...... And so on Ignore the numbers. please, any one helps me.

29th Sep 2017, 12:43 AM
Shikha Pandey
Shikha Pandey - avatar
6 odpowiedzi
+ 1
Thank you so much Mr Jurgen Mueller sir. your response is really helpful for my research. thanks a lot.
8th Oct 2017, 10:57 AM
Shikha Pandey
Shikha Pandey - avatar
+ 1
Dear Shikha, Thank you for your kind words, but I am a little dissapointed; Sololearn is for learning and practicing programming. That is why I helped you out. So you can learn from it. Sololearn is not for getting codes for free. You can put your request at other places to get things done , like Fiverr. If you do the free python course at Sololearn (there are more free courses at the internet, if needed) and you examine the code, you can do it yourself. Good luck.
9th Oct 2017, 10:05 AM
Jurgen Mueller
Jurgen Mueller - avatar
0
Regex will be useful, then store the parts in lists, then compare on string level, word level, character level? Add a few counters, calculate and display.
3rd Oct 2017, 11:48 PM
Jurgen Mueller
Jurgen Mueller - avatar
0
No, I was wrong. Maybe you have to change the way of giving the answer. A little homework then. You have to install the fuzzywuzzy module in python with pip or easyinstall before. This should do the trick: from fuzzywuzzy import process def str_list(string): l_str_t = string.split(" ") l_str = [] brac = False for i in l_str_t: if ("(" in i) and not(")" in i) : brac = True elif (")" in i) and (brac==True): l_str.append(l_str_t[l_str_t.index(i)-1] +" "+ i) brac = False else: brac = False return l_str str1 = str(input("Enter the first string:")) str2 = str(input("Enter the second string::")) l_str1 = str_list(str1) l_str2 = str_list(str2) print("For comparing the first string to the second string.\ These are the results:") for i in l_str1: print(i) print(process.extract(i, l_str2)) print()
5th Oct 2017, 5:28 PM
Jurgen Mueller
Jurgen Mueller - avatar
0
Ok. I will stop editing now. I improved the output. Although if you are going to process the result with more programming is not useful.. from fuzzywuzzy import process def str_list(string): l_str_t = string.split(" ") l_str = [] brac = False for i in l_str_t: if ("(" in i) and not(")" in i) : brac = True elif (")" in i) and (brac==True): l_str.append(l_str_t[l_str_t.index(i)-1] +" "+ i) brac = False else: brac = False return l_str str1 = str(input("Enter the first string:")) str2 = str(input("Enter the second string::")) l_str1 = str_list(str1) l_str2 = str_list(str2) print("These parts fits the most with each other.") print("perc\tpart of first string\t\tpart of second string") for i in l_str1: result = process.extract(i, l_str2) print("{0}\t{1}\t{2}".format(result[0][1], i, result[0][0]))
5th Oct 2017, 5:28 PM
Jurgen Mueller
Jurgen Mueller - avatar
0
Sir actually i want to compare parse dependence relationship of two sentences and try to find out their similarity in percentage. i will be very thankful if u send me this code to my mail id. shikhamtech2008@gmail.com
8th Oct 2017, 12:06 PM
Shikha Pandey
Shikha Pandey - avatar