<commit_before>/* See LICENSE file for copyright and license details. */

#include "node.hpp"

#include <QDebug>

using namespace std;

const map<Port::Type, std::string> Port::TYPENAME{{Type::EXPLICIT, "[->]"},
                                                  {Type::LATENT, "[~]"},
                                                  {Type::EVENT, "[!]"},
                                                  {Type::OTHER, ""}};

Node::Node() : Node(boost::uuids::random_generator()()) {}
Node::Node(boost::uuids::uuid uuid)
    : uuid(uuid), _x(0), _y(0), _cognitive_function(CognitiveFunction::OTHER) {}

Node::~Node() {
    // qWarning() << "Node " << QString::fromStdString(_name) << " deleted!!";
}

/* Performs a deep-copy of the current Node, with however a different UUID
 */
NodePtr Node::duplicate() const {
    auto node = make_shared<Node>();
    node->name(_name + " (copy)");

    for (const auto p : _ports) {
        node->createPort(*p);
    }

    return node;
}

PortPtr Node::createPort(const Port port) {
    auto portPtr = make_shared<Port>(port);

    // check that we do not already have this port
    for (auto p : _ports) {<commit_msg>Preserve node's cognitive function when duplicating<commit_after>/* See LICENSE file for copyright and license details. */

#include "node.hpp"

#include <QDebug>

using namespace std;

const map<Port::Type, std::string> Port::TYPENAME{{Type::EXPLICIT, "[->]"},
                                                  {Type::LATENT, "[~]"},
                                                  {Type::EVENT, "[!]"},
                                                  {Type::OTHER, ""}};

Node::Node() : Node(boost::uuids::random_generator()()) {}
Node::Node(boost::uuids::uuid uuid)
    : uuid(uuid), _x(0), _y(0), _cognitive_function(CognitiveFunction::OTHER) {}

Node::~Node() {
    // qWarning() << "Node " << QString::fromStdString(_name) << " deleted!!";
}

/* Performs a deep-copy of the current Node, with however a new UUID
 */
NodePtr Node::duplicate() const {
    auto node = make_shared<Node>();
    node->name(_name + " (copy)");
    node->cognitive_function(_cognitive_function);

    for (const auto p : _ports) {
        node->createPort(*p);
    }

    return node;
}

PortPtr Node::createPort(const Port port) {
    auto portPtr = make_shared<Port>(port);

    // check that we do not already have this port
    for (auto p : _ports) {
{'fraction_non_alphanumeric': 0.16493127863390253, 'fraction_numerical': 0.001665972511453561, 'mean_word_length': 2.4811594202898553, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2300547', 'n_tokens_mistral': 715, 'n_tokens_neox': 702, 'n_words': 174}