Question

I have two strings -

"I like running around the track.

I like swimming in the pool, but only in the morning.

I need to pull out what people "like" from the above two comments (running around the track and swimming in the pool.

Does anyone have a recommendation for a text analytics gem or other method of pulling in that kind of information? I don't necessarily need word counts or n-grams, I just want to know what words are seen in relation to the word "like".

Was it helpful?

Solution

For a quick-and-dirty fix, you could use a Regex to search for all the forms of "like" and pull out all the text between there and the punctuation mark or Newline character.

OTHER TIPS

You could use a dependency parser such as The Stanford Parser to parse your text and find the keys words in your sentiment dictionary, and probably put some constraints on the type of dependencies for disambiguation. For example, the dependency needs to be of type "dobj" (direct object). Then follow the dependency structures to the end of phrase or sentence depending on your needs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top