<commit_before>class Article < ActiveRecord::Base
  default_scope { where("nr is not null") }
  default_scope { order(:nr) }

  belongs_to :first_letter
  has_many :logs

  belongs_to :root_article, class_name: "Article", foreign_key: "root_id"
  has_many   :sub_articles, class_name: "Article", foreign_key: "root_id"

  before_save do |a|
    a.ar_inf_wo_vowels = Article.remove_vowels(a.ar_inf)
    a.ar_inf_wo_vowels_n_hamza = Article.remove_hamza(a.ar_inf_wo_vowels)
  end

  after_create do |a|
    if Article.where(:nr => a.nr).count > 1
      Article.where(["nr >= ? AND id <> ?", a.nr, a.id]).update_all("nr = nr + 1")
    end
  end

  before_save do |a|
    if !a.is_root && !a.root_id<commit_msg>stripping \r's in translation before save<commit_after>class Article < ActiveRecord::Base
  default_scope { where("nr is not null") }
  default_scope { order(:nr) }

  belongs_to :first_letter
  has_many :logs

  belongs_to :root_article, class_name: "Article", foreign_key: "root_id"
  has_many   :sub_articles, class_name: "Article", foreign_key: "root_id"

  before_save do |a|
    a.ar_inf_wo_vowels = Article.remove_vowels(a.ar_inf)
    a.ar_inf_wo_vowels_n_hamza = Article.remove_hamza(a.ar_inf_wo_vowels)
    a.translation.gsub!(/\r/, "")
  end

  after_create do |a|
    if Article.where(:nr => a.nr).count > 1
      Article.where(["nr >= ? AND id <> ?", a.nr, a.id]).update_all("nr = nr + 1")
    end
  end

  before_save do |a|
    if !a.is_root && !a.root_id
{'fraction_non_alphanumeric': 0.13617886178861788, 'fraction_numerical': 0.0027100271002710027, 'mean_word_length': 3.9233333333333333, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '729559', 'n_tokens_mistral': 597, 'n_tokens_neox': 577, 'n_words': 117}