I need to extract the source and destination terms from the text documents using text mining/NLP/Information Retrieval ?

ex :

  1. i am travelling from New York to London.
  2. i am heading towards playground from home.
  3. i will be going to Sweden from Boston.
  4. i was flying from School to Home.

the output can be as follows :

S. No. |  source    | Destination
------ |  ----------|------------
      1| New York   | London
      2| playground | home
      3| Sweden     | Boston
      4| School     | Home

1 Answer 1


To solve this problem, you need two things.

The first is an entity recognizer that detects terms in the text referencing locations. Since you have custom entities like "home", a standard named entity recognizer like Apache OpenNLP will most likely not be sufficient without retraining.

The second is a model that tells you which of the detected terms is the source and which the destination, e.g. isSource("home") = 0 and isDestination("home") = 1. You can try to train a classification model or a relation extraction model for this task on your own using labelled instances. But for a start I would recommend checking out MITIE, an information extraction library providing named entity recognition and binary relation extraction tools. Note that it also comes with an interactive model training tool.


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.