<commit_before>from PyQt5.QtCore import Qt, QObject, QTimer, pyqtSignal
from keyboard.input import device
from keyboard import config
from keyboard.classification import cca
from random import randint

class Manager(QObject):
  flash_signal = pyqtSignal(bool)
  update_signal = pyqtSignal(int)

  def __init__(self, parent=None):
    super(Manager, self).__init__(parent)
    self.device = device.Device(callback=self.device_update, collect_time=config.TIME_FLASH_SEC, is_virtual=False)
    self.device.collect_signal.connect(self.device_update)
    self.paused = False

  def pause_handler(self, paused):
    self.paused = paused
    print("Paused: ", paused)
    if paused:
      self.stop()
    else:
      self.start()

  def start(self):
    if not self.paused:
      QTimer.singleShot(1000, Qt.PreciseTimer, self.device.collect)

  def stop(self):
    self.device.stop()

  def device_update(self, collecting, data=None):
    self.flash_signal.emit(collecting)
    if not collecting:
      sample, _quality = data
      result = cca.classify(sample, config.FREQ, config.TIME_FLASH_SEC)
      #result = randint(0, 3)
      self.update_signal.emit(result)
      if not self.paused:
        QTimer.singleShot(config.TIME_REST_SEC * 1000, Qt.PreciseTimer, self.device.collect)
<commit_msg>Start counting targets from 0 instead of 1<commit_after>from PyQt5.QtCore import Qt, QObject, QTimer, pyqtSignal
from keyboard.input import device
from keyboard import config
from keyboard.classification import cca
from random import randint

class Manager(QObject):
  flash_signal = pyqtSignal(bool)
  update_signal = pyqtSignal(int)

  def __init__(self, parent=None):
    super(Manager, self).__init__(parent)
    self.device = device.Device(callback=self.device_update, collect_time=config.TIME_FLASH_SEC, is_virtual=False)
    self.device.collect_signal.connect(self.device_update)
    self.paused = False

  def pause_handler(self, paused):
    self.paused = paused
    print("Paused: ", paused)
    if paused:
      self.stop()
    else:
      self.start()

  def start(self):
    if not self.paused:
      QTimer.singleShot(1000, Qt.PreciseTimer, self.device.collect)

  def stop(self):
    self.device.stop()

  def device_update(self, collecting, data=None):
    self.flash_signal.emit(collecting)
    if not collecting:
      sample, _quality = data
      result = cca.classify(sample, config.FREQ, config.TIME_FLASH_SEC) - 1
      print(result)
      #result = randint(0, 3)
      self.update_signal.emit(result)
      if not self.paused:
        QTimer.singleShot(config.TIME_REST_SEC * 1000, Qt.PreciseTimer, self.device.collect)

{'fraction_non_alphanumeric': 0.10056925996204934, 'fraction_numerical': 0.009487666034155597, 'mean_word_length': 3.899628252788104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3196651', 'n_tokens_mistral': 883, 'n_tokens_neox': 835, 'n_words': 189}