Skip to content

Commit

Permalink
Merge pull request #32156 from vespa-engine/bratseth/chinese-query-test
Browse files Browse the repository at this point in the history
Add Chinese query test
  • Loading branch information
Harald Musum authored Aug 15, 2024
2 parents 99d3fca + 458e61b commit 0fc2b00
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,24 @@ public static SystemName defaultSystem() {
}

public static SystemName from(String value) {
switch (value.toLowerCase()) {
case "dev": return dev;
case "cd": return cd;
case "main": return main;
case "public": return Public;
case "publiccd": return PublicCd;
default: throw new IllegalArgumentException(String.format("'%s' is not a valid system", value));
}
return switch (value.toLowerCase()) {
case "dev" -> dev;
case "cd" -> cd;
case "main" -> main;
case "public" -> Public;
case "publiccd" -> PublicCd;
default -> throw new IllegalArgumentException(String.format("'%s' is not a valid system", value));
};
}

public String value() {
switch (this) {
case dev: return "dev";
case cd: return "cd";
case main: return "main";
case Public: return "public";
case PublicCd: return "publiccd";
default : throw new IllegalStateException();
}
return switch (this) {
case dev -> "dev";
case cd -> "cd";
case main -> "main";
case Public -> "public";
case PublicCd -> "publiccd";
};
}

/** Whether the system is similar to Public, e.g. PublicCd. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Iterator<Execution.Trace.LogValue> logValueIterator() {
* @param name the name of the property
* @param value the value of the property, or null to set this property to null
*/
public void setProperty(String name,Object value) {
public void setProperty(String name, Object value) {
owner.getModel().getExecution().trace().setProperty(name,value);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.test;

import ai.vespa.opennlp.OpenNlpConfig;
import com.yahoo.component.chain.Chain;
import com.yahoo.language.Language;
import com.yahoo.language.Linguistics;
import com.yahoo.language.detect.Detection;
import com.yahoo.language.detect.Detector;
import com.yahoo.language.detect.Hint;
import com.yahoo.language.opennlp.OpenNlpLinguistics;
import com.yahoo.language.process.StemMode;
import com.yahoo.language.process.Token;
import com.yahoo.language.simple.SimpleDetector;
Expand Down Expand Up @@ -1257,6 +1259,17 @@ void testSettingNativeQueryProfileValueInQueryProfile() {
}
}

@Test
public void testChinese() {
var query = new Query(httpEncode("?query=中村靖日驟逝"), null);
var execution = new Execution(Execution.Context.createContextStub(null, new IndexFacts(),
new OpenNlpLinguistics(new OpenNlpConfig.Builder().cjk(true)
.createCjkGrams(true)
.snowballStemmingForEnglish(true).build())));
query.getModel().setExecution(execution);
assertEquals("WEAKAND(100) 中村靖 日驟 逝", query.getModel().getQueryTree().toString());
}

private void assertDetectionText(String expectedDetectionText, String queryString, String ... indexSpecs) {
Query q = new Query(httpEncode("/?query=" + queryString));
SearchDefinition sd = new SearchDefinition("testSearchDefinition");
Expand Down
2 changes: 1 addition & 1 deletion flags/src/main/java/com/yahoo/vespa/flags/Flags.java
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public class Flags {
public static final UnboundBooleanFlag USE_LEGACY_WAND_QUERY_PARSING = defineFeatureFlag(
"use-legacy-wand-query-parsing", true,
List.of("arnej"), "2023-07-26", "2025-12-31",
"If true, force leagy mode for weakAnd query parsing",
"If true, force legacy mode for weakAnd query parsing",
"Takes effect at redeployment",
INSTANCE_ID);

Expand Down

0 comments on commit 0fc2b00

Please sign in to comment.