-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathclassdecode.cpp
More file actions
54 lines (48 loc) · 1.72 KB
/
classdecode.cpp
File metadata and controls
54 lines (48 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <string>
#include <iostream>
#include <getopt.h>
#include "classdecoder.h"
#include "config.h"
/*****************************
* Colibri Core
* by Maarten van Gompel
* Centre for Language Studies
* Radboud University Nijmegen
*
* http://proycon.github.io/colibri-core
*
* Licensed under GPLv3
*****************************/
using namespace std;
void usage() {
cerr << "Colibri Core " << VERSION << " - Class Decoder" << endl;
cerr << " by Maarten van Gompel, Language Machines, Centre for Language Studies, Radboud University Nijmegen" << endl;
cerr << " https://proycon.github.io/colibri-core" << endl << endl;
cerr << "Syntax: colibri-classdecode -f encoded-corpus -c class-file" << endl;
cerr << "Description: Decodes an encoded corpus" << endl << endl;
cerr << "Options:" << endl;
cerr << "\t-s start line number (default: 0)" << endl;
cerr << "\t-e end line number (default: infinite)" << endl;
}
int main(int argc, char* argv[]) {
string classfile = "";
string corpusfile = "";
unsigned int start = 0;
unsigned int end = 0;
char c;
while ((c = getopt(argc, argv, "c:f:hs:e:")) != -1)
switch (c) {
case 'c': classfile = optarg; break;
case 'f': corpusfile = optarg; break;
case 's': start = atoi(optarg); break;
case 'e': end = atoi(optarg); break;
case 'h': usage(); exit(0);
default: cerr << "Unknown option: -" << optopt << endl; abort();
}
if (classfile.empty() || corpusfile.empty()) {
usage();
exit(2);
}
ClassDecoder classdecoder = ClassDecoder(classfile);
classdecoder.decodefile(corpusfile, cout, start, end);
}