📄 combinedocnode.java
字号:
package searchingEngine.dataPreprocessing.wordPosition;
import java.io.IOException;
import java.util.LinkedList;
import searchingEngine.dataPreprocessing.invertedFile.DocNode;
import searchingEngine.dataPreprocessing.invertedFile.TermNode;
import searchingEngine.utilites.dataConverter.RawConverter;
public class CombineDocNode {
/**
* @param args
*/
public void combine(LinkedList<TermNode> host,LinkedList<TermNode> sub){
int indexHost=0,indexSub = 0;
int hostLen=host.size(), subLen = sub.size();
while ((indexHost<hostLen)||(indexSub<subLen)){
if (indexHost>=hostLen) {
host.addAll(sub.subList(indexSub,subLen));
break;
}
if (indexSub>=subLen) {
break;
}
int checker = host.get(indexHost).compareTo(sub.get(indexSub));
if ( checker ==0) {
insert(host.get(indexHost).doc_list,sub.get(indexSub).doc_list);
indexHost++;
indexSub++;
} else if ( checker <0) {
indexHost++;
} else if ( checker >0) {
host.add(indexHost,sub.get(indexSub));
indexSub++;
}
}
}
private void insert(LinkedList<DocNode> host,LinkedList<DocNode> sub){
int indexHost=0,indexSub = 0;
int hostLen=host.size(), subLen = sub.size();
while ((indexHost<hostLen)||(indexSub<subLen)){
if (indexHost>=hostLen) {
host.addAll(sub.subList(indexSub,subLen));
break;
}
if (indexSub>=subLen) {
break;
}
int checker = host.get(indexHost).compareTo(sub.get(indexSub));
if ( checker ==0) {
insertInt(((DocNodeWpos)host.get(indexHost)).wpos_list,((DocNodeWpos)sub.get(indexSub)).wpos_list);
indexHost++;
indexSub++;
} else if ( checker <0) {
indexHost++;
} else if ( checker >0) {
host.add(indexHost,sub.get(indexSub));
indexSub++;
}
}
}
private void insertInt(LinkedList<Integer> host,LinkedList<Integer> sub){
int indexHost=0,indexSub = 0;
int hostLen=host.size(), subLen = sub.size();
while ((indexHost<hostLen)||(indexSub<subLen)){
if (indexHost>=hostLen) {
host.addAll(sub.subList(indexSub,subLen));
break;
}
if (indexSub>subLen) {
break;
}
int checker = host.get(indexHost).compareTo(sub.get(indexSub));
if ( checker <0) {
indexHost++;
} else if ( checker >0) {
host.add(indexHost,sub.get(indexSub));
indexSub++;
}
}
}
public static void main(String[] args) throws IOException{
/*
LinkedList<TermNode> nodeA;
LinkedList<TermNode> nodeB;
CombineDocNode combine;
for (int i=0;i<118;i++){
nodeA = (LinkedList<TermNode>)RawConverter.loadObject("G:/X/X/combined"+i+".dat");
nodeB = (LinkedList<TermNode>)RawConverter.loadObject("G:/X/X/combined"+(i+8)+".dat");
combine = new CombineDocNode();
combine.combine(nodeA,nodeB);
RawConverter.saveListAsText(nodeA,"G:/X/X/X/combined"+i+".txt");
RawConverter.saveObject(nodeA,"G:/X/X/X/combined"+i+".dat");
i = i+15;
combine = null;
nodeA = null;
nodeB = null;
System.gc();
}
*/
LinkedList<TermNode> nodeB;
nodeB = (LinkedList<TermNode>)RawConverter.loadObject("combinedXX96.dat");
RawConverter.saveListAsText(nodeB,"combinedXX96.txt");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -