<s> """<STR_LIT>""" <EOL> import os <EOL> import os . path <EOL> from pypred import Predicate , PredicateSet , OptimizedPredicateSet <EOL> DOC = { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT:status>" : <NUM_LIT> , <EOL> "<STR_LIT>" : { "<STR_LIT:source>" : "<STR_LIT>" , "<STR_LIT>" : { "<STR_LIT:text>" : "<STR_LIT>" } } , <EOL> "<STR_LIT>" : <NUM_LIT:100> , <EOL> "<STR_LIT>" : <NUM_LIT:200> , <EOL> } <EOL> def test_samples ( ) : <EOL> p = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> fh = open ( os . path . join ( p , "<STR_LIT>" ) ) <EOL> s1 = PredicateSet ( ) <EOL> s2 = OptimizedPredicateSet ( ) <EOL> match = [ ] <EOL> for line , pred in enumerate ( fh ) : <EOL> pred = pred . strip ( ) <EOL> obj = Predicate ( pred ) <EOL> s1 . add ( obj ) <EOL> s2 . add ( obj ) <EOL> if pred . endswith ( "<STR_LIT:true>" ) : <EOL> match . append ( pred ) <EOL> s1_match = s1 . evaluate ( DOC ) <EOL> s2_match = s2 . evaluate ( DOC ) <EOL> match . sort ( ) <EOL> s1_match = [ p . predicate for p in s1_match ] <EOL> s1_match . sort ( ) <EOL> s2_match = [ p . predicate for p in s2_match ] <EOL> s2_match . sort ( ) <EOL> assert s1_match == match <EOL> assert s2_match == match </s>
