<commit_before>'use strict';

var NS_IODEF = exports.NS_IODEF = 'urn:ietf:params:xml:ns:iodef-1.0'

var VERSION_IODEF = exports.VERSION_IODEF = '1.00'

var logger

var iodefDocumentAttributes = ['version', 'lang', 'formatid']
var incidentAttributes = ['purpose', 'ext-purpose', 'lang', 'restriction']
var incidentIdAttributes = ['name', 'instance', 'restriction']
var assessmentAttributes = ['occurrence', 'restriction']
var impactAttributes = ['lang', 'severity', 'completion', 'type', 'ext-type']
var contactAttributes = ['role', 'ext-role', 'type', 'ext-type', 'restriction']
var emailAttributes = ['meaning']

var parseIncidentId = function(incident, entity) {
    var incidentId

    if (!(incidentId = incident.getChild('IncidentID'))) return

    entity.IncidentID = {
        IncidentID : incidentId.getText()
    }

    incidentIdAttributes.forEach(function(attribute) {
        if (incidentId.attrs[attribute]) entity.IncidentID[attribute] = incidentId.attrs[attribute]
    })
}

var parseReportTime = function(incident, entity) {
    var reportTime

    if (!(reportTime = incident.getChild('ReportTime'))) return

    entity.ReportTime = {
        ReportTime : reportTime.getText()
    }
}

var parseImpact = function(assessment, entity) {
    var impacts

    if (0 === (impacts = assessment.getChildren('Impact')).length) return

    entity.Impacts = []

    impacts.forEach(function(impact) {
        var item = {}

        impactAttributes.forEach(function(attribute) {
            if (impact.attrs[attribute]) item[attribute] = impact.attrs[attribute]
        })

        item.Impact = impact.getText()

        entity.Impacts.push(item)
    })
}

var parseAssessments = function(incident, entity) {
    var assessments

    if (0 === (assessments = incident.getChildren('Assessment')).length) return

    entity.Assessments = []

    assessments.forEach(function(assessment) {
        var item = {}

        assessmentAttributes.forEach(function(attribute) {
            if (assessment.attrs[attribute]) item[attribute] = assessment.attrs[attribute]
        })

        parseImpact(assessment, item);
        entity.Assessments.push(item)
    })
}

var parseContactName = function(contact, entity) {
    var contactName

    if (!(contactName = contact.getChild('ContactName'))) return

    // Simple string element with no attributes but I'd prefer to be consistent so:
    entity.ContactName = {
        ContactName : contactName.getText()
    }
}

var parseEmail = function(contact, entity) {
    var emails

    if (0 === (emails = contact.getChildren('Email')).length) return

    entity.Emails = []

    emails.forEach(function(email) {
        var item = {}

        emailAttributes.forEach(function(attribute) {
            if (email.attrs[attribute]) item[attribute] = email.attrs[attribute]
        })
        item.Email = email.getText()
        entity.Emails.push(item)
    })
}

var parseContact = function(incident, entity) {
    var contacts<commit_msg>formatting<commit_after>'use strict';

var NS_IODEF = exports.NS_IODEF = 'urn:ietf:params:xml:ns:iodef-1.0'

var VERSION_IODEF = exports.VERSION_IODEF = '1.00'

var logger

var iodefDocumentAttributes = ['version', 'lang', 'formatid']
var incidentAttributes = ['purpose', 'ext-purpose', 'lang', 'restriction']
var incidentIdAttributes = ['name', 'instance', 'restriction']
var assessmentAttributes = ['occurrence', 'restriction']
var impactAttributes = ['lang', 'severity', 'completion', 'type', 'ext-type']
var contactAttributes = ['role', 'ext-role', 'type', 'ext-type', 'restriction']
var emailAttributes = ['meaning']

var parseIncidentId = function(incident, entity) {
    var incidentId

    if (!(incidentId = incident.getChild('IncidentID'))) return

    entity.IncidentID = {
        IncidentID: incidentId.getText()
    }

    incidentIdAttributes.forEach(function(attribute) {
        if (incidentId.attrs[attribute]) entity.IncidentID[attribute] = incidentId.attrs[attribute]
    })
}

var parseReportTime = function(incident, entity) {
    var reportTime

    if (!(reportTime = incident.getChild('ReportTime'))) return

    entity.ReportTime = {
        ReportTime: reportTime.getText()
    }
}

var parseImpact = function(assessment, entity) {
    var impacts

    if (0 === (impacts = assessment.getChildren('Impact')).length) return

    entity.Impacts = []

    impacts.forEach(function(impact) {
        var item = {}

        impactAttributes.forEach(function(attribute) {
            if (impact.attrs[attribute]) item[attribute] = impact.attrs[attribute]
        })

        item.Impact = impact.getText()

        entity.Impacts.push(item)
    })
}

var parseAssessments = function(incident, entity) {
    var assessments

    if (0 === (assessments = incident.getChildren('Assessment')).length) return

    entity.Assessments = []

    assessments.forEach(function(assessment) {
        var item = {}

        assessmentAttributes.forEach(function(attribute) {
            if (assessment.attrs[attribute]) item[attribute] = assessment.attrs[attribute]
        })

        parseImpact(assessment, item);
        entity.Assessments.push(item)
    })
}

var parseContactName = function(contact, entity) {
    var contactName

    if (!(contactName = contact.getChild('ContactName'))) return

    // Simple string element with no attributes but I'd prefer to be consistent so:
    entity.ContactName = {
        ContactName: contactName.getText()
    }
}

var parseEmail = function(contact, entity) {
    var emails

    if (0 === (emails = contact.getChildren('Email')).length) return

    entity.Emails = []

    emails.forEach(function(email) {
        var item = {}

        emailAttributes.forEach(function(attribute) {
            if (email.attrs[attribute]) item[attribute] = email.attrs[attribute]
        })
        item.Email = email.getText()
        entity.Emails.push(item)
    })
}

var parseContact = function(incident, entity) {
    var contacts
{'fraction_non_alphanumeric': 0.13275226282266175, 'fraction_numerical': 0.0026818638954073082, 'mean_word_length': 3.493222891566265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3543162', 'n_tokens_mistral': 1776, 'n_tokens_neox': 1707, 'n_words': 361}