Created
October 31, 2013 04:37
-
-
Save semisight/7244425 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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