<commit_before>const WaveformPlaylist = require('waveform-playlist');

// const notes = [
//   {
//     begin: '0.000',
//     children: [],
//     end: '3.680',
//     id: 'f000001',
//     language: 'eng',
//     lines: [
//       '1',
//     ],
//   },
//   {
//     begin: '3.680',
//     children: [],
//     end: '10.880',
//     id: 'f000002',
//     language: 'eng',
//     lines: [
//       'bird one',
//     ],
//   },
//   {
//     begin: '10.880',
//     children: [],
//     end: '29.240',
//     id: 'f000003',
//     language: 'eng',
//     lines: [
//       'bird two',
//     ],
//   },
// ];

const actions = [
  {
    class: 'fa.fa-minus',
    title: 'Reduce annotation end by 0.010s',
    action: (annotation, i, annotations, opts) => {
      let next;
      const delta = 0.010;
      annotation.end -= delta;

      if (opts.linkEndpoints) {
        next = annotations[i + 1];
        next && (next.start -= delta);
      }
    },
  },
  {
    class: 'fa.fa-plus',
    title: 'Increase annotation end by 0.010s',
    action: (annotation, i, annotations, opts) => {
      let next;
      const delta = 0.010;
      annotation.end += delta;

      if (opts.linkEndpoints) {
        next = annotations[i + 1];
        next && (next.start += delta);
      }
    },
  },
  {
    class: 'fa.fa-scissors',
    title: 'Split annotation in half',
    action: (annotation, i, annotations) => {
      const halfDuration = (annotation.end - annotation.start) / 2;

      annotations.splice(i + 1, 0, {
        id: 'New',
        start: annotation.end - halfDuration,
        end: annotation.end,
        lines: ['----'],
        lang: 'en',
      });

      annotation.end = annotation.start + halfDuration;
    },
  },
  {
    class: 'fa.fa-trash',
    title: 'Delete annotation',
    action: (annotation, i, annotations) => {
      annotations.splice(i, 1);
    },
  },
];

export function loadLabels(data) {
  const notes = [];
  if (data.length > 0) {
    for (let i = 0; i < data.length; i++) {
      notes.push({
        begin: data[i].begin,
        end: data[i].end,
        id: `${i}`,
        language: 'eng',
        lines: [
          data[i].label,
        ],
      });
    }
  } else {
    notes.push({
      begin: '0.000',
      end: '5.000',
      id: 'New',
      language: 'eng',<commit_msg>Order label data before bind<commit_after>const WaveformPlaylist = require('waveform-playlist');

// const notes = [
//   {
//     begin: '0.000',
//     children: [],
//     end: '3.680',
//     id: 'f000001',
//     language: 'eng',
//     lines: [
//       '1',
//     ],
//   },
//   {
//     begin: '3.680',
//     children: [],
//     end: '10.880',
//     id: 'f000002',
//     language: 'eng',
//     lines: [
//       'bird one',
//     ],
//   },
//   {
//     begin: '10.880',
//     children: [],
//     end: '29.240',
//     id: 'f000003',
//     language: 'eng',
//     lines: [
//       'bird two',
//     ],
//   },
// ];

const actions = [
  {
    class: 'fa.fa-minus',
    title: 'Reduce annotation end by 0.010s',
    action: (annotation, i, annotations, opts) => {
      let next;
      const delta = 0.010;
      annotation.end -= delta;

      if (opts.linkEndpoints) {
        next = annotations[i + 1];
        next && (next.start -= delta);
      }
    },
  },
  {
    class: 'fa.fa-plus',
    title: 'Increase annotation end by 0.010s',
    action: (annotation, i, annotations, opts) => {
      let next;
      const delta = 0.010;
      annotation.end += delta;

      if (opts.linkEndpoints) {
        next = annotations[i + 1];
        next && (next.start += delta);
      }
    },
  },
  {
    class: 'fa.fa-scissors',
    title: 'Split annotation in half',
    action: (annotation, i, annotations) => {
      const halfDuration = (annotation.end - annotation.start) / 2;

      annotations.splice(i + 1, 0, {
        id: 'New',
        start: annotation.end - halfDuration,
        end: annotation.end,
        lines: ['----'],
        lang: 'en',
      });

      annotation.end = annotation.start + halfDuration;
    },
  },
  {
    class: 'fa.fa-trash',
    title: 'Delete annotation',
    action: (annotation, i, annotations) => {
      annotations.splice(i, 1);
    },
  },
];

export function loadLabels(data) {
  data.sort((a, b) => (a.start < b.start) ? -1 : 1);

  const notes = [];
  if (data.length > 0) {
    for (let i = 0; i < data.length; i++) {
      notes.push({
        begin: data[i].begin,
        end: data[i].end,
        id: `${i}`,
        language: 'eng',
        lines: [
          data[i].label,
        ],
      });
    }
  } else {
    notes.push({
      begin: '0.000',
      end: '5.000',
      id: 'New',
      language: 'eng',
{'fraction_non_alphanumeric': 0.19847166206750158, 'fraction_numerical': 0.033538526852048396, 'mean_word_length': 1.6442199775533108, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 14, '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': '6842138', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1622, 'n_words': 363}