当前位置: 首页>>代码示例>>Java>>正文


Java Intent.getName方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:19,代码来源:RequestDispatcher.java

示例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());
    }
}
 
开发者ID:qaware,项目名称:iot-hessen-amazon-echo,代码行数:19,代码来源:WarehouseSpeechlet.java

示例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;
}
 
开发者ID:jneong,项目名称:CS370_Echo_Demo,代码行数:22,代码来源:KnockKnockConversation.java

示例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;
}
 
开发者ID:jneong,项目名称:CS370_Echo_Demo,代码行数:22,代码来源:TemplateBaseSkillSpeechlet.java

示例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");
	}
}
 
开发者ID:bellissimo,项目名称:AlexaSky,代码行数:26,代码来源:SkySpeechlet.java

示例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");
    }

}
 
开发者ID:itzg,项目名称:alexa-notes,代码行数:24,代码来源:NoteTakerSpeechlet.java

示例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.");
    }
}
 
开发者ID:mapbox,项目名称:mapbox-assistant-example,代码行数:32,代码来源:MapboxSpeechlet.java

示例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());
  }
}
 
开发者ID:comtel2000,项目名称:fritz-home-skill,代码行数:41,代码来源:FritzHomeSpeechlet.java

示例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);
}
 
开发者ID:hennroja,项目名称:rh-dropwizard-alexa,代码行数:16,代码来源:AlexaSpeechlet.java

示例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;
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:9,代码来源:AlexaReceiveMessageFactoryImpl.java

示例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);
}
 
开发者ID:KayLerch,项目名称:alexa-morser-coder-skill,代码行数:15,代码来源:AbstractSpeechlet.java

示例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);
}
 
开发者ID:rs22,项目名称:alexa-routing,代码行数:10,代码来源:RoutingSpeechlet.java

示例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);
  }
}
 
开发者ID:vqtran,项目名称:EchoQuery,代码行数:35,代码来源:EchoQuerySpeechlet.java


注:本文中的com.amazon.speech.slu.Intent.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。