title: python: count word tokens in sentence
body: <p>I'm trying to count the number of words in a string. however, i first have to strip some punctuations e.g.</p>
  
  <pre><code>line = "i want you , to know , my name . "
  </code></pre>
  
  <p>running</p>
  
  <pre><code>en = line.translate(string.maketrans('', ''), '!,.?')
  </code></pre>
  
  <p>produces</p>
  
  <pre><code>en = "i want you  to know  my name  "
  </code></pre>
  
  <p>after this, i want to count the number of words in the line. but when i do len(en) I get 30 instead of 7. </p>
  
  <p>Using split on en to tokenize and find the length doesn't work in all cases. e.g.</p>
  
  <p>i tried that it doesn't always work. e.g. consider this string. </p>
  
  <pre><code>"i ccc bcc the a of the abc ccc dd on aaa , 28 abc 19 ."
  </code></pre>
  
  <p>en then becomes:</p>
  
  <pre><code>"i ccc bcc the a of the abc ccc dd on aaa 28 abc 19 "
  </code></pre>
  
  <p>but len(en) returns 17 and not 15.</p>
  
  <p>can you please help? thanks</p>