<commit_before>package org.nexusformat;

import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

class NXSnode implements TreeModel {
	private static final String PADDING = "  ";
	private static final String NXROOT = "NXroot";
	private static final String TYPE = "NAPItype";
	private static final String LINK = "NAPIlink";
	private static final String SDS = "SDS";
	private static final Logger LOG = Logger.getInstance();

	private String name;
	private String nxclass;
	private Map<String, String> attrs;
	private Vector<NXSnode> children;
	private Vector<SVRLitem> svrl;

	NXSnode(final Node node) {
		this.nxclass  = node.getNodeName();
		this.attrs = new HashMap<String, String>();
		this.setAttrs(node.getAttributes());

		NodeList nodes = node.getChildNodes();
		int size = nodes.getLength();
		this.children = new Vector<NXSnode>();
		for (int i = 0; i < size; i++) {
			this.addChild(nodes.item(i));
		}
		this.svrl = new Vector<SVRLitem>();
	}

	Vector<SVRLitem> addSVRL(final Node svrl) {
		// generate a list of xml error nodes
		Vector<Node> errors = new Vector<Node>();
		addSVRL(svrl, errors);

		// convert it to java classes
		Vector<SVRLitem> items = new Vector<SVRLitem>();
		for (Node node: errors) {
			items.add(new SVRLitem(node));
		}

		// find the appropriate nodes to attach it to
		NXSnode nxsnode;
		for (SVRLitem item: items) {
			nxsnode = getNode(this, item.getLocationArray(), 1);
			nxsnode.svrl.add(item);
		}

		return items;
	}

	private static NXSnode getNode(NXSnode parent, Vector<String> location,
			int depth) {
		// chop up this part of the path to be useful<commit_msg>Added default node that is just an empty root. Refs #179.<commit_after>package org.nexusformat;

import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

class NXSnode implements TreeModel {
	private static final String PADDING = "  ";
	private static final String NXROOT = "NXroot";
	private static final String TYPE = "NAPItype";
	private static final String LINK = "NAPIlink";
	private static final String SDS = "SDS";
	private static final Logger LOG = Logger.getInstance();

	private String name;
	private String nxclass;
	private Map<String, String> attrs;
	private Vector<NXSnode> children;
	private Vector<SVRLitem> svrl;

	NXSnode() {
		this.name = NXROOT;
		this.nxclass = "";
		this.attrs = new HashMap<String, String>();
		this.children = new Vector<NXSnode>();
		this.svrl = new Vector<SVRLitem>();
	}

	NXSnode(final Node node) {
		this();
		this.nxclass  = node.getNodeName();
		this.setAttrs(node.getAttributes());

		NodeList nodes = node.getChildNodes();
		int size = nodes.getLength();
		for (int i = 0; i < size; i++) {
			this.addChild(nodes.item(i));
		}
	}

	Vector<SVRLitem> addSVRL(final Node svrl) {
		// generate a list of xml error nodes
		Vector<Node> errors = new Vector<Node>();
		addSVRL(svrl, errors);

		// convert it to java classes
		Vector<SVRLitem> items = new Vector<SVRLitem>();
		for (Node node: errors) {
			items.add(new SVRLitem(node));
		}

		// find the appropriate nodes to attach it to
		NXSnode nxsnode;
		for (SVRLitem item: items) {
			nxsnode = getNode(this, item.getLocationArray(), 1);
			nxsnode.svrl.add(item);
		}

		return items;
	}

	private static NXSnode getNode(NXSnode parent, Vector<String> location,
			int depth) {
		// chop up this part of the path to be useful
{'fraction_non_alphanumeric': 0.11851851851851852, 'fraction_numerical': 0.0034391534391534392, 'mean_word_length': 4.165300546448087, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 27, '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': '4225159', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1258, 'n_words': 368}