⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inpharse.java

📁 自己写的search engine, 有 boolean search, fuzzy search
💻 JAVA
字号:
package searchingEngine.queryPrepocessing;
import java.util.*;
import java.io.IOException;
import java.math.*;

import searchingEngine.booleanModel.PostOrder;
import searchingEngine.dataPreprocessing.invertedFile.DocNode;
import searchingEngine.dataPreprocessing.invertedFile.InvertedFile;
import searchingEngine.fuzzyBooleanModel.MembershipNode;
import searchingEngine.utilites.dataConverter.KeywordCounter;
import searchingEngine.utilites.dataConverter.RawConverter;

public class Inpharse{
	
	private LinkedList<String> term = new LinkedList<String>();
	private LinkedList<Integer> fileid;
	LinkedList<MembershipNode> docs;

	public Inpharse(LinkedList<Integer> fileid,LinkedList<String> input){
		this.term = input;
		this.fileid = fileid;
	}

	
	public LinkedList <Integer> retrieveDocs(LinkedList<Integer>fileid, LinkedList<String>term){

			LinkedList<Integer> resultset = new LinkedList<Integer>();
			int resultindex=0;

			for (int i=0;i<fileid.size() ;i++ )
			{
				int tempindex=0;//temp index is used to creat the new temp1 vector
				LinkedList <Integer> temp1 = KeywordCounter.getPosition(term.get(0), fileid.get(i));
				for (int k=1; k<term.size(); k++) {
					LinkedList <Integer> temp2 = KeywordCounter.getPosition(term.get(k), fileid.get(i));
					int temp1index=0;
					int temp2index=0;
					tempindex=0;	
									
					while(temp1index < temp1.size())
					{
						while(temp2index< temp2.size())
						{
							if(temp1.get(temp1index) > temp2.get(temp2index)-1)
							{
								temp2index++;
								continue;
							}
							else if(temp1.get(temp1index) < temp2.get(temp2index)-1)
							{
								break;
							}
							else if(temp1.get(temp1index) ==temp2.get(temp2index)-1)
							{
								temp1.set(tempindex++,(Integer)temp1.get(temp1index));
								temp2index++;
								break;
							}else
								break;
						} // end while
						temp1index++;
					}// end while
					if (tempindex==0)
					{
						break;
					}
					for(int l=tempindex+1;l<temp1.size();l++){
						temp1.remove(l);
					}
								
				}// end for
								
				if (tempindex!=0)
				{
					resultset.set(resultindex++, (Integer)fileid.get(i));
				}				
			}// end for		
		return resultset;
	}//end retrieveDocs
	

}//end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -