Exemple #1
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'])