<commit_before>part of esl;

/**
 * Class representing a reponse received from the FreeSWTICH event socket.
 */
class Response {

  static const String OK = '+OK';
  static const String ERROR = '-ERR';
  static const String UNKNOWN = '';

  final String rawBody;

  Response.fromPacketBody(String this.rawBody);

  /**
   * The status of the response. Can be either [OK], [ERROR] or [UNKNOWN].
   */
  String get status {
    String lastLine = this.rawBody.split('\n').last;

    if (lastLine.startsWith(OK)) {
      return OK;
    } else if (lastLine.startsWith(ERROR)) {
      return ERROR;
    } else {
      return UNKNOWN;
    }
  }

  /**
   * Reponses may carry the UUID of a channel.
   */
  String get channelUUID {
    String lastLine = this.rawBody.split('\n').last;

    if (lastLine.startsWith(OK)) {
      return lastLine.substring(OK.length, lastLine.length).trim();
    } else {
      throw new StateError(
          'Response does not carry channel information. '
          'Raw body: ${this.rawBody}');
    }
  }

  /**
   * String representation of a Response for debug purposes or
   * manual processing.
   */
  @override
  String toString() {
    return this.rawBody;<commit_msg>Added detection of USAGE response.<commit_after>part of esl;

/**
 * Class representing a reponse received from the FreeSWTICH event socket.
 */
class Response {

  /// String constants that map to responses.
  static const String OK = '+OK';
  static const String ERROR = '-ERR';
  static const String USAGE = '-USAGE';
  static const String UNKNOWN = '';

  final String rawBody;

  Response.fromPacketBody(String this.rawBody);

  /**
   * The status of the response. Can be either [OK], [ERROR] or [UNKNOWN].
   */
  String get status {
    String lastLine = this.rawBody.split('\n').last;

    if (lastLine.startsWith(OK)) {
      return OK;
    } else if (lastLine.startsWith(ERROR)) {
      return ERROR;
    } else if (lastLine.startsWith(USAGE)) {
      return ERROR;
    } else {
      return UNKNOWN;
    }
  }

  /**
   * Reponses may carry the UUID of a channel.
   */
  String get channelUUID {
    String lastLine = this.rawBody.split('\n').last;

    if (lastLine.startsWith(OK)) {
      return lastLine.substring(OK.length, lastLine.length).trim();
    } else {
      throw new StateError(
          'Response does not carry channel information. '
          'Raw body: ${this.rawBody}');
    }
  }

  /**
   * String representation of a Response for debug purposes or
   * manual processing.
   */
  @override
  String toString() {
    return this.rawBody;
{'fraction_non_alphanumeric': 0.11810411810411811, 'fraction_numerical': 0.0, 'mean_word_length': 2.6370056497175143, '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': '1032600', 'n_tokens_mistral': 785, 'n_tokens_neox': 776, 'n_words': 243}