本文整理匯總了Java中org.galagosearch.core.parse.DocumentIndexReader.Iterator方法的典型用法代碼示例。如果您正苦於以下問題:Java DocumentIndexReader.Iterator方法的具體用法?Java DocumentIndexReader.Iterator怎麽用?Java DocumentIndexReader.Iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.galagosearch.core.parse.DocumentIndexReader
的用法示例。
在下文中一共展示了DocumentIndexReader.Iterator方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleDumpCorpus
import org.galagosearch.core.parse.DocumentIndexReader; //導入方法依賴的package包/類
private static void handleDumpCorpus(String[] args) throws IOException {
if (args.length <= 1) {
commandHelp(args[0]);
return;
}
DocumentIndexReader reader = new DocumentIndexReader(args[1]);
DocumentIndexReader.Iterator iterator = reader.getIterator();
while (!iterator.isDone()) {
System.out.println("#IDENTIFIER: " + iterator.getKey());
Document document = iterator.getDocument();
System.out.println("#METADATA");
for (Entry<String, String> entry : document.metadata.entrySet()) {
System.out.println(entry.getKey() + "," + entry.getValue());
}
System.out.println("#TEXT");
System.out.println(document.text);
iterator.nextDocument();
}
}
示例2: handleDumpCorpus
import org.galagosearch.core.parse.DocumentIndexReader; //導入方法依賴的package包/類
private void handleDumpCorpus(String[] args) throws IOException {
if (args.length <= 1) {
commandHelp(args[0]);
return;
}
DocumentIndexReader reader = new DocumentIndexReader(args[1]);
DocumentIndexReader.Iterator iterator = reader.getIterator();
while (!iterator.isDone()) {
output.println("#IDENTIFIER: " + iterator.getKey());
Document document = iterator.getDocument();
output.println("#METADATA");
for (Entry<String, String> entry : document.metadata.entrySet()) {
output.println(entry.getKey() + "," + entry.getValue());
}
output.println("#TEXT");
output.println(document.text);
iterator.nextDocument();
}
}
示例3: init
import org.galagosearch.core.parse.DocumentIndexReader; //導入方法依賴的package包/類
public synchronized void init() throws IOException {
if (inited) {
return;
}
//here, set path of stopword file
stopwordFile = "../doc/stopwords.txt";
//here, set path of corpus file assigned to you
corpusFile = "../doc/reuter.corpus";
if (stopwordList == null)
stopwordList = makeStopWordList(stopwordFile);
if (documentList == null) {
// 캐싱된게 없다면 가져오기
documentList = new ArrayList<String>();
corpusStr = new StringBuffer();
// galago 함수 통해서 직접 읽는다.
DocumentIndexReader reader = new DocumentIndexReader(corpusFile);
DocumentIndexReader.Iterator iterator = reader.getIterator();
while (!iterator.isDone()) {
Document document = iterator.getDocument();
documentList.add(document.text);
corpusStr.append(" " + document.text);
iterator.nextDocument();
}
//to get global tf list
topTerms = getTopTermFreq(corpusStr.toString());
docFreq = new int[topTerms.length];
termFreqList = makeTermFreqList(documentList);
}
// to get df per term
for (int index = 0; index < topTerms.length; index++) {
int docFreqTerm = 0;
for (int cnt = 0; cnt < termFreqList.size(); cnt++) {
HashMap<String, Integer> termFreq = termFreqList.get(cnt);
if (termFreq.containsKey(topTerms[index])) docFreqTerm++;
}
docFreq[index] = docFreqTerm;
}
inited = true;
}