Changeset 3794


Ignore:
Timestamp:
2003-03-05T13:53:10+13:00 (21 years ago)
Author:
mdewsnip
Message:

Equivalent term information is now stored in a separate class: MGEquivTermInfo.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/packages/mg/java/org/greenstone/mg/MGQueryResult.java

    r3744 r3794  
    102102
    103103
    104     // public void addTerm(String term, int stem, long match, long freq)
    105     public void addTerm(String term, String tag, int stem,
    106             long match, long freq, String[] equivs)
     104    public void addTerm(String term, int stem)
    107105    {
    108106    MGTermInfo ti = new MGTermInfo();
    109107    ti.term_ = term;
    110     ti.tag_ = tag;
    111108    ti.stem_method_ = stem;
    112     ti.match_docs_ = match;
    113     ti.term_freq_ = freq;
    114     if (equivs != null) {
    115         for (int i = 0; i < equivs.length; i++) {
    116         ti.equiv_terms_.add(equivs[i]);
     109    terms_.add(ti);
     110    System.out.println("(Java) Added term " + ti);
     111    }
     112
     113
     114    public void addEquivTerm(String term, String equivTerm,
     115                 long match, long freq)
     116    {
     117    // Find the term to add the equivalent to
     118    MGTermInfo ti = null;
     119    for (int i = (terms_.size() - 1); i >= 0; i--) {
     120        ti = (MGTermInfo) terms_.elementAt(i);
     121        // Found
     122        if (ti.term_ == term) {
     123        break;
    117124        }
    118125    }
    119     System.out.println("(Java) Added term " + ti);
    120126
    121     terms_.add(ti);
     127    if (ti == null) {
     128        System.err.println("Internal error: No term exists to add to.\n");
     129    }
     130    else {
     131        ti.addEquivTerm(equivTerm, match, freq);
     132        System.out.println("(Java) Added equivalent term " + equivTerm + ", match: " + match + ", freq: " + freq);
     133    }
    122134    }
    123135
  • trunk/gsdl3/packages/mg/java/org/greenstone/mg/MGTermInfo.java

    r3744 r3794  
    3333    public String term_ = null;
    3434
    35     /** the tag - level or metadata - for which the query was done */
    36     public String tag_ = null;
    37 
    3835    /** the stem and casefold method used
    3936    0 = none
     
    4239    3 = casefold and stem */
    4340    public int stem_method_ = 0;
    44 
    45     /** the number of documents containing this term
    46     (where document is defined by the tag data) */
    47     public long match_docs_ = 0;
    48 
    49     /** overall term freq - word level */
    50     public long term_freq_ = 0;
    5141
    5242    /** list of stemmed and casefolded equivalent terms - if stem_method_ is non-zero
     
    6151
    6252
     53    public void addEquivTerm(String equivTerm, long match, long freq)
     54    {
     55    equiv_terms_.add(new MGEquivTermInfo(equivTerm, match, freq));
     56    }
     57
     58
    6359    /** output the class as a string */
    6460    public String toString()
    6561    {
    6662    String result = "\"" + term_ + "\"";
    67     result += " tag(" + tag_ + ")";
    6863    result += " stem(" + stem_method_ + ")";
    69     result += " docs(" + match_docs_ + ")";
    70     result += " freq(" + term_freq_ + ")";
    71 
    7264    result += " equiv terms(";
    7365    for (int i = 0; i < equiv_terms_.size(); i++) {
    7466        if (i > 0) result += ", ";
    75         result += (String) equiv_terms_.elementAt(i);
     67        result += equiv_terms_.elementAt(i);
    7668    }
    7769    result += ")";
    78 
    7970    return result;
    8071    }
  • trunk/gsdl3/src/packages/mg/java/org/greenstone/mg/MGQueryResult.java

    r3744 r3794  
    102102
    103103
    104     // public void addTerm(String term, int stem, long match, long freq)
    105     public void addTerm(String term, String tag, int stem,
    106             long match, long freq, String[] equivs)
     104    public void addTerm(String term, int stem)
    107105    {
    108106    MGTermInfo ti = new MGTermInfo();
    109107    ti.term_ = term;
    110     ti.tag_ = tag;
    111108    ti.stem_method_ = stem;
    112     ti.match_docs_ = match;
    113     ti.term_freq_ = freq;
    114     if (equivs != null) {
    115         for (int i = 0; i < equivs.length; i++) {
    116         ti.equiv_terms_.add(equivs[i]);
     109    terms_.add(ti);
     110    System.out.println("(Java) Added term " + ti);
     111    }
     112
     113
     114    public void addEquivTerm(String term, String equivTerm,
     115                 long match, long freq)
     116    {
     117    // Find the term to add the equivalent to
     118    MGTermInfo ti = null;
     119    for (int i = (terms_.size() - 1); i >= 0; i--) {
     120        ti = (MGTermInfo) terms_.elementAt(i);
     121        // Found
     122        if (ti.term_ == term) {
     123        break;
    117124        }
    118125    }
    119     System.out.println("(Java) Added term " + ti);
    120126
    121     terms_.add(ti);
     127    if (ti == null) {
     128        System.err.println("Internal error: No term exists to add to.\n");
     129    }
     130    else {
     131        ti.addEquivTerm(equivTerm, match, freq);
     132        System.out.println("(Java) Added equivalent term " + equivTerm + ", match: " + match + ", freq: " + freq);
     133    }
    122134    }
    123135
  • trunk/gsdl3/src/packages/mg/java/org/greenstone/mg/MGTermInfo.java

    r3744 r3794  
    3333    public String term_ = null;
    3434
    35     /** the tag - level or metadata - for which the query was done */
    36     public String tag_ = null;
    37 
    3835    /** the stem and casefold method used
    3936    0 = none
     
    4239    3 = casefold and stem */
    4340    public int stem_method_ = 0;
    44 
    45     /** the number of documents containing this term
    46     (where document is defined by the tag data) */
    47     public long match_docs_ = 0;
    48 
    49     /** overall term freq - word level */
    50     public long term_freq_ = 0;
    5141
    5242    /** list of stemmed and casefolded equivalent terms - if stem_method_ is non-zero
     
    6151
    6252
     53    public void addEquivTerm(String equivTerm, long match, long freq)
     54    {
     55    equiv_terms_.add(new MGEquivTermInfo(equivTerm, match, freq));
     56    }
     57
     58
    6359    /** output the class as a string */
    6460    public String toString()
    6561    {
    6662    String result = "\"" + term_ + "\"";
    67     result += " tag(" + tag_ + ")";
    6863    result += " stem(" + stem_method_ + ")";
    69     result += " docs(" + match_docs_ + ")";
    70     result += " freq(" + term_freq_ + ")";
    71 
    7264    result += " equiv terms(";
    7365    for (int i = 0; i < equiv_terms_.size(); i++) {
    7466        if (i > 0) result += ", ";
    75         result += (String) equiv_terms_.elementAt(i);
     67        result += equiv_terms_.elementAt(i);
    7668    }
    7769    result += ")";
    78 
    7970    return result;
    8071    }
  • trunk/indexers/mg/java/org/greenstone/mg/MGQueryResult.java

    r3744 r3794  
    102102
    103103
    104     // public void addTerm(String term, int stem, long match, long freq)
    105     public void addTerm(String term, String tag, int stem,
    106             long match, long freq, String[] equivs)
     104    public void addTerm(String term, int stem)
    107105    {
    108106    MGTermInfo ti = new MGTermInfo();
    109107    ti.term_ = term;
    110     ti.tag_ = tag;
    111108    ti.stem_method_ = stem;
    112     ti.match_docs_ = match;
    113     ti.term_freq_ = freq;
    114     if (equivs != null) {
    115         for (int i = 0; i < equivs.length; i++) {
    116         ti.equiv_terms_.add(equivs[i]);
     109    terms_.add(ti);
     110    System.out.println("(Java) Added term " + ti);
     111    }
     112
     113
     114    public void addEquivTerm(String term, String equivTerm,
     115                 long match, long freq)
     116    {
     117    // Find the term to add the equivalent to
     118    MGTermInfo ti = null;
     119    for (int i = (terms_.size() - 1); i >= 0; i--) {
     120        ti = (MGTermInfo) terms_.elementAt(i);
     121        // Found
     122        if (ti.term_ == term) {
     123        break;
    117124        }
    118125    }
    119     System.out.println("(Java) Added term " + ti);
    120126
    121     terms_.add(ti);
     127    if (ti == null) {
     128        System.err.println("Internal error: No term exists to add to.\n");
     129    }
     130    else {
     131        ti.addEquivTerm(equivTerm, match, freq);
     132        System.out.println("(Java) Added equivalent term " + equivTerm + ", match: " + match + ", freq: " + freq);
     133    }
    122134    }
    123135
  • trunk/indexers/mg/java/org/greenstone/mg/MGTermInfo.java

    r3744 r3794  
    3333    public String term_ = null;
    3434
    35     /** the tag - level or metadata - for which the query was done */
    36     public String tag_ = null;
    37 
    3835    /** the stem and casefold method used
    3936    0 = none
     
    4239    3 = casefold and stem */
    4340    public int stem_method_ = 0;
    44 
    45     /** the number of documents containing this term
    46     (where document is defined by the tag data) */
    47     public long match_docs_ = 0;
    48 
    49     /** overall term freq - word level */
    50     public long term_freq_ = 0;
    5141
    5242    /** list of stemmed and casefolded equivalent terms - if stem_method_ is non-zero
     
    6151
    6252
     53    public void addEquivTerm(String equivTerm, long match, long freq)
     54    {
     55    equiv_terms_.add(new MGEquivTermInfo(equivTerm, match, freq));
     56    }
     57
     58
    6359    /** output the class as a string */
    6460    public String toString()
    6561    {
    6662    String result = "\"" + term_ + "\"";
    67     result += " tag(" + tag_ + ")";
    6863    result += " stem(" + stem_method_ + ")";
    69     result += " docs(" + match_docs_ + ")";
    70     result += " freq(" + term_freq_ + ")";
    71 
    7264    result += " equiv terms(";
    7365    for (int i = 0; i < equiv_terms_.size(); i++) {
    7466        if (i > 0) result += ", ";
    75         result += (String) equiv_terms_.elementAt(i);
     67        result += equiv_terms_.elementAt(i);
    7668    }
    7769    result += ")";
    78 
    7970    return result;
    8071    }
Note: See TracChangeset for help on using the changeset viewer.