在看《 Lucene In Action 》一书,在第四章同义词搜索遇到了问题。 书中源码 SynonymFilter.java 有一段 private AttributeSource.State current; ... restoreState(current); ... current = captureState(); 查看了 java 源码,State 是内部类。restoreState,captureState 都是 AttributeSource 中的函数: public final void restoreState(State state) public final State captureState() 没有找到 pylucene 中如何使用,尝试了一下: current = AttributeSource.State() AttributeSource.restoreState(current) current = AttributeSource.captureState() 但是报错: >>> AttributeSource.restoreState(current) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: descriptor 'restoreState' requires a 'AttributeSource' object but received a 'AttributeSource$State'
>>> AttributeSource.captureState() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: descriptor 'captureState' of 'AttributeSource' object needs an argument
>>> AttributeSource.captureState(current) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: descriptor 'captureState' requires a 'AttributeSource' object but received a 'At tributeSource$State'