NLTK relation extraction returns nothing
<p>I am recently working on using nltk to extract relation from text. so i build a sample text:" Tom is the cofounder of Microsoft." and using following program to test and return nothing. I cannot figure out why.</p>

<p>I'm using NLTK version: 3.2.1, python version: 3.5.2.</p>

<p>Here is my code:</p>

<pre><code>import re
import nltk
from nltk.sem.relextract import extract_rels, rtuple
from nltk.tokenize import sent_tokenize, word_tokenize


def test():
    with open('sample.txt', 'r') as f:
        sample = f.read()   # "Tom is the cofounder of Microsoft"

    sentences = sent_tokenize(sample)
    tokenized_sentences = [word_tokenize(sentence) for sentence in sentences]
    tagged_sentences = [nltk.tag.pos_tag(sentence) for sentence in tokenized_sentences]

    OF = re.compile(r'.*\bof\b.*')

    for i, sent in enumerate(tagged_sentences):
        sent = nltk.chunk.ne_chunk(sent) # ne_chunk method expects one tagged sentence
        rels = extract_rels('PER', 'GPE', sent, corpus='ace', pattern=OF, window=10) 
        for rel in rels:
            print('{0:&lt;5}{1}'.format(i, rtuple(rel)))

if __name__ == '__main__':
    test()
</code></pre>

<hr>

<h2>1.　After some debug, if found that when i changed the input as</h2>

<blockquote>
  <p>"Gates was born in Seattle, Washington on October 28, 1955. "</p>
</blockquote>

<h2>the nltk.chunk.ne_chunk() output is:</h2>

<blockquote>
  <p>(S
    (PERSON Gates/NNS)
    was/VBD
    born/VBN
    in/IN
    (GPE Seattle/NNP)
    ,/,
    (GPE Washington/NNP)
    on/IN
    October/NNP
    28/CD
    ,/,
    1955/CD
    ./.)</p>
</blockquote>

<h2>The test() returns:</h2>

<blockquote>
  <p>[PER: 'Gates/NNS'] 'was/VBD born/VBN in/IN' [GPE: 'Seattle/NNP']</p>
</blockquote>

<h2>2. After i changed the input as:</h2>

<blockquote>
  <p>"Gates was born in Seattle on October 28, 1955. "</p>
</blockquote>

<p>The test() retuns nothing.</p>

<h2>3. I digged into <strong>nltk/sem/relextract.py</strong> and find this strange</h2>

<p>output is caused by function:
<strong>semi_rel2reldict(pairs, window=5, trace=False), which returns result only when len(pairs) > 2, and that's why when one sentence with less than three NEs will return None.</strong></p>

<p><strong>Is this a bug or i used NLTK in wrong way?</strong></p>