2
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 5.9

4

1 回答 1

0

问题是 indri 的版本

于 2015-12-28T16:24:19.003 回答