当前位置: 首页>>代码示例>>Java>>正文


Java DocumentIndexReader.Iterator方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:21,代码来源:App.java

示例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();
    }
}
 
开发者ID:youngilcho,项目名称:internet-application-2014,代码行数:21,代码来源:App.java

示例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;
}
 
开发者ID:youngilcho,项目名称:internet-application-2014,代码行数:50,代码来源:TermAssociationManager.java


注:本文中的org.galagosearch.core.parse.DocumentIndexReader.Iterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。