about summary refs log tree commit diff stats
path: root/gen.cpp
diff options
context:
space:
mode:
authorFeffernoose <fefferburbia@gmail.com>2013-10-06 20:16:40 -0400
committerFeffernoose <fefferburbia@gmail.com>2013-10-06 20:16:40 -0400
commitd4b193e6e7fdefc66d9698337581b960c30844ea (patch)
treef8185611fae0bbc38ea896e596a194469db22b6e /gen.cpp
parent60561c9b95de1043979fbe59c93342175f9febd8 (diff)
downloadrawr-ebooks-d4b193e6e7fdefc66d9698337581b960c30844ea.tar.gz
rawr-ebooks-d4b193e6e7fdefc66d9698337581b960c30844ea.tar.bz2
rawr-ebooks-d4b193e6e7fdefc66d9698337581b960c30844ea.zip
Removed yamlcpp dependency from rawr-gen
rawr-gen now takes the input corpus as a command-line argument, so as to increase the ease-of-use. It also now shows a usage message if provided with a non-existent file or no argument.
Diffstat (limited to 'gen.cpp')
-rw-r--r--gen.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/gen.cpp b/gen.cpp index dc73e0f..e4a58e5 100644 --- a/gen.cpp +++ b/gen.cpp
@@ -7,18 +7,34 @@
7#include <cstdlib> 7#include <cstdlib>
8#include <fstream> 8#include <fstream>
9#include <iostream> 9#include <iostream>
10#include <unistd.h>
11#include <yaml-cpp/yaml.h>
12 10
13using namespace::std; 11using namespace::std;
14 12
15int main(int argc, char** args) 13int main(int argc, char** args)
16{ 14{
17 srand(time(NULL)); 15 srand(time(NULL));
18 16
19 YAML::Node config = YAML::LoadFile("config.yml"); 17 if (argc == 1)
20 18 {
21 ifstream infile(config["corpus"].as<std::string>().c_str()); 19 cout << "rawr-gen, version 1.0" << endl;
20 cout << "Usage: rawr-gen corpus-file" << endl;
21 cout << " where 'corpus-file' is the path to your input" << endl;
22
23 return 0;
24 }
25
26 ifstream infile(args[1]);
27 if (!infile)
28 {
29 cout << "rawr-gen, version 1.0" << endl;
30 cout << "Usage: rawr-gen corpus-file" << endl;
31 cout << " where 'corpus-file' is the path to your input" << endl;
32 cout << endl;
33 cout << "The file you specified does not exist." << endl;
34
35 return 0;
36 }
37
22 string corpus; 38 string corpus;
23 string line; 39 string line;
24 while (getline(infile, line)) 40 while (getline(infile, line))