简体   繁体   English

通过调用org.apache.lucene.benchmark.byTask.feeds.TrecGov2Parser.parse获取NullPointerException

[英]Get NullPointerException from calling org.apache.lucene.benchmark.byTask.feeds.TrecGov2Parser.parse

I want to pars GOv2 collection format and I want to use TrecGov2Parser . 我想解析GOv2集合格式,并且想使用TrecGov2Parser I find its code in this page . 我在此页面中找到其代码。 The input file is test file and it contains just one document of GOV2 collection. 输入文件是测试文件,它仅包含GOV2集合的一个文档。 This is my code: 这是我的代码:

public static void writeHTMLText()
{
    try
    {
        FileWriter fw1= new FileWriter(new File("/home/fl/Desktop/GOV_Text/GOV/00.txt"));
        BufferedWriter bw1 = new BufferedWriter(fw1);

        FileReader fileReader = new FileReader(new File("/home/fl/Desktop/GOV/00"));
        BufferedReader br = new BufferedReader(fileReader);
        String docs="";
        String line;
        while((line=br.readLine())!= null )
              docs= docs+line+"\n";

        DocData docData = new DocData();
        DocData result = new TrecGov2Parser().parse(docData,"result00",new TrecContentSource(),new StringBuilder(docs),TrecDocParser.ParsePathType.GOV2);
        bw1.write(result.getBody());

        br.close();
        bw1.close();
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}

I got this error. 我得到这个错误。

java.lang.NullPointerException
    at org.apache.lucene.benchmark.byTask.feeds.TrecGov2Parser.parse(TrecGov2Parser.java:56)
    at LuceneParser.parserInput.writeHTMLText(parserInput.java:63)
I add *lucene-core-3.4.0.jar* and *lucene-benchmark-3.4.0.jar* to my project buildpath.

What do I need to do? 我需要做什么?

There is no private , protected or public keyword at getHtmlParser() . getHtmlParser()处没有privateprotectedpublic关键字。 This means you can call this method only from inside the same package ( default/package visibility ). 这意味着您只能从同一包内部调用此方法( 默认/包可见性 )。 The method is intended not to be used by others . 该方法不应被其他人使用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PyLucene org.apache.lucene.benchmark丢失 - PyLucene org.apache.lucene.benchmark is missing 如何使用Java的SAX Parser从URL数组一次解析多个XML feed? - How to parse multiple XML feeds at once from an array of URLs with SAX Parser for Java? 在 org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1198) 处获取 NullPointerException - Getting NullPointerException at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1198) 调用CommandLineParser#parser时使用org.apache.commons.cli的java.lang.IllegalAccessError - java.lang.IllegalAccessError using org.apache.commons.cli when calling CommandLineParser#parser Lucene 拆分包:模块从“lucene.analyzers.common”和“lucene.core”中读取包“org.apache.lucene.analysis.standard” - Lucene split package: module reads package 'org.apache.lucene.analysis.standard' from both 'lucene.analyzers.common' and 'lucene.core' 无法导入org.apache.lucene - Cannot import org.apache.lucene Lucene的org.apache.lucene.document.Field类的方法使用 - Methods usage of org.apache.lucene.document.Field class of Lucene NoSuchMethodError: org.apache.lucene.document.Field - NoSuchMethodError: org.apache.lucene.document.Field IllegalAccessError:org / apache / lucene / index / DirectoryReader - IllegalAccessError: org/apache/lucene/index/DirectoryReader org.apache.lucene.index.IndexNotFoundException:org.apache.lucene.store.RAMDirectory中找不到segments *文件 - org.apache.lucene.index.IndexNotFoundException: no segments* file found in org.apache.lucene.store.RAMDirectory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM