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

modified to use the CKServer instead of jni based Cluster and Extractor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/greenstone3-extensions/vishnu/src/vishnu/server/VisServlet.java

    r8189 r8287  
    4141    final String INITIALIZATION_ACTION = "initialise";
    4242   
    43     protected Document doc=null;
    4443    protected String COLLS_HOME=null;
    45 
    46     DataBlock data = null;
     44   
    4745    Hashtable collH;
    4846
     
    8886    public void doPost(HttpServletRequest req, HttpServletResponse resp)
    8987    {
    90         DataBlock data = null;
    9188    Object obj;
    9289   
     
    131128        descriptions = search_engine.getDocDescriptions();
    132129        System.out.println(docNums.size() + " documents in VisServlet");
    133         Cluster c = new Cluster();
    134         String results = c.getCluster(collection_home,docNums);
    135         Packaging p = new Packaging();
    136         data = p.getDataPackage(results, descriptions);
    137         response.addElement(data);
     130        DataBlock data = generateDataBlock(collection_home, docNums, descriptions);
     131        if (data != null) {
     132            response.addElement(data);
     133        }
    138134        sendObject(resp,response);
    139135        search_engine = null;
    140         c = null;
    141         p = null;
     136        data = null;
     137        docNums = null;
     138        descriptions = null;
     139       
    142140        }
    143141        else if( action.equals(DOCUMENT_FETCH_ACTION) ){
     
    179177    Vector colls = new Vector();
    180178    collH = new Hashtable();
     179    Document doc = null;
    181180   
    182181    File dir = new File(COLLS_HOME);
     
    217216        }           
    218217    }
     218    doc = null;
    219219    return colls;
    220220    }
     221   
     222    private DataBlock generateDataBlock(String collection_home, Vector docNums, Vector descriptions) {
     223
     224    DataBlock data = new DataBlock();
     225
     226    CKServer ck_server = new CKServer(collection_home);
     227   
     228    /**** set data fields one by one and pass one what ever gets assembled ****/
     229       
     230    try{
     231       
     232        ck_server.setDescriptions(descriptions);
     233       
     234        /**** get candidate keywords ****/
     235       
     236        String[] keywords = ck_server.computeKeywords(docNums);
     237       
     238        data.words = keywords;
     239       
     240       
     241        /**** get sparse document * keyword matrix ****/
     242       
     243        SparseMatrix matrix = ck_server.getSparseMatrix(docNums);
     244       
     245        data.matrix = matrix;
     246       
     247       
     248        /**** get document indices, this is a subset of the original ****/
     249        /**** those without keywords are excluded                    ****/
     250       
     251        int[] docs = ck_server.getHitDocuments();
     252       
     253        data.docs = docs;
     254       
     255       
     256        String[] desc = ck_server.getHitDescriptions();
     257       
     258        data.descriptions = desc;
     259       
     260       
     261        /**** get 10 or so clusters ****/
     262       
     263        Vector[] clusters = ck_server.getClusters();
     264       
     265        data.clusters = clusters;
     266       
     267       
     268        double[][] centroids = ck_server.getCentroids();
     269       
     270       
     271        /**** send their centroids through sammon mapping ****/
     272       
     273        Point2D[] sammon = ck_server.getSammonMap(centroids);
     274       
     275        System.out.println("Num descriptions: " + descriptions.size());
     276        System.out.println("Num docs: " + docs.length);
     277        System.out.println("Num desc: " + desc.length);
     278       
     279        data.sammon = sammon;
     280       
     281    } catch (Exception e) {
     282        System.err.println("VisServlet: computing clustering Error: "+e);
     283    }
     284    ck_server = null;
     285    return data;
     286    }
    221287}
    222288
Note: See TracChangeset for help on using the changeset viewer.