Ignore:
Timestamp:
2004-10-12T12:19:22+13:00 (20 years ago)
Author:
kjdon
Message:

some mods, not sure what they are. will tidy them up soon, but didn't want to leave the package uncompilable so committing this now

Location:
trunk/greenstone3-extensions/vishnu/src/vishnu/builder
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/greenstone3-extensions/vishnu/src/vishnu/builder/CollectionBuilder.java

    r8189 r8290  
    1212    String collDesc;
    1313    String indexer;
     14    boolean use_views;
    1415    long numDocs=0;
    1516   
    1617    private static void usage()
    1718    {
    18     System.out.println("java vishnu.builder.CollectionBuilder\n -collsHome (directory where collections live) \n -collection (directory name of collection)\n -name (descriptive name for collection) \n -description (collection description)\n -index (\"mg\" or \"luc\")");
     19    System.out.println("java vishnu.builder.CollectionBuilder\n -collsHome (directory where collections live) \n -collection (directory name of collection)\n -name (descriptive name for collection) \n -description (collection description)\n -index (\"mg\" or \"luc\")\n [-use_views]");
    1920    }
    2021   
     
    3233    String collDesc = "";
    3334    String indexer = null;
    34    
     35    boolean use_views = false;
    3536    int a = 0;
    3637    while( a < args.length ){
     
    4748        else if( args[a].equals("-index") )
    4849        indexer = args[++a];
     50        else if (args[a].equals("-use_views"))
     51        use_views = true;
    4952        a++;
    5053    }
     
    6669    String coll_home = collsHome + collID + File.separator;
    6770    //CollectionBuilder cb = new CollectionBuilder(site,collName,gHome,indexer);
    68     CollectionBuilder cb = new CollectionBuilder(coll_home,collID, collName,collDesc, indexer);
    69     }
    70    
    71    
    72    
    73     public CollectionBuilder(String coll_home, String coll_id, String coll_name,String coll_desc,  String ind)
     71    CollectionBuilder cb = new CollectionBuilder(coll_home,collID, collName,collDesc, indexer, use_views);
     72    }
     73   
     74   
     75   
     76    public CollectionBuilder(String coll_home, String coll_id, String coll_name,String coll_desc,  String ind, boolean use_views)
    7477    {
    7578    this.collHome = coll_home;
     
    7881    this.collDesc = coll_desc;
    7982    this.indexer = ind;
    80 
     83    this.use_views = use_views;
     84   
    8185    if (!setupCollection()) {
    8286        System.err.println("Couldn't setup the collection. Quitting build");
     
    144148        buffer.append("\" />");
    145149       
     150        // add in views
     151        if (use_views) {
     152
     153        }
    146154        out.print(buffer.toString());
    147155        out.close();
     
    185193    private void CKIndexing()
    186194    {
    187     CKWrapper ckw = new CKWrapper();
    188    
     195    //CKWrapper ckw = new CKWrapper();
     196    CKIndexer cki = new CKIndexer();
    189197    String in = collHome + "import"+File.separator;
    190198    String out = collHome + "building"+File.separator+"ck_index"+File.separator;
    191199   
    192     ckw.setCollectionName(collID);
    193     ckw.setOutputDirectory(out);
    194     ckw.setInputDirectory(in);
    195     ckw.startIndexing();
     200    cki.setCollectionName(collID);
     201    cki.setOutputDirectory(out);
     202    cki.setInputDirectory(in);
     203    cki.startIndexing();
    196204    }
    197205   
  • trunk/greenstone3-extensions/vishnu/src/vishnu/builder/Indexer.java

    r8189 r8290  
    11package vishnu.builder;
    22
     3import java.io.File;
    34abstract public class Indexer
    45{
    5     String name;
     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;
    620    String outputDir = null;
    721    String inputDir = null;
    822    String collName = null;
    9     //String GSDL3_HOME = null;
    10    
     23
    1124    public Indexer(String n)
    1225    {
     
    1528   
    1629   
    17 //     public void setRootDirectory(String root)
     30//     public void setUseViews(boolean use_v) {
     31//  use_views = use_v;
     32//     }
     33   
     34//     public void setIndexingType(int t)
    1835//     {
    19 //  GSDL3_HOME = root;
    20 //     }
    21 
    22 
     36//  type = t;
     37//     }   
    2338    public void setOutputDirectory(String s)
    2439    {
     
    2641    }
    2742   
     43//     public void setLimiter(String s)
     44//     {
     45//         limiter = s;
     46//     }
    2847   
    2948    public void setInputDirectory(String s)
     
    3857    }
    3958
     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   
    4088    abstract public void startIndexing();
    4189}
  • trunk/greenstone3-extensions/vishnu/src/vishnu/builder/IndexerGUI.java

    r8189 r8290  
    66import javax.swing.SpringLayout;
    77import java.io.File;
     8import vishnu.util.SpringUtilities;
    89
    910public class IndexerGUI {
     
    100101
    101102    //CollectionBuilder builder = new CollectionBuilder(dir,name,home,indexer);
    102     CollectionBuilder builder = new CollectionBuilder(coll_home, coll_id, coll_name, coll_desc, indexer);
     103    CollectionBuilder builder = new CollectionBuilder(coll_home, coll_id, coll_name, coll_desc, indexer, false); // no views for now - change this
    103104    output += "\n Indexing Finished";
    104105    ja.setText(output);
  • trunk/greenstone3-extensions/vishnu/src/vishnu/builder/LuceneWrapper.java

    r8189 r8290  
    6464   
    6565    public void startIndexing() {
    66 
    67     if( inputDir == null || outputDir == null ){
    68         usage();
    69         System.exit(0);
    70     }
    71 
    72     /* check if index dir exists */
    73     File in = new File(inputDir);
    74     if (!in.isDirectory()) {
    75         System.err.println("input directory ("+inputDir+") not a directory, exiting...");
    76         System.exit(0);
    77     }
    78 
    79     /**** check if output directory exists, if not create it ****/ 
    80         File f = new File(outputDir);
    81         if( !f.exists() ){
    82         try {
    83         f.mkdirs();
    84         } catch (Exception e) {
    85         System.err.println("Couldn't create output directory "+outputDir);
    86         System.err.println(e);
    87         System.exit(0);
    88         }
    89     }
     66    initialize();
    9067    try {
    9168        IndexWriter writer = new IndexWriter(outputDir, new StandardAnalyzer(), true);
    9269        // this is a bit of a hack putting import here
    93         indexFiles(writer, in, "import/");
     70        indexFiles(writer, new File(inputDir), "import/");
    9471        writer.optimize();
    9572        writer.close();
  • trunk/greenstone3-extensions/vishnu/src/vishnu/builder/MGWrapper.java

    r8189 r8290  
    6464    {
    6565
    66     if( inputDir == null || outputDir == null ){
    67         usage();
    68         System.exit(0);
    69     }
    70 
    71 
    72     /* check if index dir exists */
    73     File in = new File(inputDir);
    74     if (!in.isDirectory()) {
    75         System.err.println("input directory ("+inputDir+") not a directory, exiting...");
    76         System.exit(0);
    77     }
    78    
    79     /**** check if output directory exist, if not create it ****/
    80 
    81     File f = new File(outputDir);
    82         if( !f.exists() ){
    83         try {
    84         f.mkdirs();
    85         } catch (Exception e) {
    86         System.err.println("Couldn't create output directory "+outputDir);
    87         System.err.println(e);
    88         System.exit(0);
    89         }
    90     }
    91 
     66    initialize();
    9267    // new mg requires a .mg_getrc to work
    9368    // lets put it in the output dir
    94     File rc_file = new File(f, ".mg_getrc");
     69    File rc_file = new File(outputDir, ".mg_getrc");
    9570    if (!rc_file.exists()) {
    9671        // if its there, assume it is correct
Note: See TracChangeset for help on using the changeset viewer.