File Open Error on Probablities Format

The engine.
Post Reply
xavier7179
Posts: 10
Joined: Tue Feb 17, 2015 9:36 am

File Open Error on Probablities Format

Post by xavier7179 »

Hello,

I'm working with SMILE libraries (on OSX 10.10) trying to open a .xdsl model file created using GENIE on a Windows VM. I got stuck with an error in the probability format since GENIE exports probabilities with the '.' and the library function seems to expected them with the ',' character. Is it something that I can control in the library somehow? The actual solution consists in changing them manually, that goes in the wrong direction without saying.

Thanks.
Ale
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: File Open Error on Probablities Format

Post by shooltz[BayesFusion] »

Try adding the following line just before DSL_network::ReadFile call:

Code: Select all

setlocale(LC_NUMERIC, "C");
If this solves the problem, you can ensure that your locale settings are preserved by using this class (this is actually internal part of jSMILE):

Code: Select all

/* 
example usage:
{
    // block to ensure c'tor and d'tor run
    DefLocaleCtx lctx;
    res = net.ReadFile(filename);
}

*/


class DefLocaleCtx
{
public:
	DefLocaleCtx();
	~DefLocaleCtx();
private:
	std::string defLocale;
};

DefLocaleCtx::DefLocaleCtx()
{
	char *loc = setlocale(LC_NUMERIC, NULL);
	if (NULL != loc)
	{
		defLocale = loc;
	}
	setlocale(LC_NUMERIC, "C");
}

DefLocaleCtx::~DefLocaleCtx()
{
	if (!defLocale.empty())
	{
		setlocale(LC_NUMERIC, defLocale.c_str());
	}
}
xavier7179
Posts: 10
Joined: Tue Feb 17, 2015 9:36 am

Re: File Open Error on Probablities Format

Post by xavier7179 »

Yes, it works just fine!

Thanks for solving my issue.
Post Reply