Changeset 8288


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

added in daniel's mods for new server stuff - not sure what they are :-)

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/greenstone3-extensions/vishnu/src/vishnu/datablock/DataBlock.java

    r8189 r8288  
    88public class DataBlock implements Serializable
    99{
    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;
    1616
    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;
    2628        this.words = words;
    27         this.matrix = matrix;
    28         this.clusters = clusters;
    29         this.sammon = sammon;
    30     }
    31 
     29    this.matrix = matrix;
     30    this.clusters = clusters;
     31    this.sammon = sammon;
     32    }
     33   
    3234}
    3335
  • trunk/greenstone3-extensions/vishnu/src/vishnu/datablock/SparseMatrix.java

    r8189 r8288  
    22import java.io.*;
    33
    4 
    5 // a matrix of size (document# x columnCount)
    6 // columns represent 100 most important keywords present in the retrieved documents
    74public class SparseMatrix implements Serializable
    85{
    96    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)
    1411    {
    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;
    2019    }
    2120   
    22     public void addDataItem(int row, int column, int value)
     21   
     22    public void addDataItem(int row, int column, float value)
    2323    {
    24         SparseNode node;
    25         node = new SparseNode(value, column);
    26         nodes[row] = node.push(nodes[row]);
     24    SparseNode node;
     25    node = new SparseNode(value, column);
     26    nodes[row] = node.push(nodes[row]);
    2727    }
     28   
    2829   
    2930    public SparseNode getRow(int row)
     
    3233    }
    3334
     35
    3436    public int getRowCount()
    3537    {
    36         return rowCount;
     38        return n_rows;
    3739    }
     40
    3841
    3942    public int getColumnCount()
    4043    {
    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;
    6445    }
    6546   
    66     /*public SparseMatrix getReduced(int maxDoc)
     47
     48    public float[][] getExpanded()
    6749    {
    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}
    7381
    74 }
  • trunk/greenstone3-extensions/vishnu/src/vishnu/datablock/SparseNode.java

    r8189 r8288  
    44public class SparseNode implements Serializable
    55{
    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   
    927
    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    {
    3530        if (next != null) next.push(n);
    3631        else next = n;
     
    3833    }
    3934
    40     // this simply returns the next node in a list with respect to "this"
    41     public SparseNode pop()
    42     {
    43         return next;
    44     }
    4535
     36    public SparseNode pop()
     37    {
     38    return next;
     39    }
     40
     41   
    4642    public SparseNode getNext()
    4743    {
    4844        return next;
    4945    }
     46
    5047   
    5148    public int getColumn()
     
    5451    }
    5552   
    56     public int getValue()
     53
     54    public float getValue()
    5755    {
    5856        return value;
    5957    }
    60 
    61 
    6258}
    6359
  • trunk/gsdl3/extensions/vishnu/src/vishnu/datablock/DataBlock.java

    r8189 r8288  
    88public class DataBlock implements Serializable
    99{
    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;
    1616
    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;
    2628        this.words = words;
    27         this.matrix = matrix;
    28         this.clusters = clusters;
    29         this.sammon = sammon;
    30     }
    31 
     29    this.matrix = matrix;
     30    this.clusters = clusters;
     31    this.sammon = sammon;
     32    }
     33   
    3234}
    3335
  • trunk/gsdl3/extensions/vishnu/src/vishnu/datablock/SparseMatrix.java

    r8189 r8288  
    22import java.io.*;
    33
    4 
    5 // a matrix of size (document# x columnCount)
    6 // columns represent 100 most important keywords present in the retrieved documents
    74public class SparseMatrix implements Serializable
    85{
    96    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)
    1411    {
    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;
    2019    }
    2120   
    22     public void addDataItem(int row, int column, int value)
     21   
     22    public void addDataItem(int row, int column, float value)
    2323    {
    24         SparseNode node;
    25         node = new SparseNode(value, column);
    26         nodes[row] = node.push(nodes[row]);
     24    SparseNode node;
     25    node = new SparseNode(value, column);
     26    nodes[row] = node.push(nodes[row]);
    2727    }
     28   
    2829   
    2930    public SparseNode getRow(int row)
     
    3233    }
    3334
     35
    3436    public int getRowCount()
    3537    {
    36         return rowCount;
     38        return n_rows;
    3739    }
     40
    3841
    3942    public int getColumnCount()
    4043    {
    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;
    6445    }
    6546   
    66     /*public SparseMatrix getReduced(int maxDoc)
     47
     48    public float[][] getExpanded()
    6749    {
    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}
    7381
    74 }
  • trunk/gsdl3/extensions/vishnu/src/vishnu/datablock/SparseNode.java

    r8189 r8288  
    44public class SparseNode implements Serializable
    55{
    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   
    927
    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    {
    3530        if (next != null) next.push(n);
    3631        else next = n;
     
    3833    }
    3934
    40     // this simply returns the next node in a list with respect to "this"
    41     public SparseNode pop()
    42     {
    43         return next;
    44     }
    4535
     36    public SparseNode pop()
     37    {
     38    return next;
     39    }
     40
     41   
    4642    public SparseNode getNext()
    4743    {
    4844        return next;
    4945    }
     46
    5047   
    5148    public int getColumn()
     
    5451    }
    5552   
    56     public int getValue()
     53
     54    public float getValue()
    5755    {
    5856        return value;
    5957    }
    60 
    61 
    6258}
    6359
  • trunk/gsdl3/packages/vishnu/src/vishnu/datablock/DataBlock.java

    r8189 r8288  
    88public class DataBlock implements Serializable
    99{
    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;
    1616
    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;
    2628        this.words = words;
    27         this.matrix = matrix;
    28         this.clusters = clusters;
    29         this.sammon = sammon;
    30     }
    31 
     29    this.matrix = matrix;
     30    this.clusters = clusters;
     31    this.sammon = sammon;
     32    }
     33   
    3234}
    3335
  • trunk/gsdl3/packages/vishnu/src/vishnu/datablock/SparseMatrix.java

    r8189 r8288  
    22import java.io.*;
    33
    4 
    5 // a matrix of size (document# x columnCount)
    6 // columns represent 100 most important keywords present in the retrieved documents
    74public class SparseMatrix implements Serializable
    85{
    96    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)
    1411    {
    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;
    2019    }
    2120   
    22     public void addDataItem(int row, int column, int value)
     21   
     22    public void addDataItem(int row, int column, float value)
    2323    {
    24         SparseNode node;
    25         node = new SparseNode(value, column);
    26         nodes[row] = node.push(nodes[row]);
     24    SparseNode node;
     25    node = new SparseNode(value, column);
     26    nodes[row] = node.push(nodes[row]);
    2727    }
     28   
    2829   
    2930    public SparseNode getRow(int row)
     
    3233    }
    3334
     35
    3436    public int getRowCount()
    3537    {
    36         return rowCount;
     38        return n_rows;
    3739    }
     40
    3841
    3942    public int getColumnCount()
    4043    {
    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;
    6445    }
    6546   
    66     /*public SparseMatrix getReduced(int maxDoc)
     47
     48    public float[][] getExpanded()
    6749    {
    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}
    7381
    74 }
  • trunk/gsdl3/packages/vishnu/src/vishnu/datablock/SparseNode.java

    r8189 r8288  
    44public class SparseNode implements Serializable
    55{
    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   
    927
    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    {
    3530        if (next != null) next.push(n);
    3631        else next = n;
     
    3833    }
    3934
    40     // this simply returns the next node in a list with respect to "this"
    41     public SparseNode pop()
    42     {
    43         return next;
    44     }
    4535
     36    public SparseNode pop()
     37    {
     38    return next;
     39    }
     40
     41   
    4642    public SparseNode getNext()
    4743    {
    4844        return next;
    4945    }
     46
    5047   
    5148    public int getColumn()
     
    5451    }
    5552   
    56     public int getValue()
     53
     54    public float getValue()
    5755    {
    5856        return value;
    5957    }
    60 
    61 
    6258}
    6359
Note: See TracChangeset for help on using the changeset viewer.