Skip to content

Instantly share code, notes, and snippets.

@semisight
Created October 31, 2013 04:37
Show Gist options
  • Save semisight/7244425 to your computer and use it in GitHub Desktop.
Save semisight/7244425 to your computer and use it in GitHub Desktop.
from __future__ import division
from json import dumps
data = [
'arostn a ard aoyd rad radrpd',
'aodha a aoydydyo 43qlgdi',
'ta <irhaotyqodl>og</irhaotyqodl>'
]
# dict of {words => [line nos]}
occurs = {}
for i in range(len(data)):
line = data[i].split()
for word in line:
if word in occurs:
occurs[word].append(i)
else:
occurs[word] = [i]
print dumps(occurs, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment