<commit_before>#ifndef STAN_SERVICES_SAMPLE_STANDALONE_GQS_HPP
#define STAN_SERVICES_SAMPLE_STANDALONE_GQS_HPP

#include <stan/callbacks/interrupt.hpp>
#include <stan/callbacks/logger.hpp>
#include <stan/callbacks/writer.hpp>
#include <stan/io/array_var_context.hpp>
#include <stan/services/error_codes.hpp>
#include <stan/services/util/create_rng.hpp>
#include <stan/services/util/gq_writer.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <boost/algorithm/string.hpp>
#include <string>
#include <vector>
#include <iostream>

namespace stan {
namespace services {

/**
 * Find the names, dimensions of the model parameters.
 * Assembles vectors of name, dimensions for the variables
 * declared in the parameters block.
 *
 * @tparam Model type of model
 * @param[in] model model to query
 * @param[in, out] param_names sequence of parameter names
 * @param[in, out] param_dimss sequence of variable dimensionalities
 */
template <class Model>
void get_model_parameters(const Model &model,
                          std::vector<std::string> &param_names,
                          std::vector<std::vector<size_t>> &param_dimss) {
  std::vector<std::string> param_cols;
  model.constrained_param_names(param_cols, false, false);
  std::string cur_name("");
  std::vector<std::string> splits;
  for (size_t i = 0; i < param_cols.size(); ++i) {
    boost::algorithm::split(splits, param_cols[i], boost::is_any_of("."));
    if (splits.size() == 1 || splits[0] != cur_name) {
      cur_name = splits[0];
      param_names.emplace_back(cur_name);
    }
  }
  size_t num_params = param_names.size();
  std::vector<std::vector<size_t>> dimss;
  model.get_dims(dimss);
  for (size_t i = 0; i < num_params; ++i) {
    param_dimss.emplace_back(dimss[i]);
  }
}
<commit_msg>fix dimension returning in get_model_parameters with zero sized parameters<commit_after>#ifndef STAN_SERVICES_SAMPLE_STANDALONE_GQS_HPP
#define STAN_SERVICES_SAMPLE_STANDALONE_GQS_HPP

#include <stan/callbacks/interrupt.hpp>
#include <stan/callbacks/logger.hpp>
#include <stan/callbacks/writer.hpp>
#include <stan/io/array_var_context.hpp>
#include <stan/services/error_codes.hpp>
#include <stan/services/util/create_rng.hpp>
#include <stan/services/util/gq_writer.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <boost/algorithm/string.hpp>
#include <string>
#include <vector>
#include <iostream>

namespace stan {
namespace services {

/**
 * Find the names, dimensions of the model parameters.
 * Assembles vectors of name, dimensions for the variables
 * declared in the parameters block.
 *
 * @tparam Model type of model
 * @param[in] model model to query
 * @param[in, out] param_names sequence of parameter names
 * @param[in, out] param_dimss sequence of variable dimensionalities
 */
template <class Model>
void get_model_parameters(const Model &model,
                          std::vector<std::string> &param_names,
                          std::vector<std::vector<size_t>> &param_dimss) {
  std::vector<std::string> param_cols;
  model.constrained_param_names(param_cols, false, false);
  std::string cur_name("");
  std::vector<std::string> splits;
  for (size_t i = 0; i < param_cols.size(); ++i) {
    boost::algorithm::split(splits, param_cols[i], boost::is_any_of("."));
    if (splits.size() == 1 || splits[0] != cur_name) {
      cur_name = splits[0];
      param_names.emplace_back(cur_name);
    }
  }
  std::vector<std::string> all_param_names;
  model.get_param_names(all_param_names);
  size_t num_params = param_names.size();
  std::vector<std::vector<size_t>> dimss;
  model.get_dims(dimss);
  for (int i = 0;i < param_names.size(); i++) {
    for (size_t j = i; j < all_param_names.size(); ++j) {
      if (param_names[i].compare(all_param_names[j]) == 0) {
        param_dimss.emplace_back(dimss[j]);
        break;
      }
    }   
  }
}

{'fraction_non_alphanumeric': 0.13709677419354838, 'fraction_numerical': 0.0028616024973985433, 'mean_word_length': 4.477207977207978, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 44, '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': '4659199', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1311, 'n_words': 279}