The ".jf" format is an ASCII data file format we use because of easy
portability (although the files are somewhat large) it contains:
line 1:
[number of classes [integer]] [number of features [integer]]
line 2...I+1:
[classnumber of pattern i [integer in [0;number of classes-1]]]
[features of pattern i [double]]
line I+2:
-1 (this is the end marker)
The features are floating point in [0,2] for "historical" reasons.
int read_ascii_file(char *name, int* numclass, int* dim, int* num, int *
classlabels, double ** content, int max)
{
FILE * file;
int class,i;
char buffer[128];
file = fopen (name,"r");
fscanf(file,"%d %d\n",numclass,dim);
fscanf(file,"%d ",&class);
*num=0;
while (class!=-1)
{
content[*num]=(double*)malloc((*dim)*sizeof(double));
classlabels[*num]=class;
for (i=0;i<*dim;i++)
{
if (fscanf(file, "%s", buffer) == EOF)
{
printf("%s: unexpected end of file\n","read_ascii_file");
exit(1);
}
content[*num][i]=(double)atof(buffer);
}
(*num)++;
if(*num>max)
{
printf("Only %d vectors are allowed here, \nchange input to
use more.\n",max);
exit(1);
}
fscanf(file,"\n %d ",&class);
}
fclose (file);
return 0;
}