title: Extract relationships from a sentence in NLTK
body: <p>I am using NLTK to extract the relationship between a PERSON and an ORGANIZATION.</p>
  
  <p>Also, I want to extract the relationship between ORGANIZATION and LOCATION.
  The NLTK version is 3.2.1.</p>
  
  <p>I've made use of Part-Of-Speech tagging and Named Entity Recognition (NER). Also the Parse Tree is drawn for the NER results.<br>
  But I am not able to extract the mentioned relationships from that sentence.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import nltk, re
  from nltk import word_tokenize
  
  sentence = "Mark works at JPMC in London every day"
  pos_tags = nltk.pos_tag(word_tokenize(sentence))            # POS tagging of the sentence
  ne = nltk.ne_chunk(pos_tags)                                # Named Entity Recognition
  ne.draw()                                                   # Draw the Parse Tree
  
  IN = re.compile(r'.*\bin\b(?!\b.+ing)')
  for rel1 in nltk.sem.extract_rels('PER', 'ORG', pos_tags, pattern = IN):
      print(nltk.sem.rtuple(rel1))
  for rel2 in nltk.sem.extract_rels('ORG', 'LOC', pos_tags, pattern = IN):
      print(nltk.sem.rtuple(rel2))
  </code></pre>
  
  <p><br>
  <strong>How to extract <em>'Person - Organization'</em> relationship and <em>'Organization - Location'</em> relationship?</strong></p>