Scala beginner here, I'm trying to find all the tweets text that contain at least one keyword in the list of keywords given.
Where a tweet:
case class Tweet(user: String, text: String, retweets: Int)
With an example Tweet("user1", "apple apple", 3)
Given that wordInTweet should return true if at least one keyword in the list keywords can be found in the tweet's text.
I tried implementing it like the following:
def wordInTweet(tweet: Tweet, keywords: List[String]): Boolean = {
keywords.exists(tweet.text.equals(_))
}
But, it also returns true if a tweet's text is music and a given keyword's text is musica.
I'm struggling to find a way to return true ONLY if the tweets contains the exact same keyword's text.
How can I achieve this?
Thanks in advance.
scala> "my tweet".sliding("my".size).toList res2: List[String] = List(my, "y ", " t", tw, we, ee, et)