Index: /branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Analysis/SentenceLogger.cs
===================================================================
--- /branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Analysis/SentenceLogger.cs	(revision 15910)
+++ /branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Analysis/SentenceLogger.cs	(revision 15911)
@@ -2,12 +2,13 @@
 using System.Diagnostics;
 using System.IO;
+using System.IO.Compression;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
 
 namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration {
-  class SentenceLogger : Item, IGrammarEnumerationAnalyzer {
+  public class SentenceLogger : Item, IGrammarEnumerationAnalyzer {
     private readonly string workingDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
     private readonly string columnDelimiter = ";";
-    private readonly string header = "hash;length;postfix;infix";
+    private readonly string header = "hash;length;infix";
 
     private string distinctSentencesFileName;
@@ -27,5 +28,4 @@
 
     public void Register(GrammarEnumerationAlgorithm algorithm) {
-      algorithm.Started += GrammarEnumerationAlgorithmOnStarted;
       algorithm.Stopped += GrammarEnumerationAlgorithmOnStopped;
       algorithm.ExceptionOccurred += GrammarEnumerationAlgorithmOnStopped;
@@ -36,5 +36,4 @@
 
     public void Deregister(GrammarEnumerationAlgorithm algorithm) {
-      algorithm.Started -= GrammarEnumerationAlgorithmOnStarted;
       algorithm.Stopped -= GrammarEnumerationAlgorithmOnStopped;
       algorithm.ExceptionOccurred -= GrammarEnumerationAlgorithmOnStopped;
@@ -44,12 +43,34 @@
     }
 
-    private void GrammarEnumerationAlgorithmOnStarted(object sender, EventArgs eventArgs) {
-      string datePostfix = $"_{DateTime.Now:yyyy-MM-dd_HH-mm}_TreeSize-{((GrammarEnumerationAlgorithm) sender).MaxComplexity}.csv";
+    private void GrammarEnumerationAlgorithmOnStopped(object sender, EventArgs eventArgs) {
+      distinctSentencesFileTrace.Close();
+      allSentencesFileTrace.Close();
+
+      // Remove duplicates afterwards using bash commands from the git bash
+      // string bashExecutable = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Programs\Git\git-bash.exe";
+      // 
+      // string commandCreate = $"echo \"{header}\" > {shortestDistinctSentencesFileName.Replace("\\", "/")}";
+      // string commandFill = $"sort -s {distinctSentencesFileName.Replace("\\", "/")} | uniq -w 10 >> {shortestDistinctSentencesFileName.Replace("\\", "/")}";
+      // 
+      // ProcessStartInfo startInfo = new ProcessStartInfo {
+      //   WindowStyle = ProcessWindowStyle.Hidden,
+      //   UseShellExecute = false,
+      //   CreateNoWindow = true,
+      //   FileName = bashExecutable,
+      //   RedirectStandardError = true,
+      //   RedirectStandardOutput = true,
+      //   Arguments = $"-c '{commandCreate};{commandFill}'"
+      // };
+      // Process.Start(startInfo);
+    }
+
+    private void Init(object sender) {
+      string datePostfix = $"_{DateTime.Now:yyyy-MM-dd_HH-mm}_TreeSize-{((GrammarEnumerationAlgorithm)sender).MaxComplexity}.csv.gz";
       distinctSentencesFileName = workingDir + @"\distinctSentences" + datePostfix;
       allSentencesFileName = workingDir + @"\allSentences" + datePostfix;
       shortestDistinctSentencesFileName = workingDir + @"\shortestDistinctSentences" + datePostfix;
 
-      distinctSentencesFileTrace = new TextWriterTraceListener(new FileStream(distinctSentencesFileName, FileMode.Create));
-      allSentencesFileTrace = new TextWriterTraceListener(new FileStream(allSentencesFileName, FileMode.Create));
+      distinctSentencesFileTrace = new TextWriterTraceListener(new GZipStream(new FileStream(distinctSentencesFileName, FileMode.Create), CompressionMode.Compress));
+      allSentencesFileTrace = new TextWriterTraceListener(new GZipStream(new FileStream(allSentencesFileName, FileMode.Create), CompressionMode.Compress));
       ((StreamWriter)distinctSentencesFileTrace.Writer).AutoFlush = true;
       ((StreamWriter)allSentencesFileTrace.Writer).AutoFlush = true;
@@ -58,39 +79,20 @@
     }
 
-    private void GrammarEnumerationAlgorithmOnStopped(object sender, EventArgs eventArgs) {
-      distinctSentencesFileTrace.Close();
-      allSentencesFileTrace.Close();
-
-      // Remove duplicates afterwards using bash commands from the git bash
-      string bashExecutable = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Programs\Git\git-bash.exe";
-
-      string commandCreate = $"echo \"{header}\" > {shortestDistinctSentencesFileName.Replace("\\", "/")}";
-      string commandFill = $"sort -s {distinctSentencesFileName.Replace("\\", "/")} | uniq -w 10 >> {shortestDistinctSentencesFileName.Replace("\\", "/")}";
-      
-      ProcessStartInfo startInfo = new ProcessStartInfo {
-        WindowStyle = ProcessWindowStyle.Hidden,
-        UseShellExecute = false,
-        CreateNoWindow = true,
-        FileName = bashExecutable,
-        RedirectStandardError = true,
-        RedirectStandardOutput = true,
-        Arguments = $"-c '{commandCreate};{commandFill}'"
-      };
-      Process.Start(startInfo);
-    }
-
     private void DistinctSentenceGenerated(object sender, PhraseAddedEventArgs phraseAddedEventArgs) {
+      if (distinctSentencesFileName == null) Init(sender);
       distinctSentencesFileTrace.WriteLine(ToCsvLine(
         ((uint)phraseAddedEventArgs.NewHash).ToString("D10"),
         phraseAddedEventArgs.NewPhrase.Count().ToString("D3"),
-        phraseAddedEventArgs.NewPhrase.ToString(),
+        //phraseAddedEventArgs.NewPhrase.ToString(),
         ((GrammarEnumerationAlgorithm)sender).Grammar.ToInfixString(phraseAddedEventArgs.NewPhrase)));
     }
 
+
     private void SentenceGenerated(object sender, PhraseAddedEventArgs phraseAddedEventArgs) {
+      if (allSentencesFileTrace == null) Init(sender);
       allSentencesFileTrace.WriteLine(ToCsvLine(
         ((uint)phraseAddedEventArgs.NewHash).ToString("D10"),
         phraseAddedEventArgs.NewPhrase.Count().ToString("D3"),
-        phraseAddedEventArgs.NewPhrase.ToString(),
+        //phraseAddedEventArgs.NewPhrase.ToString(),
         ((GrammarEnumerationAlgorithm)sender).Grammar.ToInfixString(phraseAddedEventArgs.NewPhrase)));
     }
