<commit_before>#include "link-includes.h"

#include "word-tag.hpp"

/**
 *    Base class for all SAT encodings
 */
class SATEncoder
{
public:

  // Construct the encoder based on given sentence
  SATEncoder(Sentence sent, Parse_Options  opts)
    : _variables(new Variables(sent)), _solver(new Solver()),
      _opts(opts), _sent(sent)
  {
    _cost_cutoff = parse_options_get_disjunct_cost(opts);

    verbosity = opts->verbosity;
    debug = opts->debug;
    test = opts->test;

    // Preprocess word tags of the sentence
    build_word_tags();
  }

  virtual ~SATEncoder()
  {
    delete _variables;
    delete _solver;
  }

  // Create the formula from the sentence
  void encode();

  // Solve the formula, returning the next linkage.
  Linkage get_next_linkage();

  // Next linkage index in the linkage array
  LinkageIdx _next_linkage_index;

private:
  int verbosity;
  const char *debug;
  const char *test;

protected:

  /**
   *  Methods that generate various link-grammar constraints.
   */

  // Top-level method that generates satisfaction conditions for every
  // word in the sentence
  void generate_satisfaction_conditions();<commit_msg>SAT: Fixes a crash when no linkages are found<commit_after>#include "link-includes.h"

#include "word-tag.hpp"

/**
 *    Base class for all SAT encodings
 */
class SATEncoder
{
public:

  // Construct the encoder based on given sentence
  SATEncoder(Sentence sent, Parse_Options  opts)
    : _variables(new Variables(sent)), _solver(new Solver()),
      _opts(opts), _sent(sent)
  {
    _cost_cutoff = parse_options_get_disjunct_cost(opts);

    verbosity = opts->verbosity;
    debug = opts->debug;
    test = opts->test;

    // Preprocess word tags of the sentence
    build_word_tags();
  }

  virtual ~SATEncoder()
  {
    delete _variables;
    delete _solver;
  }

  // Create the formula from the sentence
  void encode();

  // Solve the formula, returning the next linkage.
  Linkage get_next_linkage();

  // Next linkage index in the linkage array
  LinkageIdx _next_linkage_index = 0;

private:
  int verbosity;
  const char *debug;
  const char *test;

protected:

  /**
   *  Methods that generate various link-grammar constraints.
   */

  // Top-level method that generates satisfaction conditions for every
  // word in the sentence
  void generate_satisfaction_conditions();
{'fraction_non_alphanumeric': 0.09438775510204081, 'fraction_numerical': 0.00042517006802721087, 'mean_word_length': 3.3333333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5202878', 'n_tokens_mistral': 748, 'n_tokens_neox': 708, 'n_words': 222}