summaryrefslogtreecommitdiffstats
path: root/linguistics
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@vespa.ai>2024-01-12 18:43:13 +0100
committerJon Bratseth <bratseth@vespa.ai>2024-01-12 18:43:13 +0100
commiteb79e9b1b567ca1b2b0863777c1cf47ee191216e (patch)
tree689247eba83cf1e209e8e5cc3a0e441832f636dc /linguistics
parent0213cea0df0706a1f1a70c44e8c2b5906745a6ab (diff)
Support parameter references in embed
Support embed(@myParameter) in addition to embed('text to embed')
Diffstat (limited to 'linguistics')
-rw-r--r--linguistics/abi-spec.json4
-rw-r--r--linguistics/src/main/java/com/yahoo/language/process/Embedder.java10
2 files changed, 13 insertions, 1 deletions
diff --git a/linguistics/abi-spec.json b/linguistics/abi-spec.json
index 1ffb879e57e..dc6a62cc463 100644
--- a/linguistics/abi-spec.json
+++ b/linguistics/abi-spec.json
@@ -344,7 +344,9 @@
"public java.lang.String getDestination()",
"public com.yahoo.language.process.Embedder$Context setDestination(java.lang.String)",
"public java.lang.String getEmbedderId()",
- "public com.yahoo.language.process.Embedder$Context setEmbedderId(java.lang.String)"
+ "public com.yahoo.language.process.Embedder$Context setEmbedderId(java.lang.String)",
+ "public java.util.Map getContextValues()",
+ "public com.yahoo.language.process.Embedder$Context setContextValues(java.util.Map)"
],
"fields" : [ ]
},
diff --git a/linguistics/src/main/java/com/yahoo/language/process/Embedder.java b/linguistics/src/main/java/com/yahoo/language/process/Embedder.java
index fa141977d5d..d9d2256d0c1 100644
--- a/linguistics/src/main/java/com/yahoo/language/process/Embedder.java
+++ b/linguistics/src/main/java/com/yahoo/language/process/Embedder.java
@@ -88,6 +88,7 @@ public interface Embedder {
private Language language = Language.UNKNOWN;
private String destination;
private String embedderId = "unknown";
+ private Map<String, String> contextValues;
public Context(String destination) {
this.destination = destination;
@@ -138,6 +139,15 @@ public interface Embedder {
this.embedderId = embedderId;
return this;
}
+
+ /** Returns a read-only map of context key-values which can be looked up during conversion. */
+ public Map<String, String> getContextValues() { return contextValues; }
+
+ public Context setContextValues(Map<String, String> contextValues) {
+ this.contextValues = Map.copyOf(contextValues);
+ return this;
+ }
+
}
class FailingEmbedder implements Embedder {