Ranking tweets from most relevant to least relevant in a document using Python
<p>I have a document with, say, 15 tweets. Given a query, how can we rank the tweets from most relevant to the query to least relevant?</p>

<p>That is, let D be the document containing 15 tweets:</p>

<pre><code>D = ['Tweet 1', 'Tweet 2' ..... 'Tweet 15']
Q = "some noun phrase"
</code></pre>

<p>Given Q, what method we can use for ranking the tweets from most relevant to least relevant?</p>

<p>All tweets are similar and belong to the same topic.
Can I use <a href="https://en.wikipedia.org/wiki/Tf%E2%80%93idf" rel="nofollow">tf-idf</a> (it's a bad idea, I think), topic modelling?</p>

<p>Yoe need <a href="http://www.nltk.org&quot;" rel="nofollow">nltk</a> (Natural Language Toolkit) libery. There is built-in function which count tf-idf</p>

python python-2.7 tf-idf topic-modeling