如何在java中使用indri进行索引?

时间:2015-11-24 08:22:25

标签: java indri

import lemurproject.indri.*;
import java.io.*;

public class Indritest {

    public static void main(String[] args) throws Exception {

        String [] stopWordList =  {"a", "an", "and", "are", "as", "at", "be", 
                                  "by","for", "from", "has", "he", "in", "is",
                                  "it", "its", "of", "on", "that", "the", "to",
                                  "was", "were", "will", "with"};

        String myIndex = "C:/Program Files/lemur/lemur4.12/src/app/obj/myIndex5";

        try {
            IndexEnvironment envI = new IndexEnvironment();
            envI.setStoreDocs(true);

            // create an Indri repository
            envI.setMemory(256000000);

            envI.setStemmer("krovetz");
            envI.setStopwords(stopWordList);

            envI.setIndexedFields( new String[] {"article", "header", "p", "title", "link"}); 
            envI.open(myIndex);
            envI.create( myIndex );

            // add xml files to the just created index i.e myIndex
            // xml_data is a folder which contains the list of xml files to be added

            File filesDir = new File("C:/NetbeanProg2/xml_data"); 
            File[] files = filesDir.listFiles(); 
            int noOffiles = files.length; 
            for (int i = 0; i < noOffiles; i++) { 
                System.out.println(files[i].getCanonicalPath() + "\t" + files[i].getCanonicalFile()); 
                envI.addFile(files[i].getCanonicalPath(), "xml"); 
            }  
        } catch (Exception e) {
            System.out.println("issue is: " + e);
        }
    }
}

我从教程中找到了这段代码,但它不起作用。它给了我一个例外。

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files\Indri\Indri 5.9\bin\indri_jni.dll: Can't find dependent libraries

myindex变量中,我提供了IndexUI.jar文件的路径。 我是indri的新手。我对它的用法并不太了解。我已经下载了indri 5.9

1 个答案:

答案 0 :(得分:0)

问题是indri的版本