<commit_before>extern crate clap;
extern crate quick_xml;

use clap::{Arg, App};

use std::fs::File;
use std::io::Write;
use std::io::BufReader;

use std::str;

use quick_xml::reader::Reader;
use quick_xml::events::Event;

fn main(){

    //Clap
    let matches = App::new("parse_ft_gfx_xml")
                        .version("0.1")
                        .about("Retrieve tags from factorytalk gfx-xml file!")
                        .author("<NAME>")
                        .arg(Arg::with_name("INPUT")
                            .help("Sets the input file to use")
                            .required(true)
                            .index(1))
                        .get_matches();    

    //Input file
    let file_name_in = matches.value_of("INPUT").unwrap();
    println!(); println!("Using input file: {}", file_name_in); println!();
    let input = File::open(file_name_in).unwrap();

    //Output file
    let file_name_out = format!("{}{}{}", "tagnames_", file_name_in, ".txt");
    let mut output = File::create(file_name_out).unwrap();

    //let input = File::open("MachineParameter_TabControl1.xml").unwrap();

    let buffered = BufReader::new(input);
    
    let mut reader = Reader::from_reader(buffered);
    reader.trim_text(true);

    let mut buf = Vec::new();

    let mut tag_names:Vec<String> = Vec::new(); //save all tags found during search here

    // The `Reader` does not implement `Iterator` because it outputs borrowed data (`Cow`s)
    loop {
        match reader.read_event(&mut buf) {
            // Ok(Event::Start(ref e)) => {

            //     match e.name() {
            //         b"group" => {
            //             let my_result = e.attributes().map(|a| a.unwrap()).collect::<Vec<_>>();

            //             for attrib in e.attributes() {

            //                 let my_attrib:quick_xml::events::attributes::Attribute = attrib.unwrap();

            //                 let my_key = str::from_utf8(my_attrib.key).unwrap();
            //                 let my_value = str::from_utf8(my_attrib.value).unwrap();
                            
            //                 if my_key == "isReferenceObject" {<commit_msg>clean-up<commit_after>extern crate clap;
extern crate quick_xml;

use clap::{Arg, App};

use std::fs::File;
use std::io::Write;
use std::io::BufReader;

use std::str;

use quick_xml::reader::Reader;
use quick_xml::events::Event;

fn main(){

    //Clap
    let matches = App::new("parse_ft_gfx_xml")
                        .version("0.1")
                        .about("Retrieve tags from factorytalk gfx-xml file!")
                        .author("<NAME>")
                        .arg(Arg::with_name("INPUT")
                            .help("Sets the input file to use")
                            .required(true)
                            .index(1))
                        .get_matches();    

    //Input file
    let file_name_in = matches.value_of("INPUT").unwrap();
    println!(); println!("Using input file: {}", file_name_in); println!();
    let input = File::open(file_name_in).unwrap();

    //Output file
    let file_name_out = format!("{}{}{}", "tagnames_", file_name_in, ".txt");
    let mut output = File::create(file_name_out).unwrap();

    //Create xml reader
    let buffered = BufReader::new(input);
    let mut reader = Reader::from_reader(buffered);
    reader.trim_text(true);

    let mut buf = Vec::new();

    let mut tag_names:Vec<String> = Vec::new(); //save all tags found during search here

    // The `Reader` does not implement `Iterator` because it outputs borrowed data (`Cow`s)
    loop {
        match reader.read_event(&mut buf) {
            // Ok(Event::Start(ref e)) => {

            //     match e.name() {
            //         b"group" => {
            //             let my_result = e.attributes().map(|a| a.unwrap()).collect::<Vec<_>>();

            //             for attrib in e.attributes() {

            //                 let my_attrib:quick_xml::events::attributes::Attribute = attrib.unwrap();

            //                 let my_key = str::from_utf8(my_attrib.key).unwrap();
            //                 let my_value = str::from_utf8(my_attrib.value).unwrap();
                            
            //                 if my_key == "isReferenceObject" {
{'fraction_non_alphanumeric': 0.14923646459972234, 'fraction_numerical': 0.0025451180009254974, 'mean_word_length': 1.8016850291639663, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3651696', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1240, 'n_words': 276}