コード例 #1
0
 def test_full_series(self):
     longest_example_list = pp.remove_whitespace(pp.tokenize_and_or(
         pp.strip_irrelevant(pp.remove_tags(self.longer_example))))
     self.assertEqual(longest_example_list, ['(', 'CS 3510', 'or', 'CS 3511', ')', 'and',
         'MATH 3012', 'and', '(', 'MATH 3215', 'or', 'MATH 3770', 'or', 'MATH 3670',
         'or', 'CEE 3770', 'or', 'ISYE 3770', 'or', '(', 'ISYE 2027', 'and', 'ISYE 2028',
         ')', ')'])
コード例 #2
0
 def test_parse_tokens(self):
     example_prepped = pp.remove_whitespace(pp.tokenize_and_or(
         pp.strip_irrelevant(pp.remove_tags(self.longer_example))))
     parsed = pp.parse_tokens(example_prepped)
     correct = {'type': 'and', 'courses': [
         {'type' : 'or', 'courses' : [u'CS 3510', u'CS 3511']},
         u'MATH 3012',
         {'type' : 'or', 'courses': [
             u'MATH 3215',
             u'MATH 3770',
             u'MATH 3670',
             u'CEE 3770',
             u'ISYE 3770',
             {'type': 'and', 'courses': [u'ISYE 2027', u'ISYE 2028']}
         ]}
     ]}
     self.assertEqual(parsed, correct)
コード例 #3
0
 def test_sat_act(self):
     example_prepped = pp.remove_whitespace(pp.tokenize_and_or(
         pp.strip_irrelevant(pp.remove_tags(self.sat_example))))
     parsed = pp.parse_tokens(example_prepped)
     correct = {'courses': [u'MATH 1113', u'SAT Mathematics 550', u'ACT Math 550'], 'type': 'or'}
     self.assertEqual(parsed, correct)
コード例 #4
0
 def test_remove_tags(self):
     string = pp.remove_tags("<b>This is a string</b>")
     self.assertEqual(string, "This is a string")