0

을 인식 할 수 없습니다. 또 다른 단일 watson sdk 질문입니다.
가짜 개체를 다시 만들어 첫 번째 대화 문제를 해결했습니다 ..
여기에 또 다른 문제가 있습니다.unity3d에서 IBM IBM chatbot이 순차 코드

내 채팅 봇에서는 동일한 의도가있는 경우 순차적 텍스트를 볼 수 있습니다.

어떤 라인을 변경하거나 추가해야합니까?

(또 다른 질문 : 어떤 라인은 내가 아주 순차적 텍스트에 대한 질문을 따르지 않는 내가 변경하거나 내 연합 방법 '에 점프'를 가지고 추가해야합니까

using IBM.Watson.DeveloperCloud.Services.Conversation.v1; 
using IBM.Watson.DeveloperCloud.Utilities; 
using System; 
using System.Collections.Generic; 
using UnityEngine; 

class Watson : MonoBehaviour{  
static Credentials credentials; 
static Conversation _conversation; 
void Start() 
{ 
    credentials = new Credentials("xx-xx-xx-xx-xx", "xx", "https://gateway.watsonplatform.net/conversation/api"); 
    // credentials.Url = ""; 
    _conversation = new Conversation(credentials); 

} 
static Action<string, ManagerChat.Feel, bool> Act; 
public static void GoMessage(string _str,Action<string, ManagerChat.Feel,bool> _act) 
{ 

    if (!_conversation.Message(OnMessage, "xx-xx-xx-xx-xx", _str)) 
     Debug.Log("ExampleConversation Failed to message!"); 

    Act = _act; 
} 

static bool GetIntent(Dictionary<string, object> respDict) 
{ 
    object intents; 
    respDict.TryGetValue("intents", out intents); 

    object intentString = new object(); 

    object confidenceString = new object(); 

    foreach (var intentObj in (intents as List<object>)) 
    { 
     Dictionary<string, object> intentDict = intentObj as Dictionary<string, object>; 

     intentDict.TryGetValue("intent", out intentString); 


     intentDict.TryGetValue("confidence", out confidenceString); 
    } 
    string str = intentString as string; 

    if (str == "6사용자_마무리") 
     return true; 

    return false; 

} 

static string GetOutput(Dictionary<string, object> respDict) 
{ 
    object outputs; 
    respDict.TryGetValue("output", out outputs); 

    object output; 
    (outputs as Dictionary<string, object>).TryGetValue("text", out output); 

    string var = (output as List<object>)[0] as string; 

    return var; 
} 

static ManagerChat.Feel GetEntities(Dictionary<string, object> respDict) 
{ 
    object entities; 
    respDict.TryGetValue("entities", out entities); 

    List<object> entitieList = (entities as List<object>); 

    if(entitieList.Count == 0) 
    { 
     return ManagerChat.Feel.Normal; 
    } 
    else 
    { 
     object entitie; 
     (entitieList[0] as Dictionary<string, object>).TryGetValue("value", out entitie); 
     ManagerChat.Feel feel = ManagerChat.Feel.NONE; 

     string str = entitie as string; 

     switch (str) 
     { 
      case "Happy": 
       feel = ManagerChat.Feel.Happy; 
       break; 
      case "Expect": 
       feel = ManagerChat.Feel.Expect; 
       break; 
      case "Born": 
       feel = ManagerChat.Feel.Born; 
       break; 
      case "Sad": 
       feel = ManagerChat.Feel.Sad; 
       break; 
      case "Surprise": 
       feel = ManagerChat.Feel.Surprise; 
       break; 
      case "Normal": 
       feel = ManagerChat.Feel.Normal; 
       break; 
      default: 
       break; 
     } 

     return feel; 
    } 
} 

static void OnMessage(object resp, string data) 
{ 
    Dictionary<string, object> respDict = resp as Dictionary<string, object>; 

    bool flag = (GetIntent(respDict)); 

    string output = (GetOutput(respDict)); 

    ManagerChat.Feel feel = GetEntities(respDict); 
    //  Debug.Log(resp); 
    //  Debug.Log(data); 
     Act(output,feel, flag); 
    } 
} 

답변

0

,하지만 난 생각? 응용 프로그램 코드에서 필요한 것보다 더 많은 작업을하려고 할 수 있습니다. sdk를 사용하는 방법에 대한 높은 수준의 패턴을 제공하고이를 지워야하는지 확인해 보겠습니다. Unity는 없지만 패턴은 동일합니다. 언어와 상관없이 Watson에게 사용자의 입력 텍스트와 기존 컨텍스트 변수, 가장 중요한 시스템 컨텍스트를 제공하면되지만 사용자가 만든 사용자 지정 컨텍스트는 유용합니다. 그러면 Watson은 사용자에게 게시하는 output.text 개체를 반환하고 Watson은 업데이트 된 시스템 컨텍스트를 반환합니다. 다음으로 사용자가 새로운 것을 입력하면 앱이 해당 텍스트를 가져와 지난 번 반환 한 컨텍스트 개체와 함께 Watson에 전달하고 프로세스가 반복됩니다.

점프 대상, 순차적 텍스트 등 모든 작업은 왓슨에서 처리하므로 앱 코드에서 아무 것도하지 않아도됩니다.

순차적 조각에 대해 생각할 수있는 유일한 기능은 단일 대화 노드의 응답 변형입니다. 이 기능은 사용자가 특정 대화 상자 노드를 여러 번 방문하면 연속 된 순서 또는 여러 개가있는 경우 임의의 순서로 다른 응답을 제공함을 의미합니다. 동일한 노드로 여러 번 탐색하여 사용자로부터 하나 이상의 입력이 필요합니다. 이것은 로봇에게 'hello', 'googbye', 'thanks'등과 같은 공통 입력에 가장 유용한 몇 가지 변형을 제공하는 것입니다.

관련 문제