<commit_before>#include "menu/option_menu.h"
#include "menu/menu.h"
#include "menu/tab_menu.h"
#include "util/token.h"
#include "return_exception.h"
#include "util/token_exception.h"
#include "util/funcs.h"

OptionMenu::OptionMenu(Token *token) throw (LoadException): MenuOption(token, Event), _menu(0)
{
    // Check whether we have a menu or tabmenu
    if ( *token == "menu" )
    {
	_menu = new Menu();
    } else if (*token == "tabmenu"){
	_menu = new TabMenu();
    } else {
	throw LoadException("Not a menu");
    }
    // Set this menu as an option
    _menu->setAsOption(true);
    
    // Lets try loading from a file
    std::string temp;
    // Filename
    *token >> temp;
    if(temp=="name")
    {
	    token->resetToken();
	    _menu->load(token);
    }
    else _menu->load(Util::getDataPath() + temp);
    this->setText(_menu->getName());
    
    // Lets check if this menu is going bye bye
    if ( _menu->checkRemoval() ) setForRemoval(true);
}

OptionMenu::~OptionMenu()
{
	// Delete our menu
	if(_menu)delete _menu;
}<commit_msg>dont assume first token is "name"<commit_after>#include "menu/option_menu.h"
#include "menu/menu.h"
#include "menu/tab_menu.h"
#include "util/token.h"
#include "return_exception.h"
#include "util/token_exception.h"
#include "util/funcs.h"
#include "globals.h"

OptionMenu::OptionMenu(Token *token) throw (LoadException):
MenuOption(token, Event),
_menu(0){
    // Check whether we have a menu or tabmenu
    if ( *token == "menu" ){
	_menu = new Menu();
    } else if (*token == "tabmenu"){
	_menu = new TabMenu();
    } else {
	throw LoadException("Not a menu");
    }
    // Set this menu as an option
    _menu->setAsOption(true);
    
    /*
    // Lets try loading from a file
    std::string temp;
    // Filename
    *token >> temp;
    */

    if (token->numTokens() == 1){
        std::string temp;
        *token >> temp;
        _menu->load(Util::getDataPath() + temp);
    } else {
        _menu->load(token);
    }

    this->setText(_menu->getName());
    
    // Lets check if this menu is going bye bye
    if ( _menu->checkRemoval() ) setForRemoval(true);
}

OptionMenu::~OptionMenu()
{
	// Delete our menu
	if(_menu)delete _menu;
}
{'fraction_non_alphanumeric': 0.15810995002271694, 'fraction_numerical': 0.0013630168105406633, 'mean_word_length': 3.0403669724770643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '1845330', 'n_tokens_mistral': 763, 'n_tokens_neox': 755, 'n_words': 192}