コード例 #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?
コード例 #2
0
 def test_document(self):
     elements = [
         Paragraph(
             '''The consequences of global change on rivers include altered flow regime, and entrance of
                      compounds that may be toxic to biota. When water is scarce, a reduced dilution capacity may
                      amplify the effects of chemical pollution. Therefore, studying the response of natural
                      communities to compromised water flow and to toxicants is critical for assessing how global
                      change may affect river ecosystems. This work aims to investigate how an episode of drought
                      might influence the response of river biofilms to pulses of triclosan (TCS). The objectives
                      were to assess the separate and combined effects of simulated drought (achieved through
                      drastic flow alteration) and of TCS exposure on biofilms growing in artificial channels.'''
         ),
         Paragraph(
             '''Thus, three-week-old biofilms were studied under four conditions: Control (normal water flow);
                      Simulated Drought (1 week reduced flow+2 days interrupted flow); TCS only (normal water flow
                      plus a 48-h pulse of TCS); and Simulated Drought+TCS. All channels were then left for 2 weeks
                      under steady flow conditions, and their responses and recovery were studied.
                      Several descriptors of biofilms were analyzed before and after each step. Flow reduction and
                      subsequent interruption were found to provoke an increase in extracellular phosphatase
                      activity, bacterial mortality and green algae biomass. The TCS pulses severely affected
                      biofilms: they drastically reduced photosynthetic efficiency, the viability of bacteria and
                      diatoms, and phosphate uptake. Latent consequences evidenced significant combined effects
                      caused by the two stressors.'''),
         Paragraph(
             '''The biofilms exposed only to TCS recovered far better than those
                      subjected to both altered flow and subsequent TCS exposure: the latter suffered more
                      persistent consequences, indicating that simulated drought amplified the toxicity of this
                      compound. This finding has implications for river ecosystems, as it suggests that the toxicity
                      of pollutants to biofilms may be exacerbated following a drought.'''
         )
     ]
     d = Document(*elements)
     self.assertEqual(d.abbreviation_definitions,
                      [(['TCS'], ['triclosan'], 'CM')])
コード例 #3
0
 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']}])
コード例 #4
0
 def test_document_iter(self):
     """Test Document can be iterated like a list to access its elements."""
     els = [
         'A first paragraph. With two sentences.', 'A second paragraph.',
         'A third paragraph.'
     ]
     d = Document(*els)
     self.assertEqual(len(d), 3)
     self.assertEqual(d[2].text, 'A third paragraph.')
     self.assertEqual([e.text for e in d], els)
コード例 #5
0
 def test_bytestring_elements(self):
     """Test Document can be instantiated with a list of bytestrings."""
     els = [
         'A first paragraph. With two sentences.'.encode('ascii'),
         'A second paragraph. \u00a9'.encode('utf-8'),
         'A third paragraph (\u00b6).'.encode('windows-1252'),
     ]
     d = Document(*els)
     self.assertEqual(d.elements[0].text, 'A first paragraph. With two sentences.')
     self.assertEqual(d.elements[0].sentences[1].text, 'With two sentences.')
     self.assertEqual(d.elements[1].document, d)
コード例 #6
0
 def test_text_elements(self):
     """Test Document can be instantiated with a list of strings."""
     els = [
         'A first paragraph. With two sentences.',
         'A second paragraph.',
         'A third paragraph.'
     ]
     d = Document(*els)
     self.assertEqual(d.elements[0].text, 'A first paragraph. With two sentences.')
     self.assertEqual(d.elements[0].sentences[1].text, 'With two sentences.')
     self.assertEqual(d.elements[1].document, d)