On Tue, 16 Jul 2013, jean.dahan wrote:
suggestWordsList = wordBreakSpellChecker.suggestWordBreaks( term, maxSugs, reader, sugMode, sortMethod) for suggestWords in suggestWordsList: print suggestWords[0]
It's difficult to create one of these suggest word lists out of thin air so here is a way to unpack an int[][] instead. The idea is to cast_() the outer array elements back into the array element type they actually are:
>>> import lucene >>> lucene.initVM() <jcc.JCCEnv object at 0x10029c0f0> >>> from lucene import JArray >>> b = JArray('int')(4) >>> b[0]=3 >>> b JArray<int>[3, 0, 0, 0] >>> a = JArray('object')(4) >>> a[2]=b >>> a JArray<object>[None, None, <Object: [I@778735f1>, None] >>> a[2] <Object: [I@778735f1> >>> JArray('int').cast_(a[2]) JArray<int>[3, 0, 0, 0] >>> JArray('int').cast_(a[2])[0] 3 Andi..
Java doc here describes .. http://lucene.apache.org/core/4_3_0/suggest/org/apache/lucene/search/spell/WordBreakSpellChecker.html public SuggestWord <http://lucene.apache.org/core/4_3_0/suggest/org/apache/lucene/search/spell/SuggestWord.html>[][] suggestWordBreaks(Term <http://lucene.apache.org/core/4_3_0/core/org/apache/lucene/index/Term.html?is-external=true> term, int maxSuggestions, IndexReader <http://lucene.apache.org/core/4_3_0/core/org/apache/lucene/index/IndexReader.html?is-external=true> ir, SuggestMode <http://lucene.apache.org/core/4_3_0/suggest/org/apache/lucene/search/spell/SuggestMode.html> suggestMode, WordBreakSpellChecker.BreakSuggestionSortMethod <http://lucene.apache.org/core/4_3_0/suggest/org/apache/lucene/search/spell/WordBreakSpellChecker.BreakSuggestionSortMethod.html> sortMethod) throws IOException <http://download.oracle.com/javase/6/docs/api/java/io/IOException.html?is-external=true> .. but .. How do we convert from SuggestWord<http://lucene.apache.org/core/4_3_0/suggest/org/apache/lucene/search/spell/SuggestWord.html> [][] to something accessible from python? Thanks!