title: How do I accumulate vectors into a map?
body: <p>I have an alias <code>A</code> like this:</p>
  
  <pre><code>{cookie: chararray,
   keywords: {tuple_of_tokens: (token: chararray)},
   weight: double}
  </code></pre>
  
  <p>where the 2nd and 3rd fields are defined as</p>
  
  <pre><code>keywords = TOKENIZE((chararray)$5,',');
  weight = 1.0/(double)SIZE(keywords);
  </code></pre>
  
  <p>now I want to do </p>
  
  <pre><code>foreach (group A by cookie) generate
    group.cookie as cookie,
    ???? as keywords;
  </code></pre>
  
  <p>and <code>keywords</code> should be a <code>map</code> from a keyword into a the sum of weights.</p>
  
  <p>E.g., </p>
  
  <pre><code>1   k1,k2,k3
  1   k2,k4
  </code></pre>
  
  <p>should turn into</p>
  
  <pre><code>1   {k1:1/3, k2:5/6, k3:1/3, k4:1/2}
  </code></pre>
  
  <p>I am already using <a href="http://datafu.incubator.apache.org/docs/datafu/guide.html" rel="nofollow">datafu</a>, but I am open to any alternative...</p>