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


Java Result类代码示例

本文整理汇总了Java中ai.api.model.Result的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Result类属于ai.api.model包,在下文中一共展示了Result类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createNlpContext

import ai.api.model.Result; //导入依赖的package包/类
protected NlpContext createNlpContext(final Result aiResponseResult) {
	final NlpContext result = new NlpContext();

	if (aiResponseResult.getMetadata() != null) {
		final NlpIntent nlpIntent = createNlpIntent(aiResponseResult);
		result.addIntent(nlpIntent);
	}

	if (aiResponseResult.getParameters() != null) {
		for (final Entry<String, JsonElement> entry : aiResponseResult.getParameters().entrySet()) {
			final NlpNamedEntity nlpNamedEntity = createNamedEntity(entry);
			result.addNamedEntity(nlpNamedEntity);
		}
	}

	return result;
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:18,代码来源:ApiAiReceiveMessageFactoryImpl.java

示例2: createReceiveMessage

import ai.api.model.Result; //导入依赖的package包/类
@Override
public ReceiveMessage createReceiveMessage(final AIResponse aiResponse, final Map<String, String[]> params) {
	final ReceiveMessage result = new ReceiveMessage();
	result.setMessageId(aiResponse.getId());

	final Participant sender = createParticipant(aiResponse);
	result.setSender(sender);

	final Participant recipient = createParticipant(aiResponse);
	result.setRecipient(recipient);

	result.setNativePayload(ApiAiPlatformEnum.APIAI, aiResponse);

	if (params != null) {
		result.getParams().putAll(params);
	}

	final Result aiResponseResult = aiResponse.getResult();

	if (aiResponseResult != null) {
		final TextReceivePayload payload = createPayload(aiResponseResult);
		result.addPayload(payload);
	}

	return result;
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:27,代码来源:ApiAiReceiveMessageFactoryImpl.java

示例3: testReceiveMessage

import ai.api.model.Result; //导入依赖的package包/类
@Test
public void testReceiveMessage() {
	final Metadata metadata = new Metadata();
	metadata.setIntentName(intentName);

	final Result result = new Result();
	result.setMetadata(metadata);

	final AIResponse aiResponse = new AIResponse();
	aiResponse.setId(messageId);
	aiResponse.setResult(result);
	aiResponse.setSessionId(senderId);

	final ReceiveMessage receiveMessage = apiAiReceiveMessageFactory.createReceiveMessage(aiResponse, null);
	assertEquals(receiveMessage.getSender().getId(), senderId);
	assertEquals(receiveMessage.getMessageId(), messageId);

	assertEquals(receiveMessage.getPayloads().get(0).getClass(), TextReceivePayload.class);
	final TextReceivePayload textReceivePayload = (TextReceivePayload) receiveMessage.getPayloads().get(0);
	assertEquals(intentName, textReceivePayload.getNlpContext().getMaxIntent().getName());
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:22,代码来源:ApiAiMessageTest.java

示例4: createNlpIntent

import ai.api.model.Result; //导入依赖的package包/类
protected NlpIntent createNlpIntent(final Result aiResponseResult) {
	final Metadata metadata = aiResponseResult.getMetadata();
	final String intentName = metadata.getIntentName();

	final NlpIntent result = new NlpIntent();
	result.setName(intentName.toLowerCase());
	result.setConfidence(1.0);
	return result;
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:10,代码来源:ApiAiReceiveMessageFactoryImpl.java

示例5: createPayload

import ai.api.model.Result; //导入依赖的package包/类
protected TextReceivePayload createPayload(final Result aiResponseResult) {
	final String text = aiResponseResult.getResolvedQuery();
	final TextReceivePayload result = new TextReceivePayload();
	result.setText(text);

	final NlpContext nlpContext = createNlpContext(aiResponseResult);
	result.setNlpContext(nlpContext);
	return result;
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:10,代码来源:ApiAiReceiveMessageFactoryImpl.java

示例6: onResult

import ai.api.model.Result; //导入依赖的package包/类
@Override
public void onResult(final AIResponse response) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Log.d(TAG, "onResult");

            resultTextView.setText(gson.toJson(response));

            Log.i(TAG, "Received success response");

            // this is example how to get different parts of result object
            final Status status = response.getStatus();
            Log.i(TAG, "Status code: " + status.getCode());
            Log.i(TAG, "Status type: " + status.getErrorType());

            final Result result = response.getResult();
            Log.i(TAG, "Resolved query: " + result.getResolvedQuery());

            Log.i(TAG, "Action: " + result.getAction());

            final String speech = result.getFulfillment().getSpeech();
            Log.i(TAG, "Speech: " + speech);
            TTS.speak(speech);

            final Metadata metadata = result.getMetadata();
            if (metadata != null) {
                Log.i(TAG, "Intent id: " + metadata.getIntentId());
                Log.i(TAG, "Intent name: " + metadata.getIntentName());
            }

            final HashMap<String, JsonElement> params = result.getParameters();
            if (params != null && !params.isEmpty()) {
                Log.i(TAG, "Parameters: ");
                for (final Map.Entry<String, JsonElement> entry : params.entrySet()) {
                    Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString()));
                }
            }
        }

    });
}
 
开发者ID:dialogflow,项目名称:dialogflow-android-client,代码行数:43,代码来源:AIServiceSampleActivity.java

示例7: onResult

import ai.api.model.Result; //导入依赖的package包/类
@Override
public void onResult(final AIResponse response) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Log.d(TAG, "onResult");

            resultTextView.setText(gson.toJson(response));

            Log.i(TAG, "Received success response");

            // this is example how to get different parts of result object
            final Status status = response.getStatus();
            Log.i(TAG, "Status code: " + status.getCode());
            Log.i(TAG, "Status type: " + status.getErrorType());

            final Result result = response.getResult();
            Log.i(TAG, "Resolved query: " + result.getResolvedQuery());

            Log.i(TAG, "Action: " + result.getAction());
            final String speech = result.getFulfillment().getSpeech();
            Log.i(TAG, "Speech: " + speech);
            TTS.speak(speech);

            final Metadata metadata = result.getMetadata();
            if (metadata != null) {
                Log.i(TAG, "Intent id: " + metadata.getIntentId());
                Log.i(TAG, "Intent name: " + metadata.getIntentName());
            }

            final HashMap<String, JsonElement> params = result.getParameters();
            if (params != null && !params.isEmpty()) {
                Log.i(TAG, "Parameters: ");
                for (final Map.Entry<String, JsonElement> entry : params.entrySet()) {
                    Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString()));
                }
            }
        }

    });
}
 
开发者ID:dialogflow,项目名称:dialogflow-android-client,代码行数:42,代码来源:AIDialogSampleActivity.java

示例8: onResult

import ai.api.model.Result; //导入依赖的package包/类
private void onResult(final AIResponse response) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Log.d(TAG, "onResult");

            resultTextView.setText(gson.toJson(response));

            Log.i(TAG, "Received success response");

            // this is example how to get different parts of result object
            final Status status = response.getStatus();
            Log.i(TAG, "Status code: " + status.getCode());
            Log.i(TAG, "Status type: " + status.getErrorType());

            final Result result = response.getResult();
            Log.i(TAG, "Resolved query: " + result.getResolvedQuery());

            Log.i(TAG, "Action: " + result.getAction());

            final String speech = result.getFulfillment().getSpeech();
            Log.i(TAG, "Speech: " + speech);
            TTS.speak(speech);

            final Metadata metadata = result.getMetadata();
            if (metadata != null) {
                Log.i(TAG, "Intent id: " + metadata.getIntentId());
                Log.i(TAG, "Intent name: " + metadata.getIntentName());
            }

            final HashMap<String, JsonElement> params = result.getParameters();
            if (params != null && !params.isEmpty()) {
                Log.i(TAG, "Parameters: ");
                for (final Map.Entry<String, JsonElement> entry : params.entrySet()) {
                    Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString()));
                }
            }
        }

    });
}
 
开发者ID:dialogflow,项目名称:dialogflow-android-client,代码行数:42,代码来源:AITextSampleActivity.java


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