INNER CODE UNIT · Python

add_mapping

center-for-threat-informed-defense/tram · src/scripts/reformat_training_data.py:208

    def add_mapping(self, sentence_text, attack_id=None):
        mappings = self.mappings.get(sentence_text, [])  # Get mappings or empty list

        if attack_id:  # If attack_id is specified, add it to the list
            if attack_id not in mappings:
                mappings.append(attack_id)

        self.mappings[sentence_text] = mappings  # Put the mapping list back in

    def to_report_export_serializer_json(self):
        """Creates a dict that can be used to create
        a serializers.ReportExportSerializer instance
        """
        utc_now = datetime.utcnow().isoformat() + "Z"
        res_json = {
            "name": "Bootstrap Training Data",
            "text": "There is no text for this report. These sentences were mapped by human analysts.",
            "ml_model": "humans",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…