Skip to content

Commit 57662e2

Browse files
committed
Update DynamicQuestionAnswering.java
1 parent 7e281a0 commit 57662e2

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/main/java/net/b07z/sepia/sdk/services/uid1007/DynamicQuestionAnswering.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import net.b07z.sepia.server.assist.data.Parameter;
88
import net.b07z.sepia.server.assist.interpreters.NluResult;
99
import net.b07z.sepia.server.assist.interviews.InterviewData;
10-
import net.b07z.sepia.server.assist.parameters.GenericEmptyParameter;
10+
import net.b07z.sepia.server.assist.parameters.CustomParameter;
1111
import net.b07z.sepia.server.assist.services.ServiceBuilder;
1212
import net.b07z.sepia.server.assist.services.ServiceInfo;
1313
import net.b07z.sepia.server.assist.services.ServiceInterface;
@@ -110,8 +110,8 @@ public ServiceInfo getInfo(String language) {
110110

111111
//Parameters:
112112

113-
//This service has no fixed parameter. The question is instead generated dynamically inside the result handler.
114-
//We still need to define the custom parameter as optional though to extract it properly later:
113+
//This service has no required parameter because the question is generated dynamically inside the result handler.
114+
//We define the custom parameter as optional though to extract it properly later (or in regular expression trigger):
115115
Parameter p1 = new Parameter(new SpecialQuestion());
116116
info.addParameter(p1);
117117

@@ -198,8 +198,17 @@ public ServiceResult getResult(NluResult nluResult) {
198198
//----------------- custom parameters -------------------
199199

200200
/**
201-
* Parameter handler that is just a placeholder for our custom question.
202-
* It will contain the full input, normalized and raw if used in a response.
201+
* Custom parameter that tries to extract the question from first input or response.
202+
* It will contain the normalized and full raw input by default.
203203
*/
204-
public static class SpecialQuestion extends GenericEmptyParameter {}
204+
public static class SpecialQuestion extends CustomParameter {
205+
206+
@Override
207+
public String extract(String input){
208+
//If you use regular expression triggers in 'getInfo' you could try to extract
209+
//the question here. For now we just return nothing and get the input during
210+
//response phase (after "what do you want to know?")
211+
return "";
212+
}
213+
}
205214
}

0 commit comments

Comments
 (0)