本文整理汇总了Java中com.amazon.speech.slu.Intent.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getName方法的具体用法?Java Intent.getName怎么用?Java Intent.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazon.speech.slu.Intent
的用法示例。
在下文中一共展示了Intent.getName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
public SpeechletResponse onIntent(IntentRequest request, Session session) throws SpeechletException {
LOGGER.info("onRequest requestId={}, sessionId={}", request.getRequestId(), session.getSessionId());
// Get intent from the request object.
Intent intent = request.getIntent();
String intentName = (intent != null) ? intent.getName() : null;
RequestHandlerFactory factory = GetRequestHandlerFactory.FUNCTION.apply(intentName);
if (factory != null) {
return factory.create(context).onRequest(request, session);
} else {
return new SpeechletResponseBuilder()
.withNewPlainTextOutputSpeechOutputSpeech()
.withText("I don't know how to do that.")
.endPlainTextOutputSpeechOutputSpeech()
.build();
}
}
示例2: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope) {
LOGGER.info("onIntent()");
Intent intent = requestEnvelope.getRequest().getIntent();
switch (intent.getName()) {
case "QueryInventory":
return handleQueryInventory(requestEnvelope);
case "OrderWare":
return handleOrderWare(requestEnvelope);
case "LocateWare":
return handleLocateWare(requestEnvelope);
case "Quit":
return handleQuit();
default:
throw new IllegalArgumentException("Unknown intent: " + intent.getName());
}
}
示例3: respondToIntentRequest
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse respondToIntentRequest(IntentRequest intentReq, Session session) {
Intent intent = intentReq.getIntent();
String intentName = (intent != null) ? intent.getName() : null;
SpeechletResponse response = null;
if (INTENT_START.equals(intentName)) {
response = handleStartJokeIntent(intentReq, session);
}
else if (INTENT_WHO_DER.equals(intentName)) {
response = handleWhoThereIntent(intentReq, session);
}
else if (INTENT_DR_WHO.equals(intentName)) {
response = handleDrWhoIntent(intentReq, session);
}
else {
response = newTellResponse("Whatchu talkin' bout!", false);
}
return response;
}
示例4: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(final IntentRequest request, final Session session)
throws SpeechletException {
log.info("onIntent requestId={}, sessionId={}", request.getRequestId(),
session.getSessionId());
SpeechletResponse response = null;
Intent intent = request.getIntent();
String intentName = (intent != null) ? intent.getName() : null;
//Check for convo handling
Conversation convo = getConvoForIntent(intentName);
if(convo != null) {
response = convo.respondToIntentRequest(request, session);
}
else {
throw new SpeechletException("Invalid Intent");
}
return response;
}
示例5: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(final IntentRequest request, final Session session)
throws SpeechletException {
log.info("onIntent requestId={}, sessionId={}", request.getRequestId(),
session.getSessionId());
Intent intent = request.getIntent();
String intentName = (intent != null) ? intent.getName() : null;
if ("PlayRecordingIntent".equals(intentName)) {
return getPlayRecordingResponse(intent);
} else if ("FastForwardIntent".equals(intentName)) {
return getFastForwardResponse(intent);
} else if ("RewindIntent".equals(intentName)) {
return getRewindResponse(intent);
} else if ("PauseIntent".equals(intentName)) {
return getPauseResponse();
} else if ("StopIntent".equals(intentName)) {
return getStopResponse();
} else if ("AMAZON.HelpIntent".equals(intentName)) {
return getHelpResponse();
} else {
throw new SpeechletException("Invalid Intent");
}
}
示例6: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(IntentRequest request, Session session) throws SpeechletException {
LOG.info("onIntent: request={}, session={}", request, session);
final Intent intent = request.getIntent();
if (intent == null) {
throw new SpeechletException("Unrecognized intent");
}
final String intentName = intent.getName();
final Object bean = beanFactory.getBean(intentName);
if (bean instanceof IntentHandler) {
IntentHandler intentHandler = (IntentHandler) bean;
return intentHandler.handleIntent(request, intent);
}
else {
throw new SpeechletException("Unknown intent");
}
}
示例7: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(IntentRequest request, Session session) throws SpeechletException {
log.info("onIntent: requestId={}, sessionId={}", request.getRequestId(), session.getSessionId());
Intent intent = request.getIntent();
String intentName = (intent != null) ? intent.getName() : null;
IntentManager intentManager = new IntentManager(session.getUser().getUserId());
if (Constants.INTENT_HELP.equals(intentName)) {
return intentManager.getHelpResponse();
} else if (Constants.INTENT_HELLO.equals(intentName)) {
return intentManager.getHelloResponse();
} else if (Constants.INTENT_HOME_ADDRESS.equals(intentName)) {
return intentManager.getHomeAddressResponse(
intent.getSlot("PostalAddress"), intent.getSlot("City"));
} else if (Constants.INTENT_OFFICE_ADDRESS.equals(intentName)) {
return intentManager.getOfficeAddressResponse(
intent.getSlot("PostalAddress"), intent.getSlot("City"));
} else if (Constants.INTENT_COMMUTE.equals(intentName)) {
return intentManager.getCommuteResponse();
} else if (Constants.INTENT_DIRECTIONS.equals(intentName)) {
return intentManager.getDirectionsResponse(
intent.getSlot("PostalAddress"), intent.getSlot("City"),
intent.getSlot("Landmark"));
} else if (Constants.INTENT_PLACES.equals(intentName)) {
return intentManager.getPlacesResponse();
} else if (Constants.INTENT_BLOG.equals(intentName)) {
return intentManager.getBlogResponse();
} else {
throw new SpeechletException("Invalid Intent.");
}
}
示例8: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(final IntentRequest request, final Session session) throws SpeechletException {
logger.info("onIntent requestId={}, sessionId={}", request.getRequestId(), session.getSessionId());
Intent intent = request.getIntent();
if (intent == null || intent.getName() == null) {
throw new SpeechletException("Invalid Intent");
}
if (service == null) {
return newResponse("Die Session ist geschlossen");
}
switch (intent.getName()) {
case STATUS_INTENT:
return getStatusResponse(request.getLocale());
case LIST_DEVICE_INTENT:
return getListDeviceResponse(request.getLocale());
case ALL_DEVICE_ON_INTENT:
return setAllDevice(true);
case ALL_DEVICE_OFF_INTENT:
return setAllDevice(false);
case DEVICE_ON_INTENT:
return setDevice(intent, true);
case DEVICE_OFF_INTENT:
return setDevice(intent, false);
case DEVICE_TEMP_INTENT:
return getDeviceTemp(intent, request.getLocale());
case DEVICE_POWER_INTENT:
return getDeviceEnergy(intent, request.getLocale());
case HELP_INTENT:
return getHelpResponse();
case CANCEL_INTENT:
case STOP_INTENT:
PlainTextOutputSpeech outputSpeech = new PlainTextOutputSpeech();
outputSpeech.setText("Ok");
return SpeechletResponse.newTellResponse(outputSpeech);
default:
throw new SpeechletException("Unknown Intent: " + intent.getName());
}
}
示例9: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> request) {
logger.debug("onIntent");
final Intent intent = request.getRequest().getIntent();
final String intentName = intent.getName();
for (IntentHandler handler : intentHandlers) {
if (handler.name().equals(intentName)) {
return handler.handleIntent(intent);
}
}
return IntentHandler.buildSpeechletResponse("Error", true);
}
示例10: createNlpIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
protected NlpIntent createNlpIntent(final Intent intent) {
final String intentName = intent.getName();
final NlpIntent result = new NlpIntent();
result.setName(intentName.toLowerCase());
result.setConfidence(1.0);
return result;
}
示例11: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(IntentRequest intentRequest, Session session) throws SpeechletException {
log.info("onIntent requestId={}, sessionId={}", intentRequest.getRequestId(),
session.getSessionId());
Intent intent = intentRequest.getIntent();
String intentName = (intent != null) ? intent.getName() : null;
for (IIntentHandler intentHandler : getIntentHandlers()) {
if (intentHandler.getIntentName().equals(intentName)) {
return intentHandler.handleIntentRequest(intent, session);
}
}
return getUnknownIntentResponse(false);
}
示例12: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(final IntentRequest request, final Session session)
throws SpeechletException {
provideSessionForRequest(session);
Intent intent = request.getIntent();
String intentName = (intent != null) ? intent.getName() : null;
return dispatchIntent(intentName, intent, session);
}
示例13: onIntent
import com.amazon.speech.slu.Intent; //导入方法依赖的package包/类
@Override
public SpeechletResponse onIntent(
final IntentRequest request, final Session session)
throws SpeechletException {
log.info("onIntent requestId={}, sessionId={}", request.getRequestId(),
session.getSessionId());
Intent intent = request.getIntent();
String intentName = intent.getName();
// Route the intent to the proper handlers.
switch(intentName) {
case "QueryIntent":
return queryHandler.respond(intent, session);
case "RefineIntent":
return refineHandler.respond(intent, session);
case "ClarifyIntent":
return clarifyHandler.respond(intent, session);
case "PlotIntent":
return plotHandler.respond(intent, session);
case "ClearIntent":
return clearHandler.respond(intent, session);
case "AMAZON.HelpIntent":
return helpHandler.respond(intent, session);
case "AMAZON.StopIntent":
return Response.bye(session);
case "AMAZON.CancelIntent":
return Response.bye(session);
case "AMAZON.NoIntent":
return Response.bye(session);
default:
throw new SpeechletException("Invalid Intent: " + intentName);
}
}