filter two keywords at the same time #1335
-
Hi all, I use tweepy stream filter api, I want to find a tweet with two keywords at the same time, the sentence, "we like to paly the basketball" with two keywords "like" and "basketball". I find tried tweepy, it only supports "like basketball", can anyone give some suggestions. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You should be able to do this by setting the terms as a single phrase in the track parameter, separated only by whitespace. You can consider whitespace a logical AND, so it doesn't take into account ordering. For example
should find a sentence such as "we like to play the basketball" as both "like" AND "basketball" are in it. Similarly, it would find a sentence like "basketball is fun and I like to play it". But it won't find a sentence with only 1 of the terms, for example "I've never played basketball". You can find documentation on stream parameters and how to use them in the Twitter dev docs here (6. Track): |
Beta Was this translation helpful? Give feedback.
-
@GenericSnake Thanks. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
You should be able to do this by setting the terms as a single phrase in the track parameter, separated only by whitespace. You can consider whitespace a logical AND, so it doesn't take into account ordering. For example
myStream.filter(track=['like basketball'])
should find a sentence such as "we like to play the basketball" as both "like" AND "basketball" are in it. Similarly, it would find a sentence like "basketball is fun and I like to play it". But it won't find a sentence with only 1 of the terms, for example "I've never played basketball".
You can find documentation on stream parameters and how to use them in the Twitter dev docs here (6. Track):
https://developer.twitter.com/en/d…