1 | package vishnu.builder;
|
---|
2 |
|
---|
3 | import java.io.File;
|
---|
4 | abstract public class Indexer
|
---|
5 | {
|
---|
6 |
|
---|
7 | // views stuff
|
---|
8 | // public static final int DEFAULT = 0;
|
---|
9 | // public static final int DIP = 1;
|
---|
10 | // public static final int REG = 2;
|
---|
11 | // public static final int LEM = 3;
|
---|
12 | // public static final int SYN = 4;
|
---|
13 |
|
---|
14 | // public static final String[] types = new String[]{"full","dip","reg","lem","syn"};
|
---|
15 |
|
---|
16 | // boolean use_views = false;
|
---|
17 | // int type = -1;
|
---|
18 | String name = null;
|
---|
19 | //String limiter = null;
|
---|
20 | String outputDir = null;
|
---|
21 | String inputDir = null;
|
---|
22 | String collName = null;
|
---|
23 |
|
---|
24 | public Indexer(String n)
|
---|
25 | {
|
---|
26 | name = n;
|
---|
27 | }
|
---|
28 |
|
---|
29 |
|
---|
30 | // public void setUseViews(boolean use_v) {
|
---|
31 | // use_views = use_v;
|
---|
32 | // }
|
---|
33 |
|
---|
34 | // public void setIndexingType(int t)
|
---|
35 | // {
|
---|
36 | // type = t;
|
---|
37 | // }
|
---|
38 | public void setOutputDirectory(String s)
|
---|
39 | {
|
---|
40 | outputDir = s;
|
---|
41 | }
|
---|
42 |
|
---|
43 | // public void setLimiter(String s)
|
---|
44 | // {
|
---|
45 | // limiter = s;
|
---|
46 | // }
|
---|
47 |
|
---|
48 | public void setInputDirectory(String s)
|
---|
49 | {
|
---|
50 | inputDir = s;
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | public void setCollectionName(String c)
|
---|
55 | {
|
---|
56 | collName = c;
|
---|
57 | }
|
---|
58 |
|
---|
59 | // this should be called at the start of startIndexing()
|
---|
60 | protected void initialize() {
|
---|
61 |
|
---|
62 | if( inputDir == null || outputDir == null ){
|
---|
63 | System.err.println("Input dir or output dir is null");
|
---|
64 | System.exit(0);
|
---|
65 | }
|
---|
66 |
|
---|
67 | /* check if index dir exists */
|
---|
68 | File in = new File(inputDir);
|
---|
69 | if (!in.isDirectory()) {
|
---|
70 | System.err.println("input directory ("+inputDir+") not a directory, exiting...");
|
---|
71 | System.exit(0);
|
---|
72 | }
|
---|
73 |
|
---|
74 | /**** check if output directory exists, if not create it ****/
|
---|
75 | File f = new File(outputDir);
|
---|
76 | if( !f.exists() ){
|
---|
77 | try {
|
---|
78 | f.mkdirs();
|
---|
79 | } catch (Exception e) {
|
---|
80 | System.err.println("Couldn't create output directory "+outputDir);
|
---|
81 | System.err.println(e);
|
---|
82 | System.exit(0);
|
---|
83 | }
|
---|
84 | }
|
---|
85 |
|
---|
86 | }
|
---|
87 |
|
---|
88 | abstract public void startIndexing();
|
---|
89 | }
|
---|