<commit_before>/**
 * @file transition_map.h
 * @author <NAME>
 */

#include <cassert>
#include <fstream>

#include "io/binary.h"
#include "parser/transition_map.h"

namespace meta
{
namespace parser
{

transition_map::transition_map(const std::string& prefix)
{
    std::ifstream store{prefix + "/parser.trans", std::ios::binary};

    size_t num_trans;
    io::read_binary(store, num_trans);

    if (!store)
        throw exception{"malformed transitions model file"};

    transitions_.reserve(num_trans);
    for (size_t i = 0; i < num_trans; ++i)
    {
        if (!store)
            throw exception{"malformed transition model file (too few "
                            "transitions written)"};

        int trans_type;
        io::read_binary(store, trans_type);

        util::optional<transition> trans;
        if (trans_type == 0)
        {
            trans = transition{transition::type_t::SHIFT};
        }
        else if (trans_type == 1)
        {<commit_msg>Add check for nonexistent model file for parser::trainsition_map.<commit_after>/**
 * @file transition_map.h
 * @author <NAME>
 */

#include <cassert>
#include <fstream>

#include "io/binary.h"
#include "parser/transition_map.h"

namespace meta
{
namespace parser
{

transition_map::transition_map(const std::string& prefix)
{
    std::ifstream store{prefix + "/parser.trans", std::ios::binary};

    if (!store)
        throw exception{"missing transitions model file"};

    size_t num_trans;
    io::read_binary(store, num_trans);

    if (!store)
        throw exception{"malformed transitions model file"};

    transitions_.reserve(num_trans);
    for (size_t i = 0; i < num_trans; ++i)
    {
        if (!store)
            throw exception{"malformed transition model file (too few "
                            "transitions written)"};

        int trans_type;
        io::read_binary(store, trans_type);

        util::optional<transition> trans;
        if (trans_type == 0)
        {
            trans = transition{transition::type_t::SHIFT};
        }
        else if (trans_type == 1)
        {
{'fraction_non_alphanumeric': 0.12703739213806328, 'fraction_numerical': 0.0028763183125599234, 'mean_word_length': 2.7069271758436946, 'pattern_counts': {'":': 0, '<': 13, '<?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': '3925565', 'n_tokens_mistral': 640, 'n_tokens_neox': 620, 'n_words': 152}