title: Number of words per sentence
body: <p>I am reading a text file in Python 2.7 and what I am trying to do is to fill out the count of words in each sentence of a text file in to 1D array. Here is what I have:</p>
  
  <pre><code>f = open(file_txt, 'r')
  
  sen_prog = []
  
  for line in f:
      sents = line.split('.')
      sen_prog.append(sents)
  
  sen_p = []
  
  for a in sen_prog:
      for b in a:
          sen_p.append(b)
  
  sen_p = numpy.array(sen_p)
  sen_p = sen_p[sen_p!='-']
  
  sen_d = []
  
  
  for c in sen_p:
      sen_d.append([len(x.split()) for x in sen_p])
  
  sen_d = numpy.array(sen_d)
  sen_d = numpy.ravel(sen_d)
  
  print sen_prog, sen_d
  </code></pre>
  
  <p>The problem is that it is the array is created, but it gives out the wrong sentence count. My text file has 55 sentences (with each sentence separated by a full stop '.'), but it is giving out wrong figures...need help!</p>