-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraw2t.c
More file actions
62 lines (51 loc) · 1.34 KB
/
Copy pathraw2t.c
File metadata and controls
62 lines (51 loc) · 1.34 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
55
56
57
58
59
60
61
62
/*
Tokenizes all content within the <DOC> tags of a TREC document,
excluding the markup tags, and the document-id.
Spaces, punctuations and special characters are treated as
token-separators.
Letters are converted to lower case.
*/
#include "cw.h"
#include "parser.h"
#include "tfile.h"
#include "txt.h"
#include <kak/eprintf.h>
#include <kak/kcommon.h>
#include <kak/khash.h>
#include <kak/klist.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void usage(char *progname) {
eprintf("usage: %s [-c] [-n] [-x] <in.txt >out.t\n", progname);
}
int main(int argc, char *argv[]) {
FILE *fplog;
TFile *tfile;
Parser *parser;
int c, n, x_min, x_max, q, size, bpack;
esetprogname(estrdup(argv[0]));
fplog = fopen(strcat(estrdup(argv[0]), "-error.log"), "w");
esetstream(fplog);
c = n = x_min = x_max = q = bpack = 0;
size = MB;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-c") == 0)
c = 1;
else if (strcmp(argv[i], "-n") == 0)
n = 1;
else if (strcmp(argv[i], "-x") == 0) {
x_min = 4;
x_max = 20;
} else {
/* process non-optional arguments here*/
}
}
parser = newparser('d', cwSMART, c, n, x_min, x_max);
tfile = parse(parser, stdin);
writeTFile(stdout, tfile);
fflush(stdout);
freeTFile(tfile);
fclose(fplog);
return 0;
}