Commit fc2de381 authored by Duc Cao's avatar Duc Cao

Allow Wapiti to take into account both file and folder as input

parent 5d67c91b
......@@ -45,6 +45,19 @@
#include "tools.h"
#include "trainers.h"
#include "wapiti.h"
#include <sys/stat.h>
bool is_file(const char* path) {
struct stat buf;
stat(path, &buf);
return S_ISREG(buf.st_mode);
}
bool is_dir(const char* path) {
struct stat buf;
stat(path, &buf);
return S_ISDIR(buf.st_mode);
}
/*******************************************************************************
* Training
......@@ -198,20 +211,22 @@ static void dolabel(mdl_t *mdl) {
if (file == NULL)
pfatal("cannot open input model file");
mdl_load(mdl, file);
// Open input and output files
/*FILE *fin = stdin, *fout = stdout;*/
/*if (mdl->opt->input != NULL) {*/
/*fin = fopen(mdl->opt->input, "r");*/
/*if (fin == NULL)*/
/*pfatal("cannot open input data file");*/
/*}*/
/*if (mdl->opt->output != NULL) {*/
/*fout = fopen(mdl->opt->output, "w");*/
/*if (fout == NULL)*/
/*pfatal("cannot open output data file");*/
/*}*/
if (mdl->opt->inputdir != NULL && is_file(mdl->opt->inputdir)) {
/*Open input and output files*/
FILE *fin = stdin, *fout = stdout;
fin = fopen(mdl->opt->inputdir, "r");
if (fin == NULL)
pfatal("cannot open input data file");
fout = fopen(mdl->opt->outputdir, "w");
if (fout == NULL)
pfatal("cannot open output data file");
tag_label(mdl, fin, fout);
fclose(fin);
fclose(fout);
}
// Open directory of input files
if (mdl->opt->inputdir != NULL && mdl->opt->outputdir != NULL) {
else if (mdl->opt->inputdir != NULL && mdl->opt->outputdir != NULL) {
DIR *dp;
struct dirent *ep;
dp = opendir (mdl->opt->inputdir);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment