How to iterate through sentence of string in Python?
<p>Assume I have string <code>text = "A compiler translates code from a source language"</code></p>

<p>I need to iterate through each word and stem using NLTK library.</p>

<p>Function for stemming is <code>PorterStemmer().stem_word(word)</code>. We have to pass the 'word'</p>

<p>So, how can i stem each word and get stemmed sentence back ?</p>

<p><strong>EDIT -</strong></p>

<p>Also i need to remove stop words from that <code>text</code> string. List of Stopwords stored in text file (space separated)</p>

<pre><code>stopwordsfile = open('c:/stopwordlist.txt','r+')
stopwordslist=stopwordsfile.read()
</code></pre>

<p>How can i remove those stop words from <code>text</code> and get cleaned new string.</p>
