Skip to content

Commit

Permalink
Hopefully fixes static serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed May 4, 2012
1 parent e0cb338 commit c688796
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/shogun/ui/GUIClassifier.cpp
Expand Up @@ -64,6 +64,8 @@
#include <shogun/classifier/svm/SVMSGD.h>
#include <shogun/classifier/svm/WDSVMOcas.h>

#include <shogun/io/SerializableAsciiFile.h>

using namespace shogun;

CGUIClassifier::CGUIClassifier(CSGInterface* ui_)
Expand Down Expand Up @@ -834,18 +836,19 @@ bool CGUIClassifier::load(char* filename, char* type)
if (new_classifier(type))
{
FILE* model_file=fopen(filename, "r");
CSerializableAsciiFile* ascii_file = new CSerializableAsciiFile(model_file,'r');

if (model_file)
if (ascii_file)
{
if (classifier && classifier->load(model_file))
if (classifier && classifier->load_serializable(ascii_file))
{
SG_DEBUG("file successfully read.\n");
result=true;
}
else
SG_ERROR("SVM/Classifier creation/loading failed on file %s.\n", filename);

fclose(model_file);
delete ascii_file;
}
else
SG_ERROR("Opening file %s failed.\n", filename);
Expand All @@ -866,17 +869,18 @@ bool CGUIClassifier::save(char* param)
if (classifier)
{
FILE* file=fopen(param, "w");
CSerializableAsciiFile* ascii_file = new CSerializableAsciiFile(file,'w');

if ((!file) || (!classifier->save(file)))
if ((!ascii_file) || (!classifier->save_serializable(ascii_file)))
printf("writing to file %s failed!\n", param);
else
{
printf("successfully written classifier into \"%s\" !\n", param);
result=true;
}

if (file)
fclose(file);
if (ascii_file)
delete ascii_file;
}
else
SG_ERROR("create classifier first\n");
Expand Down

0 comments on commit c688796

Please sign in to comment.