<commit_before>﻿using System.IO;
using Shience.Result;

namespace Shience.Publish
{
    public class FilePublisher : IPublisher
    {
        private readonly string _filePath;

        public FilePublisher(string path)
        {
            _filePath = path;
        } 

        public void Publish<TResult>(ExperimentResult<TResult> result)
        {
            using (var sw = new StreamWriter(_filePath, true))
            {
                //TODO: Need to add exception (if any) to publishing
                sw.WriteLine(result.TestName + "|" + result.ControlResult.Result + "|" + result.ControlResult.RunTime + "|" + result.CandidateResult.Result + "|" + result.CandidateResult.RunTime + "|" + result.Matched);
            }
        }
    }
}<commit_msg>Slightly more proper file publishing<commit_after>﻿using System;
using System.IO;
using System.Text;
using Shience.Result;

namespace Shience.Publish
{
    public class FilePublisher : IPublisher
    {
        private readonly string _filePath;

        public FilePublisher(string path)
        {
            _filePath = path;
        } 

        public void Publish<TResult>(ExperimentResult<TResult> result)
        {
            var sb = new StringBuilder();

            sb.Append(DateTime.UtcNow);
            sb.Append("|");
            sb.Append(result.TestName);
            sb.Append("|");
            sb.Append(result.ControlResult.Result);
            sb.Append("|");
            sb.Append(result.ControlResult.RunTime);
            sb.Append("|");
            sb.Append(result.CandidateResult.Result);
            sb.Append("|");
            sb.Append(result.CandidateResult.RunTime);
            sb.Append("|");
            sb.Append(result.Matched);
            sb.Append("|");
            sb.Append(result.Contexts);
            sb.Append("|");
            sb.Append(result.ControlResult.Exception);
            sb.Append("|");
            sb.Append(result.CandidateResult.Exception);

            foreach (var item in result.Contexts)
            {
                sb.Append(item);
            }

            using (var sw = new StreamWriter(_filePath, true))
            {
                sw.WriteLine(sb.ToString());
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.11664423508299686, 'fraction_numerical': 0.0, 'mean_word_length': 1.8015075376884422, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6184768', 'n_tokens_mistral': 620, 'n_tokens_neox': 598, 'n_words': 111}