當前位置: 首頁>>代碼示例>>Java>>正文


Java DocumentIndexReader類代碼示例

本文整理匯總了Java中org.galagosearch.core.parse.DocumentIndexReader的典型用法代碼示例。如果您正苦於以下問題:Java DocumentIndexReader類的具體用法?Java DocumentIndexReader怎麽用?Java DocumentIndexReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DocumentIndexReader類屬於org.galagosearch.core.parse包,在下文中一共展示了DocumentIndexReader類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: handleDoc

import org.galagosearch.core.parse.DocumentIndexReader; //導入依賴的package包/類
private static void handleDoc(String[] args) throws IOException {
    if (args.length <= 2) {
        commandHelp(args[0]);
        return;
    }

    String indexPath = args[1];
    String identifier = args[2];
    DocumentIndexReader reader = new DocumentIndexReader(indexPath);
    Document document = reader.getDocument(identifier);
    System.out.println(document.text);
}
 
開發者ID:jjfiv,項目名稱:galagosearch,代碼行數:13,代碼來源:App.java

示例4: get

import org.galagosearch.core.parse.DocumentIndexReader; //導入依賴的package包/類
public Document get(String identifier) throws IOException {
    for (DocumentIndexReader reader : readers) {
        Document document = reader.getDocument(identifier);
        if (document != null) {
            return document;
        }
    }
    return null;
}
 
開發者ID:jjfiv,項目名稱:galagosearch,代碼行數:10,代碼來源:DocumentIndexStore.java

示例5: handleDoc

import org.galagosearch.core.parse.DocumentIndexReader; //導入依賴的package包/類
private void handleDoc(String[] args) throws IOException {
    if (args.length <= 2) {
        commandHelp(args[0]);
        return;
    }

    String indexPath = args[1];
    String identifier = args[2];
    DocumentIndexReader reader = new DocumentIndexReader(indexPath);
    Document document = reader.getDocument(identifier);
    output.println(document.text);
}
 
開發者ID:youngilcho,項目名稱:internet-application-2014,代碼行數:13,代碼來源:App.java

示例6: DocumentIndexStore

import org.galagosearch.core.parse.DocumentIndexReader; //導入依賴的package包/類
public DocumentIndexStore(DocumentIndexReader reader) {
    this(Collections.singletonList(reader));
}
 
開發者ID:jjfiv,項目名稱:galagosearch,代碼行數:4,代碼來源:DocumentIndexStore.java

示例7: close

import org.galagosearch.core.parse.DocumentIndexReader; //導入依賴的package包/類
public void close() throws IOException {
    for (DocumentIndexReader reader : readers) {
        reader.close();
    }
}
 
開發者ID:jjfiv,項目名稱:galagosearch,代碼行數:6,代碼來源:DocumentIndexStore.java

示例8: 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類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。