Regular Expression to get only words from file starting with letter and removing words with only numbers and punctuation in python
<p>I have a text file which i am reading in python through nltk functions.
I need to get only only words from file starting with letter and removing words with only numbers and punctuation.
For ex :-</p>

<pre><code>['Osteama pranay@123  123 !']
</code></pre>

<p>so the desired output is</p>

<pre><code>Osteama pranay@123
</code></pre>

<p>Please suggest a regular expression for this</p>

<p>To use regular expression you need to >>>import re first</p>

<pre><code>import nltk,re,pprint
from __future__ import division
from nltk import word_tokenize

def openbook(self,book):
    file = open(book)
    raw = file.read()
    tokens = nltk.wordpunct_tokenize(raw)
    text = nltk.Text(tokens)
    words = [w.lower() for w in text]
    vocab = sorted(set(words))
    return vocab
if __name__ == "__main__":
    import sys
    openbook(file(sys.argv[1]))
</code></pre>

<p>It might help you</p>

python regex nltk regex-negation