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CO)]
[$(C(=O)O)]
[$([OX1]C=O)$(OCC)]
[$([OX1]C(=O)C)]
[$(C=O)]
[C$(*=O)]
[O;-]
[O&-]
[C&r]
[Cr]
[a&s]
[as]
[+14]
[$([2H++])]
[$([2H]),$([3H])]
[2H,3H]
[$((C.C(C)C.C))]
[$((C))]
C(C)1CCC1
(C).(R).[U].([$(*)])
C[$([2H])$([3H])]
"""
lines = map(string.strip, string.split(patterns, "\n"))
def test():
h = Handler.TokenHandler()
#h = Handler.WriteHandler() # uncomment to print
t1 = time.clock()
for line in lines:
#print "Parsing", line
Smarts.tokenize(line, h)
t2 = time.clock()
print len(lines), "patt. in", t2 - t1, "s =>",
print (t2-t1)/len(lines), "s/patt. ==",
print len(lines)/(t2-t1), "patt./s"
if __name__ == "__main__":
test()
|