Exemple #1
0
    def test_accept_any_sentence_and_create_unit_or_assign_it(self):
        long_sentence = '''<p>The reactor pressure vessel temperatures in <strong>Unit 1</strong> remain above cold shutdown conditions. The indicated temperature at the feedwater nozzle of the reactor pressure vessel is 138 &deg;C and at the bottom of reactor pressure vessel is 111 &deg;C.</p>
<p>The reactor pressure vessel temperatures in <strong>Unit 2</strong> remain above cold shutdown conditions. The indicated temperature at the feed water nozzle of the reactor pressure vessel is 123 &deg;C. The reactor pressure vessel and the dry well remain at atmospheric pressure. Fresh water injection (approximately 38 tonnes) to the spent fuel pool via the spent fuel pool cooling line was carried out on 25 April.</p>
<p>The temperature at the bottom of the reactor pressure vessel in <strong>Unit 3</strong> remains above cold shutdown conditions. The indicated temperature at the feed water nozzle of the reactor pressure vessel is 75 &deg;C and at the bottom of the reactor pressure vessel is 111 &deg;C. The reactor pressure vessel and the dry well remain at atmospheric pressure.</p>
'''
        sentences = long_sentence.split('.')

        unit_parser = UnitSentenceParser()
        for sentence in sentences:
            unit_parser.accept(sentence)

        self.assertEqual(len(unit_parser.units), 3)

        self.assertEqual(unit_parser.units['1'].feedwater_nozzle_temp, '138')
        self.assertEqual(unit_parser.units['2'].feedwater_nozzle_temp, '123')
        self.assertEqual(unit_parser.units['3'].feedwater_nozzle_temp, '75')
        self.assertEqual(unit_parser.units['3'].reactor_bottom_temp, '111')
Exemple #2
0
    def test_split_sentences_and_assign_sentences_to_unit(self):
        long_sentence = 'In <strong>Unit 2</strong>, the temperature at the feed water nozzle of the RPV is 150 °C.  In <strong>Unit 3</strong> the temperature at the feed water nozzle of the RPV is 91 °C and at the bottom of the RPV is 121 °C.'
        sentences = long_sentence.split('.')

        unit_parser = UnitSentenceParser()
        unit_sentence_assignments = {}
        current_unit = None
        for sentence in sentences:
            if unit_parser._is_unit_sentence(sentence):
                current_unit = unit_parser._parse_unit(sentence)
                if current_unit not in unit_sentence_assignments.keys():
                    unit_sentence_assignments[current_unit] = []
            if current_unit:
                unit_sentence_assignments[current_unit].append(sentence)

        keys = unit_sentence_assignments.keys()
        keys.sort()
        self.assertEqual(keys, ['2', '3'])
Exemple #3
0
 def test_categorize_sentence(self):
     assert UnitSentenceParser()._is_unit_sentence('In <strong>Unit 2</strong>, the temperature at the feed water nozzle of the RPV is 150 °C.')
     assert UnitSentenceParser()._has_temp('In <strong>Unit 2</strong>, the temperature at the feed water nozzle of the RPV is 150 °C.')
     assert UnitSentenceParser()._has_nozzle_temp('In <strong>Unit 2</strong>, the temperature at the feed water nozzle of the RPV is 150 °C.')
     assert UnitSentenceParser()._has_bottom_temp('In <strong>Unit 3</strong> the temperature at the feed water nozzle of the RPV is 91 °C and at the bottom of the RPV is 121 °C.')
     assert UnitSentenceParser()._is_multi_part_sentence('In <strong>Unit 3</strong> the temperature at the feed water nozzle of the RPV is 91 °C and at the bottom of the RPV is 121 °C.')
Exemple #4
0
 def test_read_unit_from_sentence(self):
     sentence = '<p>The reactor pressure vessel temperatures in <strong>Unit 1</strong> remain above cold shutdown conditions.'
     self.assertEquals(UnitSentenceParser()._parse_unit(sentence), '1')