<commit_before>require 'json'

require 'mumukit'
require 'mumukit/inspection'

require_relative './with_swipl'

class Mumukit::Inspection::PlainInspection
  def to_term
    "inspection('#{type}')"
  end
end

class Mumukit::Inspection::TargetedInspection
  def to_term
    "inspection('#{type}','#{target}')"
  end
end

class Mumukit::Inspection::NegatedInspection
  def to_term
    "not(#{@inspection.to_term})"
  end
end

class ExpectationsRunner
  include Mumukit
  include WithSwipl

  def run_expectations!(expectations, content)
    terms = expectations_to_terms(expectations)

    file = Tempfile.new('mumuki.expectations')
    file.write(content)
    file.close

    command = "echo \"'#{file.path}'. #{terms}.\" |  #{swipl_path} -q -g main -s expectations/main.pl"
    JSON.parse %x{#{command}}
  end
<commit_msg>Using -t and -f instead of -s and -g<commit_after>require 'json'

require 'mumukit'
require 'mumukit/inspection'

require_relative './with_swipl'

class Mumukit::Inspection::PlainInspection
  def to_term
    "inspection('#{type}')"
  end
end

class Mumukit::Inspection::TargetedInspection
  def to_term
    "inspection('#{type}','#{target}')"
  end
end

class Mumukit::Inspection::NegatedInspection
  def to_term
    "not(#{@inspection.to_term})"
  end
end

class ExpectationsRunner
  include Mumukit
  include WithSwipl

  def run_expectations!(expectations, content)
    terms = expectations_to_terms(expectations)

    file = Tempfile.new('mumuki.expectations')
    file.write(content)
    file.close

    command = "echo \"'#{file.path}'. #{terms}.\" |  #{swipl_path} -q -t main -f expectations/main.pl"
    JSON.parse %x{#{command}}
  end

{'fraction_non_alphanumeric': 0.13573573573573575, 'fraction_numerical': 0.0, 'mean_word_length': 4.462295081967213, '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': '5255745', 'n_tokens_mistral': 613, 'n_tokens_neox': 604, 'n_words': 122}