apitwittertwitter-search

Using Twitter's public API to find similar tweets


I am working on an application that amongst other things tries to find similar tweets based on a tweet's text as input. The similarity of the tweet would be based on the amount of matching text. I would like to use the public twitter search api to accomplish this.

The closest thing the twitter API offers is searching using OR operators. This however returns a list of seemingly randomly ordered tweets that contain any of the query's words, ussualy matching common words like 'with' or 'we' (which is expected behaviour of the OR operator). I however am interested in results with as much matching text as possible and also in results with text that is characteristic to the input tweet (matching common words is less relevant then matching uncommon words).

Is there any way I can use the twitter API to find results with as much matching words as possible?

Example of results from query with OR operators.


Solution

  • The Twitter REST API does not expose a function that does what you are describing. You will need to capture a large number of tweets (probably from the Streaming API and then do the comparisons/identifications of similar tweets in your own code.