[英]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()
处没有private
, protected
或public
关键字。 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.