title: split sentences and combine words in Apache Beam
body: <p>I have a PCollection of dictionaries:</p>
  
  <pre><code>{'sentence': 'foo bar', 'value' : 5 }
  {'sentence': 'one bar', 'value' : 2 }
  </code></pre>
  
  <p>I would like to space split the sentences, give the same value for each word of the sentence, and then aggregate by word with sum function. My desired output is:</p>
  
  <pre><code>{'word': 'foo', 'value' : 5}
  {'word': 'bar', 'value' : 7}
  {'word': 'one', 'value' : 2}
  </code></pre>
  
  <p>I defined a function that splits the sentence and returns a list of dicts for each sentence:</p>
  
  <pre><code>def word_dicts(row):
   words = row['sentence'].split(' ')
   return [{'word' : word, 'value' : row['value'] } for word in words]
  </code></pre>
  
  <p>I put this function in a <code>beam.Map</code>, then i'm using <code>beam.CombineGlobally(beam.combiners.ToListCombineFn())</code> to get a list of all lists of dictoinaries </p>
  
  <pre><code>[[{'word': 'foo', 'value' : 5},{'word': 'bar', 'value' : 5}],[{'word': 'foo', 'value' : 5},{'word': 'one', 'value' : 2}]]
  </code></pre>
  
  <p>And then i'm stuck because i can't see how to Partition this list and do the Combine to get the final results.</p>
  
  <p>Do you know a simplest way to do this? </p>
  
  <p>Thanks in advance</p>