Consider forum posts or any text where we'd be interested in finding out related words, given the data. What would be a solution for creating a topic cluster based on this data? E.g. We are interested in finding a pre-determined topic "Tools" (e.g. Wrench, Screwdriver, ...) with the least possible effort. Is there any software/method available?

I understand a simple term frequency solution will go a long way (find out which words occur relatively often in the topic compared to how often the word occurs outside of documents).

Note that this is really a different problem than saying "we are trying to find 5 clusters based on LDA" or "let's classify these documents into 5 as distinct as possible clusters".

Is there any way not to have to come up with the "tools" ourselves?

I was thinking perhaps something semi automatic like:

  • Start with 1 object belonging to the topic "Tools" (e.g. "Wrench")
  • Sort all unique words for all documents containing the word wrench based on how often they occur in the documents in comparison with how often they occur in the whole corpus (these words might potentially be Tools)
  • Take the first X (magic number) unique words and
  • for these also consider newly "potential" documents, and reconsider which words might be belong to Tools

However, a severe limitation would be the fact that a story that might mention the word Wrench, will most likely not mention Screwdriver. So you definitely need a second step, where the words strongly correlating with Wrench might now be used instead to discover Screwdriver (if it would not stand out next to Wrench in documents)

Any ideas?

  • $\begingroup$ To be sure: You are trying to find sets of posts given a topic, instead of topics given a set of posts, right? $\endgroup$
    – fnl
    Commented Mar 2, 2015 at 12:05
  • $\begingroup$ And another question: given your comments and because you tagged this "clustering," you are looking for an unsupervised approach, right? Or do you have (training) documents tagged with/grouped by your topic(s) already? $\endgroup$
    – fnl
    Commented Mar 2, 2015 at 12:10
  • 1
    $\begingroup$ I don't have anything tagged. I'm simply interested in the case where we have documents, and I'd like to build the topic "Tools". I'm willing to guide it a bit by defining a few examples myself (such as Wrench, Screwdriver, as to increase accuracy), but after that I would like it to give me words most likely belonging to the topic. I notice that most automatic methods do not allow for any direction of a topic. Without stopwords (and even usually with stopwords), clustering does not give me the topics I seek, but often something completely useless. $\endgroup$ Commented Mar 2, 2015 at 12:56
  • $\begingroup$ Would something like word2vec help you get the other related word? You can start with a manually created set of words relating to your topic and use word2vec to get other such words. Then you can use this to see how much each document relates to your chosen topic. $\endgroup$ Commented Apr 18, 2017 at 14:48
  • $\begingroup$ Word embeddings (e.g., word2vec) based on skip-grams might indeed be useful in this regard. Skip-gram word embedding vectors should be more similar for words which occur in similar contexts ("context" usually refers to a fixed-size window around the target word). Pre-trained embeddings are popular, but you could train your own if your imagined corpus is very specific; you might find it useful to use a smaller vector size and larger context window than pre-trained embeddings. You could then build clusters by starting with a few example words and adding words with low distance to these vectors. $\endgroup$
    – Ben
    Commented Jul 30, 2017 at 0:55

3 Answers 3


One possible approach is PU learning, where PU means Positive-Undefined. You search for texts which contains words like "wrench" and "screwdriver", manually check which of them are indeed about tools, and now you have some texts which are about tools (Positive set) and a lot of unlabeled texts (Undefined set). The problem of building a classifier in such circumstances is called PU learning.

Another possible approach is called Interactive Machine Learning. I am not sure if it is appliable here, but it is worth checking.


I have tried to extract similar common real world knowledge categories from Gutenberg Project with LDA, and -- as you insightfully observe -- the result was furthest from a neat discovery of real world categories.

I turned to lexical and semantic ontologies to pursue my own project and it proved very helpful. Since your main concern -- I guess -- is to have the knowledge available for practical applications, and their discovery is not your primary purpose, you can possible use the encoding that has already gone into these ontologies. (Again, if I have understood the purpose correctly...)

For example, regarding 'Tools', if you submit a vector of 'Tool' lemmas as seed words in Wordnet, and write a function to find their hypernyms and then each hypernym's hyponyms (co-hyponyms), you will end up with much more 'Tools' than you started with.

Thus you can programmatically populate a small ontology for your needs in a relatively short time, definitely faster and more fun than encoding the categories manually. There are packages that integrate Wordnet with R and Python, and perhaps other languages, but these are the ones I know of, so perhaps you can easily adapt this approach to your workflow.


For your case, that is, an unsupervised problem, you could be using an approach known as query expansion, with your particular problem usually being referred to as Information Filtering. The idea is to let a system analyze the documents you want to work with, learn the usage of terms, and then, for a given query term, use that knowledge to "expand" the query with synonyms and related terms.

One possibility to do that is using Latent Semantic Indexing (LSI) on all (untagged) posts you have to identify/group synonymous and polysemous terms. Then assemble collections of terms for a topic of interest starting with a relevant term (such as the "tools" you describe) to assemble an "exanded query" for all documents with any of those terms and tag them with that topic using the similarity matrix LSI gave you.

A simpler way is to rank terms as found in the documents from in your initial query ("tools") against the posts or an independent set of documents (WikiPedia?) and use the highest ranked terms as your candidates, as described here.

  • $\begingroup$ Let me know what your case is and if or how I can help you understand the solution I present here better. $\endgroup$
    – fnl
    Commented Mar 2, 2015 at 12:19
  • $\begingroup$ It is indeed unsupervised. I just wish to obtain Tools with all the data-driven tools belonging to Tools. I might help it by introducing Wrench and Screwdriver, but from there on I would like to find an optimal Tools set. $\endgroup$ Commented Mar 2, 2015 at 12:54
  • 1
    $\begingroup$ Yes, right, as I thought. What you are looking for then are called "query expansion techniques". By scoring your words with an LSI you can find words similar to each other. $\endgroup$
    – fnl
    Commented Mar 2, 2015 at 16:16
  • $\begingroup$ How many texts do you have? What is their length? $\endgroup$
    – user31264
    Commented May 14, 2016 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.