<commit_before># Copyright (C) 2014  <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

{Emitter} = require 'event-kit'
_ = require 'underscore-plus'

module.exports =
# Stores a bunch of sorted predictions. Keeps track of the currently
# active predictions.
class PredictionList

  # Creates the initial prediction list.
  constructor: (predictions) ->
    @_predictions = []
    @_index = 0
    @emitter = new Emitter

    @setPredictions predictions if predictions?

  # Get the next prediction.
  next: -> @changeRelative +1

  # Get the previous prediction.
  prev: -> @changeRelative -1

  # Change the index by the given value.
  changeRelative: (amount) ->
    direction = switch
      when amount is 0 then 'beginning'
      when amount > 0 then 'next'
      else 'prev'

    index = @_index + amount<commit_msg>:bug: Fix lack of index change in PredictionList<commit_after># Copyright (C) 2014  <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

{Emitter} = require 'event-kit'
_ = require 'underscore-plus'

module.exports =
# Stores a bunch of sorted predictions. Keeps track of the currently
# active predictions.
class PredictionList

  # Creates the initial prediction list.
  constructor: (predictions) ->
    @_predictions = []
    @_index = 0
    @emitter = new Emitter

    @setPredictions predictions if predictions?

  # Get the next prediction.
  next: -> @changeRelative +1

  # Get the previous prediction.
  prev: -> @changeRelative -1

  # Change the index by the given value.
  changeRelative: (amount) ->
    direction = switch
      when amount is 0 then 'beginning'
      when amount > 0 then 'next'
      else 'prev'

    index = @_index += amount
{'fraction_non_alphanumeric': 0.0760495526496903, 'fraction_numerical': 0.006882312456985547, 'mean_word_length': 3.5564263322884013, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5186265', 'n_tokens_mistral': 801, 'n_tokens_neox': 764, 'n_words': 378}