I have two different lists and I need extract data from them according their name and then multiply them.
I have this lists:
query_tfidf = [0.8465735902799727, 0.8465735902799727]
documents_query = [['Aftonbladet', 'play', 0.0], ['Aftonbladet', 'free', 0.0],
['Radiosporten Play', 'play', 0.10769448286014331], ['Radiosporten Play', 'free', 0.0]]
And I need sort them according their name, for example:
{Aftonbladet: {play: 0.0, free: 0.0}, Radiosporten Play: {play: 0.10769448286014331, free: 0.0}
Then I need to extract data from each and multiply with query_tfidf and compute two variables. For example:
for each name:
dot_product = (play_value * query_tfidf[0]) + (free_value * query_tfidf[1])
query = sqrt((query_tfidf[0])^2 + (query_tfidf[1])^2)
document = sqrt((play_value)^2 + (free_value)^2)
I'm a little bit desperate so I want to ask here. I'm using python 2.7.
documents_queryalways going to come in ordered nicely like that?[key1, 'play', val], [key1, 'free', val], [key2, 'play, val], ...?