我在org.apache.lucene.analysis.synonym中找到了類WordnetSynonymParser,但在API和Google中都沒有使用它的示例。有沒有人有經驗?有沒有人知道如何使用Wordnet擴展查詢與Lucene 3.6?
謝謝!
編輯:我知道,曾經有類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
是否有可能通過lucene 3.6執行查詢擴展? – synack