<commit_before>package io.reporters;

import core.Path;
import core.Protocol;
import core.topology.Link;
import core.topology.Network;
import core.topology.Node;
import core.topology.Topology;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import simulators.Simulator;
import simulators.data.*;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Generates reports in CSV format.
 */
public class CSVReporter implements Reporter {

    private static final char DELIMITER = ';';

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     *  Private fields
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    private final File baseOutputFile;  // path with the base file name for the output

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     *  Private fields
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    private int simulationCounter = 0;                     // counts the simulations
    private boolean isCountsFileMissingHeaders = true;     // indicates if the counts file is missing the headers
    private boolean isDetectionsFileMissingHeaders = true; // indicates if the detections file is missing the headers
    private boolean isDeploymentsFileMissingHeaders = true; // indicates if the deployments file is missing the headers

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     *  Constructors
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    /**
     * Constructs a reporter associating the output file.
     *
     * @param baseOutputFile file to output report to.
     */
    public CSVReporter(File baseOutputFile) throws IOException {
        this.baseOutputFile = baseOutputFile;
    }

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     *  Public interface - Write methods from teh Reporter Interface
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    /**
     * Writes a summary of the simulation. Containing basic information about the topology and the simulation
     * parameters.
     */
    public void writeSummary(Topology topology, int destinationId, int minDelay, int maxDelay, Protocol protocol,
                             Simulator simulator) throws IOException {

        Network network = topology.getNetwork();

        try (CSVPrinter csvPrinter = getSummaryFilePrinter()) {
            csvPrinter.printRecord("Policy", topology.getPolicy());
            csvPrinter.printRecord("Node Count", network.getNodeCount());
            csvPrinter.printRecord("Link Count", network.getLinkCount());
            csvPrinter.printRecord("Destination", destinationId);
            csvPrinter.printRecord("Message Delay", minDelay, maxDelay);
            csvPrinter.printRecord("Protocol", protocol);
            csvPrinter.printRecord("Simulation Type", simulator);
        }
    }

    /**
     * Writes that data from the data set to the current output file.
     *
     * @param dataSet data set to write to the output file.
     */
    @Override
    public void write(BasicDataSet dataSet) throws IOException {
        mainWrite(dataSet, null, null, null);
    }<commit_msg>added the number of simulations to the summary (still has compile errors)<commit_after>package io.reporters;

import core.Path;
import core.Protocol;
import core.topology.Link;
import core.topology.Network;
import core.topology.Node;
import core.topology.Topology;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import simulators.Simulator;
import simulators.data.*;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Generates reports in CSV format.
 */
public class CSVReporter implements Reporter {

    private static final char DELIMITER = ';';

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     *  Private fields
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    private final File baseOutputFile;  // path with the base file name for the output

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     *  Private fields
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    private int simulationCounter = 0;                     // counts the simulations
    private boolean isCountsFileMissingHeaders = true;     // indicates if the counts file is missing the headers
    private boolean isDetectionsFileMissingHeaders = true; // indicates if the detections file is missing the headers
    private boolean isDeploymentsFileMissingHeaders = true; // indicates if the deployments file is missing the headers

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     *  Constructors
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    /**
     * Constructs a reporter associating the output file.
     *
     * @param baseOutputFile file to output report to.
     */
    public CSVReporter(File baseOutputFile) throws IOException {
        this.baseOutputFile = baseOutputFile;
    }

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     *  Public interface - Write methods from the Reporter Interface
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    /**
     * Writes a summary of the simulation. Containing basic information about the topology and the simulation
     * parameters.
     */
    public void writeSummary(Topology topology, int destinationId, int minDelay, int maxDelay, Protocol protocol,
                             Simulator simulator) throws IOException {

        Network network = topology.getNetwork();

        try (CSVPrinter csvPrinter = getSummaryFilePrinter()) {
            csvPrinter.printRecord("Policy", topology.getPolicy());
            csvPrinter.printRecord("Node Count", network.getNodeCount());
            csvPrinter.printRecord("Link Count", network.getLinkCount());
            csvPrinter.printRecord("Destination", destinationId);
            csvPrinter.printRecord("Message Delay", minDelay, maxDelay);
            csvPrinter.printRecord("Protocol", protocol);
            csvPrinter.printRecord("Simulation Type", simulator);
            csvPrinter.printRecord("Simulation Count", simulationCounter);
        }
    }

    @Override
    public void write(BasicDataSet dataSet) throws IOException {
        mainWrite(dataSet, null, null, null);
    }
{'fraction_non_alphanumeric': 0.16720343531937734, 'fraction_numerical': 0.00026838432635534085, 'mean_word_length': 2.227804244261585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 112, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1536833', 'n_tokens_mistral': 2345, 'n_tokens_neox': 2266, 'n_words': 466}