<commit_before>// shows an overview of an implementation phase model

const impMetamodel = require('./impSchema.js')

module.exports = function overview (cy) {
  const networkArray = impMetamodel.network
  const securityArray = impMetamodel.security
  const socialArray = impMetamodel.social

  let result = ''

  const totalNodes = cy.elements().nodes().length
  result = `• total nodes: ${totalNodes}\n\n`

  let networkNode = 0
  let securityNode = 0
  let socialNode = 0

  cy.nodes().map(node => {
    const nodeConcept = node.data().asto.concept
    if (networkArray.includes(nodeConcept) === true) {
      networkNode += 1
    } else if (securityArray.includes(nodeConcept) === true) {
      securityNode += 1
    } else if (socialArray.includes(nodeConcept) === true) {
      socialNode += 1
    }
  })
  result = `${result}• network nodes: ${networkNode}\n`
  result = `${result}• social nodes: ${socialNode}\n`
  result = `${result}• security nodes: ${securityNode}\n\n`

  let deviceNode = 0
  let connectionNode = 0
  let micronetNode = 0
  let applicationNode = 0
  let netNode = 0
  let informationNode = 0
  let assetNode = 0
  let threatNode = 0
  let vulnNode = 0
  let mechNode = 0
  let constraintNode = 0
  let malActorNode = 0
  let actorNode = 0

  cy.nodes().map(node => {
    const nodeConcept = node.data().asto.concept
    if (nodeConcept === 'device') {
      deviceNode += 1
    } else if (nodeConcept === 'application') {
      applicationNode += 1
    } else if (nodeConcept === 'information') {
      informationNode += 1
    } else if (nodeConcept === 'network connection') {
      connectionNode += 1
    } else if (nodeConcept === 'micronet') {
      micronetNode += 1
    } else if (nodeConcept === 'net') {
      netNode += 1
    } else if (nodeConcept === 'asset') {
      assetNode += 1
    } else if (nodeConcept === 'threat') {
      threatNode += 1
    } else if (nodeConcept === 'vulnerability') {
      vulnNode += 1
    } else if (nodeConcept === 'mechanism') {
      mechNode += 1
    } else if (nodeConcept === 'constraint') {
      constraintNode += 1
    } else if (nodeConcept === 'malicious actor') {
      malActorNode += 1
    } else if (nodeConcept === 'actor') {
      actorNode += 1
    }
  })

  result = `${result}• device nodes: ${deviceNode}\n`
  result = `${result}• application nodes: ${applicationNode}\n`
  result = `${result}• network connection nodes: ${connectionNode}\n`
  result = `${result}• micronet nodes: ${micronetNode}\n`
  result = `${result}• net nodes: ${netNode}\n`
  result = `${result}• information nodes: ${informationNode}\n`
  result = `${result}• asset nodes: ${assetNode}\n`
  result = `${result}• threat nodes: ${threatNode}\n`
  result = `${result}• vulnerability nodes: ${vulnNode}\n`
  result = `${result}• mechanism nodes: ${mechNode}\n`
  result = `${result}• constraint nodes: ${constraintNode}\n`
  result = `${result}• malicious actor nodes: ${malActorNode}\n`
  result = `${result}• actor nodes: ${actorNode}\n`

  // show result in the graph container
  const containerNode = document.getElementById('container-node-id')
  const containerNodeInfo = document.getElementById('container-node-info-id')
  // appends info to the div
  containerNode.style.display = 'block'
  containerNodeInfo.textContent = result
}
<commit_msg>:hammer: refactor imp overview<commit_after>// shows the total number of nodes along with their concept type and module

const impMetamodel = require('./impSchema.js')

module.exports = function overview (cy) {
  // initialize the output of the module
  let output = ''

  // stores the node of module nodes
  const moduleNodes = {
    network: {
      schema: impMetamodel.network,
      numberOfNodes: 0
    },
    security: {
      schema: impMetamodel.security,
      numberOfNodes: 0
    },
    social: {
      schema: impMetamodel.social,
      numberOfNodes: 0
    }
  }

  // stores the number of each node
  const graphNodes = {
    device: {
      numberOfNodes: 0
    },
    application: {
      numberOfNodes: 0
    },
    micronet: {
      numberOfNodes: 0
    },
    net: {
      numberOfNodes: 0
    },
    information: {
      numberOfNodes: 0
    },
    asset: {
      numberOfNodes: 0
    },
    constraint: {
      numberOfNodes: 0
    },
    threat: {
      numberOfNodes: 0
    },
    actor: {
      numberOfNodes: 0
    },
    'malicious actor': {
      numberOfNodes: 0
    },
    vulnerability: {
      numberOfNodes: 0
    },
    mechanism: {
      numberOfNodes: 0
    }
  }

  const totalNodes = cy.elements().nodes().length
  output = `• total nodes: ${totalNodes}\n\n`

  // count the number of nodes
  cy.nodes().map(node => {
    const nodeConcept = node.data().asto.concept
    // count the module nodes
    Object.keys(moduleNodes).map(module => {
      if (moduleNodes[module].schema.includes(nodeConcept) === true) {
        moduleNodes[module].numberOfNodes += 1
      }
    })
    // count the concept nodes
    Object.keys(graphNodes).map(concept => {
      if (nodeConcept === concept) {
        graphNodes[concept].numberOfNodes += 1
      }
    })
  })

  // compose the output by parsing the objects
  const composeOutput = (node, numberOfNodes) => {
    output += `• ${node} nodes: ${numberOfNodes}\n`
  }

  // loop the objects to compose the output
  Object.keys(moduleNodes).map(module => {
    composeOutput(module, moduleNodes[module].numberOfNodes)
  })
  // new line between modules and concepts
  output += `\n`
  Object.keys(graphNodes).map(node => {
    composeOutput(node, graphNodes[node].numberOfNodes)
  })

  // show result in the graph container
  const containerNode = document.getElementById('container-node-id')
  const containerNodeInfo = document.getElementById('container-node-info-id')
  // appends info to the div
  containerNode.style.display = 'block'
  containerNodeInfo.textContent = output
}

{'fraction_non_alphanumeric': 0.1353051164371919, 'fraction_numerical': 0.008329083800781914, 'mean_word_length': 2.9810554803788905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3595413', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1791, 'n_words': 485}