<commit_before>package swf.app;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import swf.accel.model.AccelerationData;
import swf.model.TimeSeries;
import swf.nnc.NearestNeighbourClassificator;
import swf.transformer.SubTransformer;

public class GestureDistanceInfo implements Evaluator {
  private NearestNeighbourClassificator<TimeSeries<AccelerationData>> nearestNeighbourClassificator;

  public GestureDistanceInfo(
      NearestNeighbourClassificator<TimeSeries<AccelerationData>> nearestNeighbourClassificator
  ) {
    this.nearestNeighbourClassificator = nearestNeighbourClassificator;
  }

  /**
   * Checks if the library gestures match the given gestures.
   */
  public String evaluate(List<TimeSeries<AccelerationData>> timeSeriesList) {
    Iterator<TimeSeries<AccelerationData>> iterator = timeSeriesList.iterator();
    String output = "";
    while (iterator.hasNext()) {
      output += this.evaluateTimeSeries(iterator.next()) + "\n";
    }
    return output;
  }

  private String evaluateTimeSeries(TimeSeries<AccelerationData> timeSeries) {
    LinkedList<TimeSeries<AccelerationData>> library =
        new LinkedList<TimeSeries<AccelerationData>>();
    LinkedList<TimeSeries<AccelerationData>> gestures =
        new LinkedList<TimeSeries<AccelerationData>>();
    for (int i = 1; i < 9; i++) {
      SubTransformer<AccelerationData> subTransformer =
          new SubTransformer<AccelerationData>("START " + i, "END " + i);
      library.add(subTransformer.transform(timeSeries));
      subTransformer = new SubTransformer<AccelerationData>("START " + (i + 8), "END " + (i + 8));
      gestures.add(subTransformer.transform(timeSeries));
    }
    String output = "";
    for (int i = 0; i < 8; i++) {
      TimeSeries<AccelerationData> gesture = gestures.get(i);
      output += i + " => " + library.indexOf(
          this.nearestNeighbourClassificator.searchNearestNeighbour(gesture, library)
      ) + "\n";
    }
    return output;
  }
}<commit_msg>format gesture info<commit_after>package swf.app;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import swf.accel.model.AccelerationData;
import swf.model.TimeSeries;
import swf.nnc.NearestNeighbourClassificator;
import swf.transformer.SubTransformer;

public class GestureDistanceInfo implements Evaluator {
  private NearestNeighbourClassificator<TimeSeries<AccelerationData>> nearestNeighbourClassificator;

  public GestureDistanceInfo(
      NearestNeighbourClassificator<TimeSeries<AccelerationData>> nearestNeighbourClassificator
  ) {
    this.nearestNeighbourClassificator = nearestNeighbourClassificator;
  }

  /**
   * Checks if the library gestures match the given gestures.
   */
  public String evaluate(List<TimeSeries<AccelerationData>> timeSeriesList) {
    Iterator<TimeSeries<AccelerationData>> iterator = timeSeriesList.iterator();
    String output = "    ____  _______       __\n"
        + "   / __ \\/_  __/ |     / /\n"
        + "  / / / / / /  | | /| / / \n"
        + " / /_/ / / /   | |/ |/ /  \n"
        + "/_____/ /_/    |__/|__/   \n"
        + "                          \n";
    String format = "| Record %d | %d | %d | %d | %d | %d | %d | %d | %d |\n";
    int recordIndex = 1;
    String top = "+----------+---+---+---+---+---+---+---+---+\n";
    output += top;
    while (iterator.hasNext()) {
      int[] result = this.evaluateTimeSeries(iterator.next());
      output += String.format(
          format,
          recordIndex,
          result[0],
          result[1],
          result[2],
          result[3],
          result[4],
          result[5],
          result[6],
          result[7]
      );
      recordIndex++;
    }
    return output + top;
  }

  private int[] evaluateTimeSeries(TimeSeries<AccelerationData> timeSeries) {
    LinkedList<TimeSeries<AccelerationData>> library =
        new LinkedList<TimeSeries<AccelerationData>>();
    LinkedList<TimeSeries<AccelerationData>> gestures =
        new LinkedList<TimeSeries<AccelerationData>>();
    for (int i = 1; i < 9; i++) {
      SubTransformer<AccelerationData> subTransformer =
          new SubTransformer<AccelerationData>("START " + i, "END " + i);
      library.add(subTransformer.transform(timeSeries));
      subTransformer = new SubTransformer<AccelerationData>("START " + (i + 8), "END " + (i + 8));
      gestures.add(subTransformer.transform(timeSeries));
    }
    int[] result = new int[8];
    for (int i = 0; i < 8; i++) {
      TimeSeries<AccelerationData> gesture = gestures.get(i);
      result[i] = library.indexOf(
          this.nearestNeighbourClassificator.searchNearestNeighbour(gesture, library)
      );
    }
    return result;
  }
}
{'fraction_non_alphanumeric': 0.1304255769637942, 'fraction_numerical': 0.004658056320135507, 'mean_word_length': 3.165784832451499, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6807488', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1433, 'n_words': 265}