Created
February 2, 2014 05:19
-
-
Save smalyshev/8763429 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
import sys | |
f = open(sys.argv[1], 'r') | |
txt = f.readline().strip() | |
patterns = [p.strip() for p in f] | |
f = open(sys.argv[2], 'r') | |
answers = [int(i) for i in f.readline().strip().split(' ')] | |
anset = set() | |
for ans in answers: | |
good = False | |
for p in patterns: | |
if txt[ans:ans+len(p)] == p: | |
good = True | |
if not good: | |
print "=== BAD: ", ans | |
if ans in anset: | |
print "=== DUPLICATE: ", ans | |
anset.add(ans) | |
# print ans | |
for p in patterns: | |
# print p | |
idx = 0 | |
while True: | |
idx = txt.find(p, idx) | |
if idx == -1: | |
break | |
if idx not in anset: | |
print "=== MISSING: ", p, idx | |
idx += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use: check.py dataset.txt answers.txt