Changeset 8288
- Timestamp:
- 2004-10-12T12:15:23+13:00 (20 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/greenstone3-extensions/vishnu/src/vishnu/datablock/DataBlock.java
r8189 r8288 8 8 public class DataBlock implements Serializable 9 9 { 10 public int [] docs;11 public String [] descriptions;12 public String [] words ;13 public SparseMatrix matrix;14 public Vector [] clusters;15 public Point2D [] sammon;10 public int [] docs = null; 11 public String [] descriptions = null; 12 public String [] words = null; 13 public SparseMatrix matrix = null; 14 public Vector [] clusters = null; 15 public Point2D [] sammon = null; 16 16 17 public DataBlock(int[] docs, 18 String [] descriptions, 19 String [] words, 20 SparseMatrix matrix, 21 Vector [] clusters, 22 Point2D [] sammon) 23 { 24 this.docs = docs; 25 this.descriptions = descriptions; 17 public DataBlock() { 18 } 19 public DataBlock(int[] docs, 20 String [] descriptions, 21 String [] words, 22 SparseMatrix matrix, 23 Vector [] clusters, 24 Point2D [] sammon) 25 { 26 this.docs = docs; 27 this.descriptions = descriptions; 26 28 this.words = words; 27 28 29 30 31 29 this.matrix = matrix; 30 this.clusters = clusters; 31 this.sammon = sammon; 32 } 33 32 34 } 33 35 -
trunk/greenstone3-extensions/vishnu/src/vishnu/datablock/SparseMatrix.java
r8189 r8288 2 2 import java.io.*; 3 3 4 5 // a matrix of size (document# x columnCount)6 // columns represent 100 most important keywords present in the retrieved documents7 4 public class SparseMatrix implements Serializable 8 5 { 9 6 private SparseNode [] nodes; 10 private int columnCount;11 private int rowCount;12 13 public SparseMatrix(int docCount, int columnCount)7 private int n_cols; 8 private int n_rows; 9 10 public SparseMatrix(int rows, int cols) 14 11 { 15 rowCount=docCount; 16 this.columnCount=columnCount; 17 nodes = new SparseNode[docCount]; 18 for (int c= 0; c<docCount;c++) 19 nodes[c] = null; 12 n_rows = rows; 13 n_cols = cols; 14 15 nodes = new SparseNode[n_rows]; 16 17 for (int c = 0; c < n_rows; c++) 18 nodes[c] = null; 20 19 } 21 20 22 public void addDataItem(int row, int column, int value) 21 22 public void addDataItem(int row, int column, float value) 23 23 { 24 SparseNode node; 25 26 nodes[row] =node.push(nodes[row]);24 SparseNode node; 25 node = new SparseNode(value, column); 26 nodes[row] = node.push(nodes[row]); 27 27 } 28 28 29 29 30 public SparseNode getRow(int row) … … 32 33 } 33 34 35 34 36 public int getRowCount() 35 37 { 36 return rowCount;38 return n_rows; 37 39 } 40 38 41 39 42 public int getColumnCount() 40 43 { 41 return columnCount; 42 } 43 44 public int[][] getExpanded() 45 { 46 int[][] full = new int[rowCount][columnCount]; 47 int r, c; 48 SparseNode n; 49 for (r = 0;r < rowCount; r++) 50 { 51 for (c = 0;c < columnCount; c++) 52 full[r][c]=0; 53 54 // n is now the first node in the list 55 n=nodes[r]; 56 57 while(n!= null) 58 { 59 full[r][n.getColumn()]=n.getValue(); 60 n=n.getNext(); 61 } 62 } 63 return full; 44 return n_cols; 64 45 } 65 46 66 /*public SparseMatrix getReduced(int maxDoc) 47 48 public float[][] getExpanded() 67 49 { 68 return this; 69 //SparseMatrix newMatrix = new SparseMatrix(); 70 //return new Matrix 71 72 }*/ 50 float[][] full = new float[n_rows][n_cols]; 51 52 SparseNode n; 53 54 for(int r = 0; r < n_rows; r++){ 55 for (int c = 0; c < n_cols; c++) 56 full[r][c]=0; 57 58 n=nodes[r]; 59 60 while(n!= null){ 61 full[r][n.getColumn()]=n.getValue(); 62 n=n.getNext(); 63 } 64 } 65 return full; 66 } 67 68 69 public void print() 70 { 71 for( int i = 0; i < nodes.length; i++ ){ 72 SparseNode n = getRow(i); 73 while(n != null ){ 74 System.out.print(n.getColumn()+ " "); 75 n = n.getNext(); 76 } 77 System.out.println(); 78 } 79 } 80 } 73 81 74 } -
trunk/greenstone3-extensions/vishnu/src/vishnu/datablock/SparseNode.java
r8189 r8288 4 4 public class SparseNode implements Serializable 5 5 { 6 private int value; 7 private int column; 8 private SparseNode next; 6 private float value; 7 8 private int column; 9 private SparseNode next; 10 11 12 SparseNode(float f, int c) 13 { 14 value = f; 15 column = c; 16 next = null; 17 } 18 19 20 SparseNode(float f, int c, SparseNode n) 21 { 22 value = f; 23 column = c; 24 next = n; 25 } 26 9 27 10 SparseNode(int d, int c) 11 { 12 value = d; 13 column = c; 14 next = null; 15 } 16 17 SparseNode(int d, int c, SparseNode n) 18 { 19 value = d; 20 column = c; 21 next = n; 22 } 23 24 25 // this simply adds a node to the BEGINNING of a list that starts with n1 26 // node = new Node(); 27 // n1 = node.push(n1); 28 // wicked! 29 // this would also add a node to the END of a list 30 // node = new Node(); 31 // n1 = n1.push(node); 32 // in which case the return argument would not be required 33 public SparseNode push(SparseNode n) 34 { 28 public SparseNode push(SparseNode n) 29 { 35 30 if (next != null) next.push(n); 36 31 else next = n; … … 38 33 } 39 34 40 // this simply returns the next node in a list with respect to "this"41 public SparseNode pop()42 {43 return next;44 }45 35 36 public SparseNode pop() 37 { 38 return next; 39 } 40 41 46 42 public SparseNode getNext() 47 43 { 48 44 return next; 49 45 } 46 50 47 51 48 public int getColumn() … … 54 51 } 55 52 56 public int getValue() 53 54 public float getValue() 57 55 { 58 56 return value; 59 57 } 60 61 62 58 } 63 59 -
trunk/gsdl3/extensions/vishnu/src/vishnu/datablock/DataBlock.java
r8189 r8288 8 8 public class DataBlock implements Serializable 9 9 { 10 public int [] docs;11 public String [] descriptions;12 public String [] words ;13 public SparseMatrix matrix;14 public Vector [] clusters;15 public Point2D [] sammon;10 public int [] docs = null; 11 public String [] descriptions = null; 12 public String [] words = null; 13 public SparseMatrix matrix = null; 14 public Vector [] clusters = null; 15 public Point2D [] sammon = null; 16 16 17 public DataBlock(int[] docs, 18 String [] descriptions, 19 String [] words, 20 SparseMatrix matrix, 21 Vector [] clusters, 22 Point2D [] sammon) 23 { 24 this.docs = docs; 25 this.descriptions = descriptions; 17 public DataBlock() { 18 } 19 public DataBlock(int[] docs, 20 String [] descriptions, 21 String [] words, 22 SparseMatrix matrix, 23 Vector [] clusters, 24 Point2D [] sammon) 25 { 26 this.docs = docs; 27 this.descriptions = descriptions; 26 28 this.words = words; 27 28 29 30 31 29 this.matrix = matrix; 30 this.clusters = clusters; 31 this.sammon = sammon; 32 } 33 32 34 } 33 35 -
trunk/gsdl3/extensions/vishnu/src/vishnu/datablock/SparseMatrix.java
r8189 r8288 2 2 import java.io.*; 3 3 4 5 // a matrix of size (document# x columnCount)6 // columns represent 100 most important keywords present in the retrieved documents7 4 public class SparseMatrix implements Serializable 8 5 { 9 6 private SparseNode [] nodes; 10 private int columnCount;11 private int rowCount;12 13 public SparseMatrix(int docCount, int columnCount)7 private int n_cols; 8 private int n_rows; 9 10 public SparseMatrix(int rows, int cols) 14 11 { 15 rowCount=docCount; 16 this.columnCount=columnCount; 17 nodes = new SparseNode[docCount]; 18 for (int c= 0; c<docCount;c++) 19 nodes[c] = null; 12 n_rows = rows; 13 n_cols = cols; 14 15 nodes = new SparseNode[n_rows]; 16 17 for (int c = 0; c < n_rows; c++) 18 nodes[c] = null; 20 19 } 21 20 22 public void addDataItem(int row, int column, int value) 21 22 public void addDataItem(int row, int column, float value) 23 23 { 24 SparseNode node; 25 26 nodes[row] =node.push(nodes[row]);24 SparseNode node; 25 node = new SparseNode(value, column); 26 nodes[row] = node.push(nodes[row]); 27 27 } 28 28 29 29 30 public SparseNode getRow(int row) … … 32 33 } 33 34 35 34 36 public int getRowCount() 35 37 { 36 return rowCount;38 return n_rows; 37 39 } 40 38 41 39 42 public int getColumnCount() 40 43 { 41 return columnCount; 42 } 43 44 public int[][] getExpanded() 45 { 46 int[][] full = new int[rowCount][columnCount]; 47 int r, c; 48 SparseNode n; 49 for (r = 0;r < rowCount; r++) 50 { 51 for (c = 0;c < columnCount; c++) 52 full[r][c]=0; 53 54 // n is now the first node in the list 55 n=nodes[r]; 56 57 while(n!= null) 58 { 59 full[r][n.getColumn()]=n.getValue(); 60 n=n.getNext(); 61 } 62 } 63 return full; 44 return n_cols; 64 45 } 65 46 66 /*public SparseMatrix getReduced(int maxDoc) 47 48 public float[][] getExpanded() 67 49 { 68 return this; 69 //SparseMatrix newMatrix = new SparseMatrix(); 70 //return new Matrix 71 72 }*/ 50 float[][] full = new float[n_rows][n_cols]; 51 52 SparseNode n; 53 54 for(int r = 0; r < n_rows; r++){ 55 for (int c = 0; c < n_cols; c++) 56 full[r][c]=0; 57 58 n=nodes[r]; 59 60 while(n!= null){ 61 full[r][n.getColumn()]=n.getValue(); 62 n=n.getNext(); 63 } 64 } 65 return full; 66 } 67 68 69 public void print() 70 { 71 for( int i = 0; i < nodes.length; i++ ){ 72 SparseNode n = getRow(i); 73 while(n != null ){ 74 System.out.print(n.getColumn()+ " "); 75 n = n.getNext(); 76 } 77 System.out.println(); 78 } 79 } 80 } 73 81 74 } -
trunk/gsdl3/extensions/vishnu/src/vishnu/datablock/SparseNode.java
r8189 r8288 4 4 public class SparseNode implements Serializable 5 5 { 6 private int value; 7 private int column; 8 private SparseNode next; 6 private float value; 7 8 private int column; 9 private SparseNode next; 10 11 12 SparseNode(float f, int c) 13 { 14 value = f; 15 column = c; 16 next = null; 17 } 18 19 20 SparseNode(float f, int c, SparseNode n) 21 { 22 value = f; 23 column = c; 24 next = n; 25 } 26 9 27 10 SparseNode(int d, int c) 11 { 12 value = d; 13 column = c; 14 next = null; 15 } 16 17 SparseNode(int d, int c, SparseNode n) 18 { 19 value = d; 20 column = c; 21 next = n; 22 } 23 24 25 // this simply adds a node to the BEGINNING of a list that starts with n1 26 // node = new Node(); 27 // n1 = node.push(n1); 28 // wicked! 29 // this would also add a node to the END of a list 30 // node = new Node(); 31 // n1 = n1.push(node); 32 // in which case the return argument would not be required 33 public SparseNode push(SparseNode n) 34 { 28 public SparseNode push(SparseNode n) 29 { 35 30 if (next != null) next.push(n); 36 31 else next = n; … … 38 33 } 39 34 40 // this simply returns the next node in a list with respect to "this"41 public SparseNode pop()42 {43 return next;44 }45 35 36 public SparseNode pop() 37 { 38 return next; 39 } 40 41 46 42 public SparseNode getNext() 47 43 { 48 44 return next; 49 45 } 46 50 47 51 48 public int getColumn() … … 54 51 } 55 52 56 public int getValue() 53 54 public float getValue() 57 55 { 58 56 return value; 59 57 } 60 61 62 58 } 63 59 -
trunk/gsdl3/packages/vishnu/src/vishnu/datablock/DataBlock.java
r8189 r8288 8 8 public class DataBlock implements Serializable 9 9 { 10 public int [] docs;11 public String [] descriptions;12 public String [] words ;13 public SparseMatrix matrix;14 public Vector [] clusters;15 public Point2D [] sammon;10 public int [] docs = null; 11 public String [] descriptions = null; 12 public String [] words = null; 13 public SparseMatrix matrix = null; 14 public Vector [] clusters = null; 15 public Point2D [] sammon = null; 16 16 17 public DataBlock(int[] docs, 18 String [] descriptions, 19 String [] words, 20 SparseMatrix matrix, 21 Vector [] clusters, 22 Point2D [] sammon) 23 { 24 this.docs = docs; 25 this.descriptions = descriptions; 17 public DataBlock() { 18 } 19 public DataBlock(int[] docs, 20 String [] descriptions, 21 String [] words, 22 SparseMatrix matrix, 23 Vector [] clusters, 24 Point2D [] sammon) 25 { 26 this.docs = docs; 27 this.descriptions = descriptions; 26 28 this.words = words; 27 28 29 30 31 29 this.matrix = matrix; 30 this.clusters = clusters; 31 this.sammon = sammon; 32 } 33 32 34 } 33 35 -
trunk/gsdl3/packages/vishnu/src/vishnu/datablock/SparseMatrix.java
r8189 r8288 2 2 import java.io.*; 3 3 4 5 // a matrix of size (document# x columnCount)6 // columns represent 100 most important keywords present in the retrieved documents7 4 public class SparseMatrix implements Serializable 8 5 { 9 6 private SparseNode [] nodes; 10 private int columnCount;11 private int rowCount;12 13 public SparseMatrix(int docCount, int columnCount)7 private int n_cols; 8 private int n_rows; 9 10 public SparseMatrix(int rows, int cols) 14 11 { 15 rowCount=docCount; 16 this.columnCount=columnCount; 17 nodes = new SparseNode[docCount]; 18 for (int c= 0; c<docCount;c++) 19 nodes[c] = null; 12 n_rows = rows; 13 n_cols = cols; 14 15 nodes = new SparseNode[n_rows]; 16 17 for (int c = 0; c < n_rows; c++) 18 nodes[c] = null; 20 19 } 21 20 22 public void addDataItem(int row, int column, int value) 21 22 public void addDataItem(int row, int column, float value) 23 23 { 24 SparseNode node; 25 26 nodes[row] =node.push(nodes[row]);24 SparseNode node; 25 node = new SparseNode(value, column); 26 nodes[row] = node.push(nodes[row]); 27 27 } 28 28 29 29 30 public SparseNode getRow(int row) … … 32 33 } 33 34 35 34 36 public int getRowCount() 35 37 { 36 return rowCount;38 return n_rows; 37 39 } 40 38 41 39 42 public int getColumnCount() 40 43 { 41 return columnCount; 42 } 43 44 public int[][] getExpanded() 45 { 46 int[][] full = new int[rowCount][columnCount]; 47 int r, c; 48 SparseNode n; 49 for (r = 0;r < rowCount; r++) 50 { 51 for (c = 0;c < columnCount; c++) 52 full[r][c]=0; 53 54 // n is now the first node in the list 55 n=nodes[r]; 56 57 while(n!= null) 58 { 59 full[r][n.getColumn()]=n.getValue(); 60 n=n.getNext(); 61 } 62 } 63 return full; 44 return n_cols; 64 45 } 65 46 66 /*public SparseMatrix getReduced(int maxDoc) 47 48 public float[][] getExpanded() 67 49 { 68 return this; 69 //SparseMatrix newMatrix = new SparseMatrix(); 70 //return new Matrix 71 72 }*/ 50 float[][] full = new float[n_rows][n_cols]; 51 52 SparseNode n; 53 54 for(int r = 0; r < n_rows; r++){ 55 for (int c = 0; c < n_cols; c++) 56 full[r][c]=0; 57 58 n=nodes[r]; 59 60 while(n!= null){ 61 full[r][n.getColumn()]=n.getValue(); 62 n=n.getNext(); 63 } 64 } 65 return full; 66 } 67 68 69 public void print() 70 { 71 for( int i = 0; i < nodes.length; i++ ){ 72 SparseNode n = getRow(i); 73 while(n != null ){ 74 System.out.print(n.getColumn()+ " "); 75 n = n.getNext(); 76 } 77 System.out.println(); 78 } 79 } 80 } 73 81 74 } -
trunk/gsdl3/packages/vishnu/src/vishnu/datablock/SparseNode.java
r8189 r8288 4 4 public class SparseNode implements Serializable 5 5 { 6 private int value; 7 private int column; 8 private SparseNode next; 6 private float value; 7 8 private int column; 9 private SparseNode next; 10 11 12 SparseNode(float f, int c) 13 { 14 value = f; 15 column = c; 16 next = null; 17 } 18 19 20 SparseNode(float f, int c, SparseNode n) 21 { 22 value = f; 23 column = c; 24 next = n; 25 } 26 9 27 10 SparseNode(int d, int c) 11 { 12 value = d; 13 column = c; 14 next = null; 15 } 16 17 SparseNode(int d, int c, SparseNode n) 18 { 19 value = d; 20 column = c; 21 next = n; 22 } 23 24 25 // this simply adds a node to the BEGINNING of a list that starts with n1 26 // node = new Node(); 27 // n1 = node.push(n1); 28 // wicked! 29 // this would also add a node to the END of a list 30 // node = new Node(); 31 // n1 = n1.push(node); 32 // in which case the return argument would not be required 33 public SparseNode push(SparseNode n) 34 { 28 public SparseNode push(SparseNode n) 29 { 35 30 if (next != null) next.push(n); 36 31 else next = n; … … 38 33 } 39 34 40 // this simply returns the next node in a list with respect to "this"41 public SparseNode pop()42 {43 return next;44 }45 35 36 public SparseNode pop() 37 { 38 return next; 39 } 40 41 46 42 public SparseNode getNext() 47 43 { 48 44 return next; 49 45 } 46 50 47 51 48 public int getColumn() … … 54 51 } 55 52 56 public int getValue() 53 54 public float getValue() 57 55 { 58 56 return value; 59 57 } 60 61 62 58 } 63 59
Note:
See TracChangeset
for help on using the changeset viewer.