📄 .#merg26217cvs
字号:
/*
* InvertTerm.java
*
* Created on 2006年12月3日, 下午10:12
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package TestIndexing;
import java.util.ArrayList;
/**
*
* @author Alpha
*/
public class InverseTerm{
/** Creates a new instance of InvertTerm */
public InverseTerm() {
this(0);
}
public InverseTerm( int id) {
this.termID = id;
this.docTimes = new ArrayList<int[]>();
}
/**
* Holds value of property termID.
*/
private int termID;
/**
* Getter for property termID.
* @return Value of property termID.
*/
public int getTermID() {
return this.termID;
}
/**
* Setter for property termID.
* @param termID New value of property termID.
*/
public void setTermID(int termID) {
this.termID = termID;
}
/**
* Holds value of property docTimes.
*/
private java.util.ArrayList<int[]> docTimes;
/**
* Getter for property docTimes.
* @return Value of property docTimes.
*/
public java.util.ArrayList<int[]> getDocTimes() {
return this.docTimes;
}
/**
* Setter for property docTimes.
* @param docTimes New value of property docTimes.
*/
public void setDocTimes(java.util.ArrayList<int[]> docTimes) {
this.docTimes = docTimes;
}
public int hashCode() {
return this.getTermID();
}
public void addDocTime(int docID) {
int len = this.getDocTimes().size();
for (int i = 0; i < len; i++) {
if (this.getDocTimes().get(i)[0] == docID) {
this.getDocTimes().get(i)[1] ++;
return;
}
}
int[] list = {docID, 1};
this.getDocTimes().add(list);
}
public void plusDocTime( ArrayList<int[]> newDocs, int occur ){
for (int i = 0; i < newDocs.size(); i++) {
for (int j = 0; j < this.getDocTimes().size(); j++) {
if( this.getDocTimes().get(j)[0] == newDocs.get(i)[0] ){
System.out.println( this.getDocTimes().get(j)[1] + "+=" + occur + "*" +newDocs.get(i)[1] );
this.getDocTimes().get(j)[1] += occur * newDocs.get(i)[1];
}
}
}
for (int i = 0; i < newDocs.size(); i++) {
boolean flag = false;
for (int j = 0; j < this.getDocTimes().size(); j++) {
if( this.getDocTimes().get(j)[0] == newDocs.get(i)[0] ){
flag = true;
}
}
if( !flag ){
this.getDocTimes().add( newDocs.get(i) );
}
}
}
public String printRank(){
StringBuffer sb = new StringBuffer();
for (int i = 0; i < this.getDocTimes().size(); i++) {
sb.append( this.getDocTimes().get(i)[0] + " " + this.getDocTimes().get(i)[1] + "\n" );
}
return sb.toString();
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(this.getTermID()+"\t");
int len = this.getDocTimes().size();
for (int i = 0; i < len; i++) {
sb.append(this.getDocTimes().get(i)[0]+"\t" + this.getDocTimes().get(i)[1] + "\t");
}
sb.append("\n");
return sb.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -