Extracting specific information from data
<p>How can i convert a data format like: </p>

<pre><code>James Smith was born on November 17, 1948
</code></pre>

<p>into something like </p>

<pre><code>("James Smith", DOB, "November 17, 1948")
</code></pre>

<p>without having to rely on positional index of strings</p>

<p>I have tried the following </p>

<pre><code>from nltk import word_tokenize, pos_tag

new = "James Smith was born on November 17, 1948"
sentences = word_tokenize(new)
sentences = pos_tag(sentences)
grammar = "Chunk: {&lt;NNP*&gt;&lt;NNP*&gt;}"
cp = nltk.RegexpParser(grammar)
result = cp.parse(sentences)
print(result)
</code></pre>

<p>How to proceed further to get the output in desired fromat.</p>

<p>Split the string with 'was born on' after that trim the spaces and assign to name and dob</p>

python python-3.x nltk stanford-nlp information-retrieval