title: Positional Index In python?
body: <p>am able to create an inverted index but I cannot quite implement a positional index. Positional index has a format of <code>[doc_ID, pos_1, pos_2, ...]</code></p>
  
  <p>here doc_ID indicate which document the word appears in and which position it appears in that document.</p>
  
  <p>Ex. <code>index = positional_index(['a','b','a'], ['a','c']])</code>
  when user  enters <code>index['a']</code> it will return <code>[[0,0,2], [1,0]]</code></p>
  
  <p>The following code is for the mentioned inverted index. I have no idea what else to add to make it positional index:</p>
  
  <pre><code>def positional index(tokens):
      d = defaultdict(lambda:[])
  
      for docID, t_list in enumerate(tokens):
          for t in t_list:
              d[t].append(docID)
  
  return d
  </code></pre>
  
  <p>All help would be much appreciated.</p>