mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 13:09:00 +00:00
(query-parser) Fix regression where advice terms weren't parsed properly
This commit is contained in:
parent
fe800b3af7
commit
89f7f3c17c
@ -83,9 +83,10 @@ public class QueryParser {
|
||||
|
||||
// special case to deal with possible RPAREN token at the end,
|
||||
// but we don't want to break if it's likely part of the search term
|
||||
if (c == '(' && prevC != ')' && parenDepth > 0)
|
||||
if (c == ')' && prevC != '(' && parenDepth > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String displayStr = query.substring(i, end);
|
||||
String str = trimEscape(displayStr.toLowerCase());
|
||||
|
@ -160,78 +160,65 @@ public class QueryFactoryTest {
|
||||
|
||||
@Test
|
||||
public void testExpansion() {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
var subquery = parseAndGetSpecs("elden ring mechanical keyboard slackware linux duke nukem 3d").query;
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
System.out.println(subquery.compiledQuery);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpansion2() {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
var subquery = parseAndGetSpecs("need for speed").query;
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
System.out.println(subquery);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpansion3() {
|
||||
long start = System.currentTimeMillis();
|
||||
var subquery = parseAndGetSpecs("buy rimonabant buy acomplia");
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
System.out.println(subquery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpansion4() {
|
||||
long start = System.currentTimeMillis();
|
||||
var subquery = parseAndGetSpecs("The Vietnam of computer science");
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
System.out.println(subquery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpansion5() {
|
||||
long start = System.currentTimeMillis();
|
||||
var subquery = parseAndGetSpecs("The");
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
System.out.println(subquery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpansion6() {
|
||||
long start = System.currentTimeMillis();
|
||||
var subquery = parseAndGetSpecs("burning the nerves in the neck");
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
System.out.println(subquery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpansion7() {
|
||||
long start = System.currentTimeMillis();
|
||||
var subquery = parseAndGetSpecs("amazing work being done");
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
System.out.println(subquery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpansion8() {
|
||||
long start = System.currentTimeMillis();
|
||||
var subquery = parseAndGetSpecs("success often consists of");
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
System.out.println(subquery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsing() {
|
||||
long start = System.currentTimeMillis();
|
||||
var subquery = parseAndGetSpecs("strlen()");
|
||||
assertEquals("strlen", subquery.query.compiledQuery);
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
System.out.println(subquery);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdvice() {
|
||||
var subquery = parseAndGetSpecs("mmap (strlen)");
|
||||
assertEquals("mmap", subquery.query.compiledQuery);
|
||||
assertEquals(List.of("strlen"), subquery.query.searchTermsAdvice);
|
||||
System.out.println(subquery);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user