tag generation from a small text content (such as tweets)
Asked Answered
S

2

17

I have already asked a similar question earlier but I have notcied that I have big constrain: I am working on small text sets suchs as user Tweets to generate tags(keywords).

And it seems like the accepted suggestion ( point-wise mutual information algorithm) is meant to work on bigger documents.

With this constrain(working on small set of texts), how can I generate tags ?

Regards

Sabrasabre answered 4/5, 2010 at 9:20 Comment(2)
In other words, you want to classify tweets into X number of categories?Proletarian
that can also work, aswell as extracting keywords from them.Sabrasabre
L
17

Two Stage Approach for Multiword Tags

You could pool all the tweets into a single larger document and then extract the n most interesting collocations from the whole collection of tweets. You could then go back and tag each tweet with the collocations that occur in it. Using this approach, n would be the total number of multiword tags that would be generated for the whole dataset.

For the first stage, you could use the NLTK code posted here. The second stage could be accomplished with just a simple for loop over all the tweets. However, if speed is a concern, you could use pylucene to quickly find the tweets that contain each collocation.

Tweet Level PMI for Single Word Tags

As also suggested here, For single word tags, you could calculate the point-wise mutual information of each individual word and the tweet itself, i.e.

PMI(term, tweet) = log [ P(term, tweet) / (P(term)*P(tweet)) 

Again, this will roughly tell you how much less (or more) surprised you are to come across the term in the specific document as appose to coming across it in the larger collection. You could then tag the tweet with a few terms that have the highest PMI with the tweet.

General Changes for Tweets

Some changes you might want to make when tagging with tweets include:

  • Only use a word or collocation as a tag for a tweet, if it occurs within a certain number or percentage of other tweets. Otherwise, PMI will tend to tag tweets with odd terms that occur in just one tweet but that are not seen anywhere else, e.g. misspellings and keyboard noise like #@$#@$%!.

  • Scale the number of tags used with the length of each tweet. You might be able to extract 2 or 3 interesting tags for longer tweets. But, for a shorter 2 word tweet, you probably don't want to use every single word and collocation to tag it. It's probably worth experimenting with different cut-offs for how many tags you want to extract given the tweet length.

Lobo answered 4/5, 2010 at 19:45 Comment(1)
n the reply above, my question is Let's assume that if term only appear once in every tweet and there is no retweet, will p(term, tweet) = 1 p(tweet) = 1 and the measurement will simply become the log(1/p(term)) ? Regards, Andy.Lacerta
S
0

I have used a method earlier, for small text content such as SMSes, where I would just repeat the same line two times. Surprisingly, that works well for such content where a noun could well be the topic. I mean, you don't need it to repeat for it to be the topic.

Servomechanism answered 28/7, 2012 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.