Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto-tag content, algorithms and suggestions needed

Tags:

tags

nlp

tagging

I am working with some really large databases of newspaper articles, I have them in a MySQL database, and I can query them all.

I am now searching for ways to help me tag these articles with somewhat descriptive tags.

All these articles is accessible from a URL that looks like this:

http://web.site/CATEGORY/this-is-the-title-slug 

So at least I can use the category to figure what type of content that we are working with. However, I also want to tag based on the article-text.

My initial approach was doing this:

  1. Get all articles
  2. Get all words, remove all punctuation, split by space, and count them by occurrence
  3. Analyze them, and filter common non-descriptive words out like "them", "I", "this", "these", "their" etc.
  4. When all the common words was filtered out, the only thing left is words that is tag-worthy.

But this turned out to be a rather manual task, and not a very pretty or helpful approach.

This also suffered from the problem of words or names that are split by space, for example if 1.000 articles contains the name "John Doe", and 1.000 articles contains the name of "John Hanson", I would only get the word "John" out of it, not his first name, and last name.

like image 455
Kasper Grubbe Avatar asked May 18 '11 02:05

Kasper Grubbe


People also ask

Is auto-tagging artificial intelligence?

AI auto-tagging is the process in which artificial intelligence is used to tag media files with metadata. This is a modern approach to metadata tagging, which creates a term that describes a keyword or phrase and assigns these metadata tags to a media asset.

What is tag recommendation?

Tag recommendation refers to the automated process of suggesting useful and. informative tags to an emerging object based on historical information. An example. of the recommendation by the Del.icio.us system is shown in Figure 2, where the. user is bookmarking a webpage regarding data mapper and the system recommends.

What is content tagging?

A content tag is a term or keyword attached to web content that identifies characteristics of the content.


2 Answers

Automatically tagging articles is really a research problem and you can spend a lot of time re-inventing the wheel when others have already done much of the work. I'd advise using one of the existing natural language processing toolkits like NLTK.

To get started, I would suggest looking at implementing a proper Tokeniser (much better than splitting by whitespace), and then take a look at Chunking and Stemming algorithms.

You might also want to count frequencies for n-grams, i.e. a sequences of words, instead of individual words. This would take care of "words split by a space". Toolkits like NLTK have functions in-built for this.

Finally, as you iteratively improve your algorithm, you might want to train on a random subset of the database and then try how the algorithm tags the remaining set of articles to see how well it works.

like image 66
Anupam Jain Avatar answered Sep 27 '22 23:09

Anupam Jain


You should use a metric such as tf-idf to get the tags out:

  1. Count the frequency of each term per document. This is the term frequency, tf(t, D). The more often a term occurs in the document D, the more important it is for D.
  2. Count, per term, the number of documents the term appears in. This is the document frequency, df(t). The higher df, the less the term discriminates among your documents and the less interesting it is.
  3. Divide tf by the log of df: tfidf(t, D) = tf(t, D) / log(df(D) + 1).
  4. For each document, declare the top k terms by their tf-idf score to be the tags for that document.

Various implementations of tf-idf are available; for Java and .NET, there's Lucene, for Python there's scikits.learn.

If you want to do better than this, use language models. That requires some knowledge of probability theory.

like image 39
Fred Foo Avatar answered Sep 27 '22 23:09

Fred Foo