Jul-05-2018, 07:26 AM
(This post was last modified: Jul-05-2018, 08:18 AM by PierreSoulier.)
Thank you for the answer :) I think i get your idea.
However result_details is a tuple composed with string of word, each word separated with ' ' (space).
So i don't really understand what you are trying to do on line 5?
Thank you for taking your time to answer :)!
I've tried something like that based on your program:
I've updated the MC list with very common words as 'le','la','et' etc... but i still get matches=[]
However result_details is a tuple composed with string of word, each word separated with ' ' (space).
So i don't really understand what you are trying to do on line 5?
Thank you for taking your time to answer :)!
I've tried something like that based on your program:
for text in result_details: # If not already a list: delimiter = ' ' text=''.join(text) #from tuple to string data_list = text.strip().split(delimiter) most_common_list = Counter(data_list).most_common(5) mc_dict = dict((x, y) for x, y in most_common_list) print(mc_dict) matches = [] for idx, word in enumerate(MC): try: count = mc_dict[word] matches.append(result_id[idx], word, count) except: continue print(matches)But this is what i get in return:
{'le': 3, '(jazz': 1, 'de': 6, '\xc3\xa0': 2, 'samedi': 2} [] {'vent': 1, '8h': 1, 'de': 4, 'Le': 1, 'plein': 1} [] {':': 19, 'Prix': 20, 'du': 12, 'de': 33, '-': 13} [] {'ville': 1, 'de': 2, ':': 5, 'pour': 2, 'la': 2} [] {'12h': 1, 'et': 3, 'de': 3, 'sur': 3, '\xc3\xa0': 2} [] {'\xc3\xa0': 3, 'et': 3, 'de': 6, 'pour': 3, 'les': 5} [] {'et': 4, 'de': 6, '\xc3\xa0': 7, 'du': 4, 'la': 7} [] {'tir\xc3\xa9': 1, 'port.': 1, 'Feu': 1, 'du': 1, "d'artifice": 1} [] {'': 1, 'et': 5, 'au': 2, '18': 2, 'la': 3} [] {'et': 2, 'des': 2, 'de': 7, 'le': 2, 'la': 2} [] {'60': 1, 'Loto': 1, 'des': 1, '56': 2, '06': 2} []So it seems like the first part is working great but it can't stock data in matches
I've updated the MC list with very common words as 'le','la','et' etc... but i still get matches=[]