Skip to content
Browse files

Updated test files

  • Loading branch information...
1 parent fd7773e commit 6353afe8c0568160d172d3a28f289a602d093bc9 hkirk committed Jun 11, 2010
View
12 src/test/DidYouMean.java
@@ -2,6 +2,7 @@
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.facade.DirectoryIndexFacade;
import org.apache.lucene.index.facade.IndexFacade;
+import org.apache.lucene.search.didyoumean.secondlevel.token.TermTokenPhraseSuggester;
import org.apache.lucene.search.didyoumean.secondlevel.token.TokenPhraseSuggester;
import org.apache.lucene.search.didyoumean.secondlevel.token.SpanNearTokenPhraseSuggester;
import org.apache.lucene.search.didyoumean.secondlevel.token.ngram.NgramTokenSuggester;
@@ -33,7 +34,8 @@ public static void main (String[] args) {
System.exit(1);
}
- Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT, Collections.EMPTY_SET);
+ Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT,
+ Collections.EMPTY_SET);
String aprioriField = args[1];
File indexDir = new File(args[0]);
@@ -56,7 +58,9 @@ public static void main (String[] args) {
ngramIndex = new DirectoryIndexFacade(new RAMDirectory());
ngramIndex.indexWriterFactory(null, true).close(); // Initialize empty index
tokenSuggester = new NgramTokenSuggester(ngramIndex);
- tokenSuggester.indexDictionary(new TermEnumIterator(aprioriIndex.indexReaderFactory(), aprioriField), 2);
+ tokenSuggester.indexDictionary(
+ new TermEnumIterator(aprioriIndex.indexReaderFactory(),
+ aprioriField), 2);
tokenSuggester.setAccuracy(0.1f);
} catch (IOException e) {
e.printStackTrace();
@@ -65,7 +69,9 @@ public static void main (String[] args) {
TokenPhraseSuggester phraseSuggester = null;
try {
- phraseSuggester = new SpanNearTokenPhraseSuggester(tokenSuggester, aprioriField, false, 3, analyzer, aprioriIndex);
+ phraseSuggester = new SpanNearTokenPhraseSuggester(tokenSuggester,
+ aprioriField, false, 3,
+ analyzer, aprioriIndex);
//phraseSuggester = new TermTokenPhraseSuggester(tokenSuggester, aprioriField, false, 3, analyzer, aprioriIndex);
} catch (IOException e) {
e.printStackTrace();
View
23 src/test/org/apache/lucene/search/didyoumean/impl/TestDefaultImplementation.java
@@ -15,12 +15,10 @@
*
*/
-
-
import junit.framework.TestCase;
-import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.search.didyoumean.secondlevel.token.TermTokenPhraseSuggester;
+import org.apache.lucene.search.didyoumean.secondlevel.token.TokenPhraseSuggester;
import org.apache.lucene.search.didyoumean.session.QueryGoalNode;
-import org.apache.lucene.search.didyoumean.Suggester;
import org.apache.lucene.search.didyoumean.Suggestion;
import org.apache.lucene.search.didyoumean.SuggestionFacade;
import org.apache.lucene.search.didyoumean.dictionary.MemoryDictionary;
@@ -32,11 +30,8 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.analysis.WhitespaceAnalyzer;
import org.apache.lucene.search.didyoumean.session.MemoryQuerySessionManager;
-import org.apache.lucene.search.didyoumean.session.QueryGoalTreeExtractor;
import org.apache.lucene.store.RAMDirectory;
-import java.io.File;
-
/**
* @author Karl Wettin <mailto:karl.wettin@gmail.com>
* Date: Jul 31, 2006
@@ -49,7 +44,13 @@
@Override
protected void setUp() throws Exception {
- suggestionFacade = new SuggestionFacade<Integer>(new MemoryDictionary(), new MemoryQuerySessionManager<Integer>(), new DefaultSuggester(), new DefaultTrainer(), new DefaultQueryGoalTreeExtractor<Integer>(), new DefaultAprioriCorpusFactory());
+ suggestionFacade =
+ new SuggestionFacade<Integer>(new MemoryDictionary(),
+ new MemoryQuerySessionManager<Integer>(),
+ new DefaultSuggester(),
+ new DefaultTrainer(),
+ new DefaultQueryGoalTreeExtractor<Integer>(),
+ new DefaultAprioriCorpusFactory());
// your primary index that suggestions must match.
IndexFacade aprioriIndex = new DirectoryIndexFacade(new RAMDirectory());
@@ -68,7 +69,11 @@ protected void setUp() throws Exception {
int maxSuggestionsPerToken = 3;
// add ngram suggester wrapped in a single token phrase suggester as second level suggester.
- suggestionFacade.getDictionary().getPrioritiesBySecondLevelSuggester().put(new SecondLevelTokenPhraseSuggester(ngramSuggester, aprioriField, false, maxSuggestionsPerToken, new WhitespaceAnalyzer(), aprioriIndex), 1d);
+ suggestionFacade.getDictionary().getPrioritiesBySecondLevelSuggester()
+ .put(new SecondLevelTokenPhraseSuggester(
+ new TermTokenPhraseSuggester(ngramSuggester, aprioriField,
+ false, maxSuggestionsPerToken, new WhitespaceAnalyzer(),
+ aprioriIndex)), 1d);
}
public void testBasicTraining() throws Exception {

0 comments on commit 6353afe

Please sign in to comment.
Something went wrong with that request. Please try again.