source: trunk/greenstone3-extensions/vishnu/src/vishnu/testvis/object/ClusterObj.java@ 8189

Last change on this file since 8189 was 8189, checked in by kjdon, 20 years ago

first version of Imperial College's Visualiser code

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1/**
2 * @(#)ClusterObj.java 12/12/99
3 * @author Peter Au
4 * All rights reserved.
5 */
6
7package vishnu.testvis.object;
8import vishnu.datablock.*;
9import java.util.Vector;
10
11public class ClusterObj
12{
13 DocObj[] _docs; //-- list of DocObj ref
14 String _label; //-- (top 3-5? related words)
15 Point2D [] _sammon; //-- 2D mapping for the centroids
16 DataManager _data;
17 public ClusterObj(DocObj[] d, String t, Point2D [] sammon, DataManager dm)
18 {
19 _docs=d; _label=t;
20 _sammon = sammon;
21 _data = dm;
22 }
23 /**
24 * @return the number of documents in the cluster
25 */
26 public int getDocsSize(){return _docs.length;}
27
28 public String getLabel(){return _label;}
29
30 public String getLabel1(){return getDocsSize() + " documents found";}
31 public String getLabel2(){return getLabel();}
32
33
34 public String getInfo(){
35 return getDocsSize() + " documents found\n" + getLabel();
36 }
37
38
39 /**
40 * This returns a list of list of documents. The inner list of documents represents
41 * which documents have the corresponding related word
42 * pre: _docs can't be null
43 * @return a vector (same length as the related words) of
44 * vectors (arbitrary length)
45 *
46 */
47 public Vector getHitDocFreq()
48 {
49 int s = _data.getWordCount();
50 Vector rwVec = new Vector(s);
51 for(int i=0;i<s;i++)
52 {
53 rwVec.addElement(new Vector(0));
54 for(int j=0;j<_docs.length;j++)
55 {
56 if ( _docs[j].getWeights(i) > 0 )
57 ((Vector) rwVec.elementAt(i)).addElement(_docs[j]);
58 }
59 }
60 return rwVec;
61 }
62
63
64 public String formatDocs()
65 {
66 int l = getDocsSize();
67 String s = "<html><font face=Arial size=-1> "+ l +" documents found\n";
68 for(int i=0;i<l;i++)
69 {
70 s += _docs[i].format4Fields();
71 }
72 s += "</font></html>\n";
73 return s;
74 }
75
76
77}
Note: See TracBrowser for help on using the repository browser.