<commit_before>var CursorMaintainer = (function () {
  'use strict';

  var layer,          // A statistical approach configured per format.
      retrospective,  // Format-independent statistical cursor maintenance.
      costFunctions;  // Cost functions for the retrospective approach.


  //--- Meta approach: Wherein we reimplement the format with
  //  elementary operations on a text-with-cursor object.

  function TextWithCursor(text, cursor) {
    this.text = text || '';
    this.cursor = cursor || 0;
  }

  TextWithCursor.prototype.length = function () {
    return this.text.length;
  };
   
  // TextCursor.read gets one character by default, several if specified.
  TextWithCursor.prototype.read = function (begin, length) {
    if (length === undefined) {
      length = 1;
    }
    if (length <= 0) {
      return;
    }
    return this.text.substring(begin, begin + length);
  };

  // TextWithCursor.insert adds text at the specified insertion point and
  //  shifts the cursor if needed. The cursor is unchanged if it is at or to
  //  the left of the insertion point.
  TextWithCursor.prototype.insert = function (begin, subtext) {
    this.text = this.text.substring(0, begin) + subtext +
        this.text.substring(begin);
    if (this.cursor > begin) {
      this.cursor += subtext.length;
    }
  };

  // TextWithCursor.delete removes one character by default, several if
  //  specified, then shifts the cursor if needed. The cursor is unchanged<commit_msg>Give advice on applying the meta approach<commit_after>var CursorMaintainer = (function () {
  'use strict';

  // The CursorMaintainer module supports three cursor-maintenance approaches:
  //  meta, layer, and retrospective.

  var layer,          // A statistical approach configured per format.
      retrospective,  // Format-independent statistical cursor maintenance.
      costFunctions;  // Cost functions for the retrospective approach.


  //--- Meta approach: Wherein we reimplement the format with elementary
  //  operations on a text-with-cursor object. The elementary operations
  //  are read, insert, and delete. When an insert or delete operation is
  //  applied once, it moves the cursor in a straightforward manner. However,
  //  it is possible to apply a sequence of elementary operations that
  //  obfuscate the overall cursor movement. You want to avoid that. Be wary
  //  of deleting large spans of text around the cursor, because that's how
  //  you lose contextual information. Seek to delete the fewest possible
  //  characters to achieve the text transformation required by the format.

  // TextWithCursor constructs a text-with-cursor object.
  function TextWithCursor(text, cursor) {
    this.text = text || '';
    this.cursor = cursor || 0;
  }

  // TextWithCursor.length is a shortcut for accessing the text length.
  TextWithCursor.prototype.length = function () {
    return this.text.length;
  };
   
  // TextCursor.read gets one character by default, several if specified.
  TextWithCursor.prototype.read = function (begin, length) {
    if (length === undefined) {
      length = 1;
    }
    if (length <= 0) {
      return;
    }
    return this.text.substring(begin, begin + length);
  };

  // TextWithCursor.insert adds text at the specified insertion point and
  //  shifts the cursor if needed. The cursor is unchanged if it is at or to
  //  the left of the insertion point.
  TextWithCursor.prototype.insert = function (begin, subtext) {
    this.text = this.text.substring(0, begin) + subtext +
        this.text.substring(begin);
    if (this.cursor > begin) {
      this.cursor += subtext.length;
    }
  };

  // TextWithCursor.delete removes one character by default, several if
  //  specified, then shifts the cursor if needed. The cursor is unchanged
{'fraction_non_alphanumeric': 0.09100473435034193, 'fraction_numerical': 0.0021041557075223566, 'mean_word_length': 2.9368530020703933, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2816038', 'n_tokens_mistral': 1044, 'n_tokens_neox': 997, 'n_words': 391}