mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-11 21:05:38 +01:00
improve usage of lucene, add stop words, code cleanup, etc.
This commit is contained in:
@@ -52,7 +52,7 @@ public class FieldAnalyzerTest extends BaseTest {
|
||||
@Test
|
||||
public void testAnalyzers() throws Exception {
|
||||
|
||||
Analyzer analyzer = new FieldAnalyzer(LuceneUtils.CURRENT_VERSION);
|
||||
Analyzer analyzer = new SearchFieldAnalyzer(LuceneUtils.CURRENT_VERSION);
|
||||
Directory index = new RAMDirectory();
|
||||
|
||||
String field1 = "product";
|
||||
@@ -93,12 +93,10 @@ public class FieldAnalyzerTest extends BaseTest {
|
||||
assertEquals("springframework", searcher.doc(hits[0].doc).get(field1));
|
||||
assertEquals("springsource", searcher.doc(hits[0].doc).get(field2));
|
||||
|
||||
searchAnalyzerProduct.clear(); //ensure we don't have anything left over from the previous search.
|
||||
searchAnalyzerVendor.clear();
|
||||
querystr = "product:(Apache Struts) vendor:(Apache)";
|
||||
Query q2 = parser.parse(querystr);
|
||||
assertFalse("second parsing contains previousWord from the TokenPairConcatenatingFilter", q2.toString().contains("core"));
|
||||
|
||||
|
||||
querystr = "product:( x-stream^5 ) AND vendor:( thoughtworks.xstream )";
|
||||
Query q3 = parser.parse(querystr);
|
||||
collector = TopScoreDocCollector.create(hitsPerPage, true);
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.apache.lucene.analysis.core.WhitespaceTokenizer;
|
||||
import org.junit.After;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -55,22 +54,4 @@ public class TokenPairConcatenatingFilterTest extends BaseTokenStreamTestCase {
|
||||
assertTokenStreamContents(filter,
|
||||
new String[]{"one", "onetwo", "two", "twothree", "three"});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of clear method, of class TokenPairConcatenatingFilter.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
@Test
|
||||
public void testClear() throws IOException {
|
||||
|
||||
TokenStream ts = new WhitespaceTokenizer(LuceneUtils.CURRENT_VERSION, new StringReader("one two three"));
|
||||
TokenPairConcatenatingFilter filter = new TokenPairConcatenatingFilter(ts);
|
||||
assertTokenStreamContents(filter, new String[]{"one", "onetwo", "two", "twothree", "three"});
|
||||
|
||||
assertNotNull(filter.getPreviousWord());
|
||||
filter.clear();
|
||||
assertNull(filter.getPreviousWord());
|
||||
assertTrue(filter.getWords().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user