<commit_before>/*!
 *  \file SimpleUI.h
 *	\brief Utilities kernel to provide a simpler user interface through yaml input files
 *  \author <NAME>
 *	\date 01/19/2017
 *	\copyright This kernel was designed and built at the Georgia Institute
 *             of Technology by <NAME> for PhD research in the area
 *             of adsorption and surface science and was developed for use
 *			   by Idaho National Laboratory and Oak Ridge National Laboratory
 *			   engineers and scientists. Portions Copyright (c) 2017, all
 *             rights reserved.
 *
 *			   <NAME> does not claim any ownership or copyright to the
 *			   MOOSE framework in which these kernels are constructed, only
 *			   the kernels themselves. The MOOSE framework copyright is held
 *			   by the Battelle Energy Alliance, LLC (c) 2010, all rights reserved.
 */

#include "SimpleUI.h"

/// Function to return true if the file extension of the given data is .yml
bool isYamlFile(char argv[])
{
	std::string arg = argv;
	if((arg.substr(arg.find_last_of(".") + 1) == "yml") || (arg.substr(arg.find_last_of(".") + 1) == "yaml"))
		return true;
	else
		return false;
}

/// Execute the simple user interface to read yaml files and create DGOSPREY input files
int exec_SimpleUI(char *file)
{
	//Declarations
	int success = 0;
	std::string arg = file;
	SimpleUI sui;
	
	// Create a blank digital MOOSE input file with default and required information
	sui.createMooseBlank();
	
	//Read the input file
	success = sui.readInputFile(file);
	if (success != 0)
	{
		mError(read_error);
		return -1;
	}
	
	//create example file (replace with real file)
	sui.createExample();
	
	//Create output file
	std::strcpy (file, ((arg.erase(arg.find_last_of(".") + 1)).append("i")).c_str());
	sui.writeOutputFile(file);
	
	//sui.DisplayInput();
	//sui.DisplayOutput();
	
	return 0;
}

//Default constructor
SimpleUI::SimpleUI()
{
}

//Default destructor
SimpleUI::~SimpleUI()
{
}

//Function to read a given input file
int SimpleUI::readInputFile(const char *file)
{
	return this->yaml_input.executeYamlRead(file);
}

// Function to write MOOSE input file
int SimpleUI::writeOutputFile(const char *file)
{
	//Declarations
	int success = 0;<commit_msg>Preparing to add the interface from yaml to moose.<commit_after>/*!
 *  \file SimpleUI.h
 *	\brief Utilities kernel to provide a simpler user interface through yaml input files
 *  \author <NAME>
 *	\date 01/19/2017
 *	\copyright This kernel was designed and built at the Georgia Institute
 *             of Technology by <NAME> for PhD research in the area
 *             of adsorption and surface science and was developed for use
 *			   by Idaho National Laboratory and Oak Ridge National Laboratory
 *			   engineers and scientists. Portions Copyright (c) 2017, all
 *             rights reserved.
 *
 *			   <NAME> does not claim any ownership or copyright to the
 *			   MOOSE framework in which these kernels are constructed, only
 *			   the kernels themselves. The MOOSE framework copyright is held
 *			   by the Battelle Energy Alliance, LLC (c) 2010, all rights reserved.
 */

#include "SimpleUI.h"

/// Function to return true if the file extension of the given data is .yml
bool isYamlFile(char argv[])
{
	std::string arg = argv;
	if((arg.substr(arg.find_last_of(".") + 1) == "yml") || (arg.substr(arg.find_last_of(".") + 1) == "yaml"))
		return true;
	else
		return false;
}

/// Execute the simple user interface to read yaml files and create DGOSPREY input files
int exec_SimpleUI(char *file)
{
	//Declarations
	int success = 0;
	std::string arg = file;
	SimpleUI sui;
	
	// Create a blank digital MOOSE input file with default and required information
	sui.createMooseBlank();
	
	//Read the input file
	success = sui.readInputFile(file);
	if (success != 0)
	{
		mError(read_error);
		return -1;
	}
	
	//Check input file for success flags
	
	//Perform preprocessing for finalization of MOOSE YamlWrapper object
	
	//Create the MOOSE YamlWrapper Object
	
	//create example file (replace with real file)
	sui.createExample();
	
	//Create output file for MOOSE
	std::strcpy (file, ((arg.erase(arg.find_last_of(".") + 1)).append("i")).c_str());
	sui.writeOutputFile(file);
	
	return 1;
}

//Default constructor
SimpleUI::SimpleUI()
{
}

//Default destructor
SimpleUI::~SimpleUI()
{
}

//Function to read a given input file
int SimpleUI::readInputFile(const char *file)
{
	return this->yaml_input.executeYamlRead(file);
}

// Function to write MOOSE input file
int SimpleUI::writeOutputFile(const char *file)
{
	//Declarations
	int success = 0;
{'fraction_non_alphanumeric': 0.10628972167433706, 'fraction_numerical': 0.01051939513477975, 'mean_word_length': 3.4833005893909625, 'pattern_counts': {'":': 0, '<': 9, '<?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': '7351203', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1380, 'n_words': 518}