GUILabels.cpp

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2008 Soeren Sonnenburg
00008  * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #include <shogun/ui/GUILabels.h>
00012 #include <shogun/ui/SGInterface.h>
00013 
00014 #include <shogun/lib/config.h>
00015 #include <shogun/io/SGIO.h>
00016 #include <shogun/io/AsciiFile.h>
00017 #include <shogun/features/Labels.h>
00018 
00019 #include <string.h>
00020 
00021 using namespace shogun;
00022 
00023 CGUILabels::CGUILabels(CSGInterface* ui_)
00024 : CSGObject(), ui(ui_), train_labels(NULL), test_labels(NULL)
00025 {
00026 }
00027 
00028 CGUILabels::~CGUILabels()
00029 {
00030     SG_UNREF(train_labels);
00031     SG_UNREF(test_labels);
00032 }
00033 
00034 bool CGUILabels::load(char* filename, char* target)
00035 {
00036     CLabels* labels=NULL;
00037 
00038     if (strncmp(target, "TEST", 4)==0)
00039         labels=test_labels;
00040     else if (strncmp(target, "TRAIN", 5)==0)
00041         labels=train_labels;
00042     else
00043         SG_ERROR("Invalid target %s.\n", target);
00044 
00045     if (labels)
00046     {
00047         SG_UNREF(labels);
00048         CAsciiFile* file=new CAsciiFile(filename);
00049         labels=new CLabels(file);
00050 
00051         if (labels)
00052         {
00053             if (strncmp(target, "TEST", 4)==0)
00054                 set_test_labels(labels);
00055             else
00056                 set_train_labels(labels);
00057 
00058             return true;
00059         }
00060         else
00061             SG_ERROR("Loading labels failed.\n");
00062 
00063         SG_UNREF(file);
00064     }
00065 
00066     return false;
00067 }
00068 
00069 bool CGUILabels::save(char* param)
00070 {
00071     bool result=false;
00072     return result;
00073 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation