Example #1
0
 def test_consecutive_headings2(self):
     d = Document(
         Heading('Example-3'),
         Heading(
             'Preparation of 5-Bromo-6-pentadecyl-2-hydroxybenzoic acid (DBAA)'
         ),
         Paragraph(
             'The product had a melting point of 70-75° C. and has structural formula VII.'
         ))
     results = [r.serialize() for r in d.records]
     print(results)
     print([{
         'names': [u'5-Bromo-6-pentadecyl-2-hydroxybenzoic acid', u'DBAA'],
         'roles': ['product']
     }, {
         'melting_points': [{
             'units': u'\xb0C.',
             'value': u'70-75'
         }],
         'labels': [u'VII'],
         'roles': [u'formula']
     }])
     self.assertEqual(results, [{
         'labels': [u'VII'],
         'roles': [u'formula']
     }, {
         'melting_points': [{
             'units': u'\xb0C.',
             'value': u'70-75'
         }],
         'names': [u'5-Bromo-6-pentadecyl-2-hydroxybenzoic acid', u'DBAA'],
         'roles': ['product']
     }])  # example-3?
 def test_consecutive_headings(self):
     d = Document(
         Heading('Preparation of 2-Amino-3-methoxy-5-chloropyridine'),
         Heading('Example 3'),
         Paragraph('The solid is suspended in hexanes, stirred and filtered to give the product as a bright yellow solid. (MP 93-94\xc2\xb0 C.).')
     )
     results = [r.serialize() for r in d.records]
     self.assertEqual(results, [{'names': ['hexanes']}, {'labels': ['3'], 'names': ['2-Amino-3-methoxy-5-chloropyridine'], 'roles': ['product', 'example']}])
 def do_parse(self, input, expected):
     s = Heading(input)
     log.debug(s)
     log.debug(s.tagged_tokens)
     results = [r.serialize() for r in s.records]
     self.assertEqual(expected, results)