<commit_before>package logistic_application;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class Facility_Inventory {

  public static void main(String[] args) {

        try {
            String fileName = "facility_network.xml";

            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();

            File xml = new File(fileName);
            if (!xml.exists()) {
                System.err.println("**** XML File '" + fileName + "' cannot be found");
                System.exit(-1);
            }
            
            Document doc = db.parse(xml);
            doc.getDocumentElement().normalize();

            NodeList fcltNetworkEntries = doc.getDocumentElement().getChildNodes();

            for (int i = 0; i < fcltNetworkEntries.getLength(); i++) {
                if (fcltNetworkEntries.item(i).getNodeType() == Node.TEXT_NODE) {
                    continue;
                }
                
                String entryName = fcltNetworkEntries.item(i).getNodeName();
                if (!entryName.equals("Facility")) {
                    System.err.println("Unexpected node found: " + entryName);
                    return;
                }
                
                // Get a node attribute
                NamedNodeMap fcltNetworkMap = fcltNetworkEntries.item(i).getAttributes();
                String fcltId = fcltNetworkMap.getNamedItem("Id").getNodeValue();

                // Get information of a node 
                Element fcltNetwork = (Element) fcltNetworkEntries.item(i);
                String fcltName = fcltNetwork.getElementsByTagName("Name").item(0).getTextContent();
                String fcltRate = fcltNetwork.getElementsByTagName("Rate").item(0).getTextContent();
                String fcltCost = fcltNetwork.getElementsByTagName("Cost").item(0).getTextContent();
                
                // Get Links - there can be 0 or more
                ArrayList<String> linksDescriptions = new ArrayList<>();
                NodeList linksList = fcltNetwork.getElementsByTagName("Link");
                for (int j = 0; j < linksList.getLength(); j++) {
                    if (linksList.item(j).getNodeType() == Node.TEXT_NODE) {
                        continue;
                    }

                    entryName = linksList.item(j).getNodeName();
                    if (!entryName.equals("Link")) {
                        System.err.println("Unexpected node found: " + entryName);
                        return;
                    }

                    // Get some named nodes
                    fcltNetwork = (Element) linksList.item(j);
                    String neighborName = fcltNetwork.getElementsByTagName("Name").item(0).getTextContent();
                    String neighborDist = fcltNetwork.getElementsByTagName("Distance").item(0).getTextContent();
                    
                    // Create a string summary of the book
                    linksDescriptions.add(neighborName + " is " + neighborDist + " miles away" );
                    //+ bookDate + " [" + bookIsbn13 + "]");
                }
                
                
                
                
                
                
                
                // Get all nodes named "Inventory" - there can be 0 or more
                ArrayList<String> inventoryDescriptions = new ArrayList<>();
                NodeList inventoryList = elem.getElementsByTagName("Inventory");
                for (int j = 0; j < inventoryList.getLength(); j++) {
                    if (inventoryList.item(j).getNodeType() == Node.TEXT_NODE) {
                        continue;
                    }

                    entryName = inventoryList.item(j).getNodeName();
                    if (!entryName.equals("Inventory")) {
                        System.err.println("Unexpected node found: " + entryName);
                        return;
                    }

                    // Get some named nodes
                    elem = (Element) inventoryList.item(j);
                    String inventoryItemID = elem.getElementsByTagName("ItemID").item(0).getTextContent();
                    String inventoryQ = elem.getElementsByTagName("Quantity").item(0).getTextContent();<commit_msg>switch "elem" to "fcltNetwork"<commit_after>package logistic_application;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class Facility_Inventory {

  public static void main(String[] args) {

        try {
            String fileName = "facility_network.xml";

            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();

            File xml = new File(fileName);
            if (!xml.exists()) {
                System.err.println("**** XML File '" + fileName + "' cannot be found");
                System.exit(-1);
            }
            
            Document doc = db.parse(xml);
            doc.getDocumentElement().normalize();

            NodeList fcltNetworkEntries = doc.getDocumentElement().getChildNodes();

            for (int i = 0; i < fcltNetworkEntries.getLength(); i++) {
                if (fcltNetworkEntries.item(i).getNodeType() == Node.TEXT_NODE) {
                    continue;
                }
                
                String entryName = fcltNetworkEntries.item(i).getNodeName();
                if (!entryName.equals("Facility")) {
                    System.err.println("Unexpected node found: " + entryName);
                    return;
                }
                
                // Get a node attribute
                NamedNodeMap fcltNetworkMap = fcltNetworkEntries.item(i).getAttributes();
                String fcltId = fcltNetworkMap.getNamedItem("Id").getNodeValue();

                // Get information of a node 
                Element fcltNetwork = (Element) fcltNetworkEntries.item(i);
                String fcltName = fcltNetwork.getElementsByTagName("Name").item(0).getTextContent();
                String fcltRate = fcltNetwork.getElementsByTagName("Rate").item(0).getTextContent();
                String fcltCost = fcltNetwork.getElementsByTagName("Cost").item(0).getTextContent();
                
                // Get Links - there can be 0 or more
                ArrayList<String> linksDescriptions = new ArrayList<>();
                NodeList linksList = fcltNetwork.getElementsByTagName("Link");
                for (int j = 0; j < linksList.getLength(); j++) {
                    if (linksList.item(j).getNodeType() == Node.TEXT_NODE) {
                        continue;
                    }

                    entryName = linksList.item(j).getNodeName();
                    if (!entryName.equals("Link")) {
                        System.err.println("Unexpected node found: " + entryName);
                        return;
                    }

                    // Get some named nodes
                    fcltNetwork = (Element) linksList.item(j);
                    String neighborName = fcltNetwork.getElementsByTagName("Name").item(0).getTextContent();
                    String neighborDist = fcltNetwork.getElementsByTagName("Distance").item(0).getTextContent();
                    
                    // Create a string summary of the book
                    linksDescriptions.add(neighborName + " is " + neighborDist + " miles away" );
                    //+ bookDate + " [" + bookIsbn13 + "]");
                }
                
                
                
                
                
                
                
                // Get all nodes named "Inventory" - there can be 0 or more
                ArrayList<String> inventoryDescriptions = new ArrayList<>();
                NodeList inventoryList = fcltNetwork.getElementsByTagName("Inventory");
                for (int j = 0; j < inventoryList.getLength(); j++) {
                    if (inventoryList.item(j).getNodeType() == Node.TEXT_NODE) {
                        continue;
                    }

                    entryName = inventoryList.item(j).getNodeName();
                    if (!entryName.equals("Inventory")) {
                        System.err.println("Unexpected node found: " + entryName);
                        return;
                    }

                    // Get some named nodes
                    fcltNetwork = (Element) inventoryList.item(j);
                    String inventoryItemID = fcltNetwork.getElementsByTagName("ItemID").item(0).getTextContent();
                    String inventoryQ = fcltNetwork.getElementsByTagName("Quantity").item(0).getTextContent();
{'fraction_non_alphanumeric': 0.10492980048559063, 'fraction_numerical': 0.0044336535416446745, 'mean_word_length': 1.6331295163979989, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, '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': '4084158', 'n_tokens_mistral': 2421, 'n_tokens_neox': 2284, 'n_words': 462}