我在 org.apache.lucene.analysis.synonym 中找到了WordnetSynonymParser类,但在 API 和谷歌中都没有使用它的示例。有没有人有这方面的经验?
谢谢!
编辑:我知道曾经有SynExpand类,但是在 3.6 版中它消失了......
我尝试:
try {
FileReader rulesReader = new FileReader("wn/wn_s.pl");
SynonymMap.Builder parser = null;
parser = new WordnetSynonymParser(true, true, analyzer);
((WordnetSynonymParser)parser).add(rulesReader);
synonymMap = parser.build();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
但我收到以下错误:
java.text.ParseException: Invalid synonym rule at line 109
at org.apache.lucene.analysis.synonym.WordnetSynonymParser.add(WordnetSynonymParser.java:75)
at pirServer.QueryClassifier.<init>(QueryClassifier.java:77)
at pirServer.PIRServer.main(PIRServer.java:32)
Caused by: java.lang.IllegalArgumentException: term: course of action analyzed to a token with posinc != 1
at org.apache.lucene.analysis.synonym.SynonymMap$Builder.analyze(SynonymMap.java:131)
at org.apache.lucene.analysis.synonym.WordnetSynonymParser.parseSynonym(WordnetSynonymParser.java:92)
at org.apache.lucene.analysis.synonym.WordnetSynonymParser.add(WordnetSynonymParser.java:67)
... 2 more