Example #1
0
        //---------------------------------------------------------------------------------

        //로컬 Lable DB를 바탕으로 대화셋 내 대화를 분류
        public void CategorizeSet(DialogueSet objDialogueSet)
        {
            foreach (Dialogue objDialogue in objDialogueSet.DialogueList.Values)
            {
                Categorize(objDialogue);
            }
        }
Example #2
0
 public void addDialogueID(DialogueSet set)
 {
     if (set.whatDialogueType == 1)
     {
         MiscData.completedTavernDialogues.Add(set.gameObject.name);
     }
     else if (set.whatDialogueType == 2)
     {
         MiscData.completedEntryDungeonDialogues.Add(set.gameObject.name);
     }
     else if (set.whatDialogueType == 4)
     {
         MiscData.completedExamineDialogues.Add(set.gameObject.name);
     }
     else if (set.whatDialogueType == 5)
     {
         MiscData.completedShopDialogues.Add(set.gameObject.name);
     }
     else if (set.whatDialogueType == 7)
     {
         MiscData.completedStoryDialogues.Add(set.gameObject.name);
         if (set.checkPointDialogue == true)
         {
             MiscData.completedCheckPoints.Add(set.gameObject.name);
         }
     }
     else if (set.whatDialogueType == 8)
     {
         MiscData.completedUniqueRoomsDialogues.Add(set.gameObject.name);
     }
     else if (set.whatDialogueType == 6)
     {
         MiscData.completedHubReturnDialogues.Add(set.gameObject.name);
     }
 }
Example #3
0
    public List <int> fetchRequirements(int dialogueID)
    {
        if (dialogueReqs.Count != dialogueSet.Count)
        {
            string             dialogue    = System.IO.File.ReadAllText(Path.Combine(Application.streamingAssetsPath, "Dialogue.json"));
            List <DialogueSet> allDialogue = new List <DialogueSet>(JsonHelper.getJsonArray <DialogueSet>(dialogue));
            foreach (int d in dialogueSet)
            {
                for (int i = allDialogue.Count - 1; i >= 0; i--)
                {
                    DialogueSet ds = allDialogue[i];
                    if (ds.id == d)
                    {
                        DiaReq newDR = new DiaReq();
                        newDR.diaID = ds.id;
                        newDR.Req   = ds.requirement;
                        allDialogue.Remove(ds);
                        dialogueReqs.Add(newDR);
                    }
                }
            }
        }

        foreach (DiaReq dr in dialogueReqs)
        {
            if (dr.diaID == dialogueID)
            {
                return(new List <int>(dr.Req));
            }
        }


        return(new List <int>(new int[] { -1 }));
    }
Example #4
0
        public override void LoadFromXml(SecurityElement element)
        {
            if ((element.Tag == "Dialogue") && (element.Children != null))
            {
                foreach (SecurityElement element2 in element.Children)
                {
                    string tag = element2.Tag;
                    if (tag != null)
                    {
                        if (tag != "DialogueSet")
                        {
                            if (tag == "PlayerPortraitIcon")
                            {
                                goto Label_0084;
                            }
                            if (tag == "PlayerAssistantPortraitIcon")
                            {
                                goto Label_00A2;
                            }
                        }
                        else
                        {
                            DialogueSet item = this.LoadDialogueSetFromXml(element2);
                            this._dialogueSets.Add(item);
                        }
                    }
                    continue;
Label_0084:
                    this.playerPortraitIcons.Add(StrParser.ParseHexInt(element2.Attribute("Id"), 0));
                    continue;
Label_00A2:
                    this.playerAssistantPortraitIcons.Add(StrParser.ParseHexInt(element2.Attribute("Id"), 0));
                }
            }
        }
Example #5
0
    private void EndDialogue()
    {
        Debug.Log("finished dialogue");

        // stop coroutine
        StopCoroutine(BeginDialogue());

        // clear dialogue box data
        DialogueName.text = "";
        DialogueText.text = "";

        // clear NPC dialogue set
        CurrentSet = null;

        // clear dialogue buffer
        CurrentDialogue.Clear();
        CurrentDialogue = new Queue <string>();

        // disable dialogue box
        DialogueBox.enabled = !DialogueBox.enabled;

        // remove invoke for security
        OnProgressClick.RemoveListener(Progress);

        // reset conversation state to initial state
        isRunningDialogue       = false;
        hasConversationFinished = false;
    }
        public override void PrepareObjective()
        {
            originalDialogue = NPC.GetDialogue();
            NPC.SetDialogue(Dialogue);

            PreparationDone();
        }
Example #7
0
    // get speaker's data from npc and commence conversation setup
    public void HandleSpeakerData(NPCData data)
    {
        // slot in data
        CurrentName = data.NPCName;
        CurrentSet  = data.NPCDialogue;

        HandleDialogue();
    }
    public DialogueNodeInfo(Node n) : base(n)
    {
        DialogueNode dn = (DialogueNode)n;

        charName  = dn.myCharacter.name;
        name      = charName + ":" + name;
        myDialSet = new DialogueSet(dn.lst_dial, dn.GetNextNodeName());
    }
Example #9
0
    IEnumerator turnOffDialoguer()
    {
        if (targetDialogue.substituteMusic != "")
        {
            FindObjectOfType <AudioManager>().FadeOut(targetDialogue.substituteMusic, 0.2f);
        }

        if (slideInAnimation == false)
        {
            blackOverlayAnimator.enabled = true;
            blackOverlayAnimator.SetTrigger("FadeOut");
            yield return(new WaitForSeconds(1f));
        }
        else
        {
            dialogueText.transform.parent.gameObject.SetActive(false);
            LeanTween.move(character1.gameObject, character1.transform.position + Vector3.left * 600, 0.25f);
            LeanTween.move(character2.gameObject, character2.transform.position + Vector3.left * 600, 0.25f);
            LeanTween.move(character3.gameObject, character3.transform.position + Vector3.right * 600, 0.25f);
            LeanTween.move(character4.gameObject, character4.transform.position + Vector3.right * 600, 0.25f);
            LeanTween.value(1, 0, 0.5f).setOnUpdate((float val) => dialogueBackground.color = dialogueBackground.color = new Color(1, 1, 1, val));
            yield return(new WaitForSeconds(0.25f));
        }

        if (slideInAnimation == false)
        {
            blackOverlayAnimator.SetTrigger("FadeIn");
        }

        if (targetDialogue.originalMusic != "")
        {
            if (targetDialogue.originalMusic == "Dungeon Ambiance")
            {
                FindObjectOfType <AudioManager>().UnMuteSound(targetDialogue.originalMusic);
            }
            else
            {
                FindObjectOfType <AudioManager>().FadeIn(targetDialogue.originalMusic, 0.2f, .5f);
            }
        }

        this.gameObject.SetActive(false);

        if (slideInAnimation)
        {
            character1.transform.position += Vector3.right * 600;
            character2.transform.position += Vector3.right * 600;
            character3.transform.position += Vector3.left * 600;
            character4.transform.position += Vector3.left * 600;
        }

        targetDialogue = null;
        endAction?.Invoke();
        endAction = null;
        playerScript.playerDead        = false;
        playerScript.windowAlreadyOpen = false;
        loaded = false;
    }
    public static int[] dActions         = new int[1]; //Unless I find a better way to do this, this number will have to be changed whenever there a new dialogue-resultant method is made


    public static void SetUpDialogue(TextAsset textFile)
    {
        //string path = filePath;
        //StreamReader dialogueReader = new StreamReader(path);
        string textString = textFile.text;

        IEnumerator reader = textString.GetEnumerator();

        reader.MoveNext();
        string dialogueSizeString = GetElement(reader);
        int    dialogueSize       = Int32.Parse(dialogueSizeString);

        DialogueSet[] dSetArray = new DialogueSet[dialogueSize]; //This is the one variable of the public static DialogueScript class object


        for (int i = 0; i < dSetArray.Length; i++) //For each spot in the dSetArray, create and add a dialogue set to dSetArray
        {
            string gameDialogue = GetElement(reader);


            string     choiceSetSizeString = GetElement(reader);
            int        choiceSetSize       = Int32.Parse(choiceSetSizeString);
            DAChoice[] choiceSet           = new DAChoice[choiceSetSize];



            for (int j = 0; j < choiceSet.Length; j++) //For each dialogue choice in the set, create and add a DAChoice to choiceSet
            {
                DAChoice thisChoice = new DAChoice();

                string choiceDialogue = GetElement(reader);
                thisChoice.dialogue = choiceDialogue;


                string nextSetString = GetElement(reader);
                thisChoice.nextSet = Int32.Parse(nextSetString);


                string actionString = GetElement(reader);
                if (actionString == "-1")
                {
                    thisChoice.executedAction = -1;
                }
                else
                {
                    thisChoice.executedAction = Int32.Parse(actionString);
                }

                choiceSet[j] = thisChoice;
            }
            DialogueSet thisDialogueSet = new DialogueSet(); //Done making the dialogue/action choice array, so we can create the dialogue set, set up the values, then add it
            thisDialogueSet.choiceSets  = choiceSet;
            thisDialogueSet.npcDialogue = gameDialogue;
            dSetArray[i] = thisDialogueSet;
        }

        dScript.dialogueSets = dSetArray; //Done making all sets, so dScript's dialogueSets can be set to dSetArray
    }
Example #11
0
 private void UpdateDialogue(DialogueSet.Dialogue d, DialogueSet dSet)
 {
     if (d.expression != "")
     {
         speakerImage.anim = dSet.character.GetExpression(d.expression);
         speakerImage.Play();
     }
     dialogueText.UpdateText(d.text);
 }
        public void CreateLableDB_Offline(DialogueSet dialogueSet)
        {
            //대화가 하나도 없으면 아무것도 하지 않음.
            if (dialogueSet.DialogueList.Count <= 0)
            {
                return;
            }

            CreateDBProgressEvent("내장 분석기로 예측하는 중...[2/4]");

            //PredictionEngine을 통해 dialogue의 레이블을 예측
            PredictionEngine predEngine;

            try
            {
                predEngine = new PredictionEngine();
            }
            catch
            {
                CreateDBProgressEvent("[ERROR] 내장 분석기 오류 발생! 분류를 중단합니다. (PredictEngine)");
                return;
            }

            Dictionary <string, int[]> receivedData;

            try
            {
                receivedData = predEngine.Predict(dialogueSet);
            }
            catch (Exception e)
            {
                CreateDBProgressEvent("[ERROR] 내장 분석기 오류 발생! 분류를 중단합니다. (Predict)");
                return;
            }

            CreateDBProgressEvent("예측 성공. 레이블을 로컬 DB에 삽입하는 중...[3/4]");
            //받은 결과값들을 하나하나 DB에 넣는다.
            foreach (KeyValuePair <string, int[]> data in receivedData)
            {
                Dialogue newDialogue = new Dialogue();
                newDialogue.Address = data.Key;

                for (int i = 0; i < Dialogue.Lable_COUNT; i++)
                {
                    newDialogue.Lables[i] = data.Value[i];
                }

                newDialogue.Thread_id = MessageDBManager.Get().GetThreadId(newDialogue.Address);

                InsertOrUpdate(newDialogue);
            }

            CreateDBProgressEvent("레이블을 메모리에 올리는 중...[4/4]");
            //DB를 메모리에 올림
            Load();
        }
Example #13
0
 private void CreateSets(string text)
 {
     string[] splits = { "<><><>" };
     string[] temp = text.Split(splits, System.StringSplitOptions.RemoveEmptyEntries);
     sets = new DialogueSet[temp.Length];
     for (int i = 0; i < sets.Length; i++)
     {
         sets[i] = new DialogueSet(temp[i]);
     }
 }
Example #14
0
    private IEnumerator DisplayDialogues()
    {
        dialogueText.text = "";
        dialoguePlaying   = true;

        // Initialize view
        DialogueSet dialogueSet = dialogueSets[0];

        nameText.text              = dialogueSet.character.characterName;
        nameText.color             = dialogueSet.character.nameColor;
        dialogueText.textBox.color = dialogueSet.character.textColor;
        speakerImage.anim          = dialogueSet.character.GetExpression(dialogueSet.dialogues[0].expression);
        speakerImage.Play();

        yield return(new WaitForSeconds(0.5f));             // Wait for UI to animate in

        int i = 0;

        while (i < dialogueSets.Length)
        {
            dialogueSet                = dialogueSets[i];
            nameText.text              = dialogueSet.character.characterName;
            nameText.color             = dialogueSet.character.nameColor;
            dialogueText.textBox.color = dialogueSet.character.textColor;
            dialogueText.SetScrollAudio(dialogueSet.character.voice);

            int j = 0;
            while (j < dialogueSet.dialogues.Length)
            {
                DialogueSet.Dialogue dialogue = dialogueSet.dialogues[j];
                UpdateDialogue(dialogue, dialogueSet);
                willAcceptScreenPress = false;
                while (dialogueText.IsTextScrolling())
                {
                    yield return(null);
                }
                yield return(new WaitForSeconds(0.2f));                         // Prevents the player from accidentally skipping things

                willAcceptScreenPress = true;
                while (!proceed)
                {
                    yield return(null);
                }
                proceed = false;
                j++;
            }
            i++;
        }
        gameObject.SetActive(false);
        dialoguePlaying = false;
        if (onDialogueFinished != null)
        {
            onDialogueFinished();
        }
    }
Example #15
0
    public void LoadDialogueUI(DialogueSet dialogueSet, float waitReveal, UnityAction endAction = null, bool slideInAnimation = false)
    {
        this.slideInAnimation = slideInAnimation;
        targetDialogue        = dialogueSet;
        this.gameObject.SetActive(true);
        blackOverlayAnimator.gameObject.SetActive(!slideInAnimation);

        playerScript.windowAlreadyOpen = true;
        StartCoroutine(loadDialogue(waitReveal));
        this.endAction = endAction;
    }
Example #16
0
    //初期化
    protected override void DogInit()
    {
        var lang = FindObjectOfType <CommonManager>().PlayLang;

        _dialogueSet = lang == Lang.ja ? dialogueSet_ja : dialogueSet_en;
        //BGM鳴らすなどをここで入れる。
        _subtitleCanvas = FindObjectOfType <SubtitleCanvas>();
        if (_subtitleCanvas == null)
        {
            Debug.LogError("subtitleCanvas is not found");
        }
    }
Example #17
0
    //load the dialogue json
    void loadDialogue(int id)
    {
        string dialogue = System.IO.File.ReadAllText(Path.Combine(Application.streamingAssetsPath, "Dialogue.json"));

        DialogueSet[] allDialogue = JsonHelper.getJsonArray <DialogueSet>(dialogue);
        for (int i = 0; i < allDialogue.Length; i++)
        {
            if (allDialogue[i].id == id)
            {
                currentDialogue = allDialogue[i];
                break;
            }
        }
    }
Example #18
0
    public void SetDialogue(DialogueSet dialogue)
    {
        if (dialogue != null)
        {
            pickupScript.SetInteractionEnabled(true);

            Dialogue = dialogue;

            if (dialogue.AutoStart)
            {
                EnterInteraction();
                //dialogue.PushDialogue(gameObject);
            }
        }
    }
Example #19
0
        //MMS DB 조회하여 address, thread_id만 수집한 목록을 반환함.
        private DialogueSet LoadMMSMetaDatas()
        {
            DialogueSet dialogueSet = new DialogueSet();

            ContentResolver cr  = Application.Context.ContentResolver;
            Uri             uri = Uri.Parse("content://mms/");

            string[] projection = new string[] { "DISTINCT thread_id", "_id", "ct_t" };
            string   selection  = "thread_id IS NOT NULL) GROUP BY (thread_id";
            ICursor  cursor     = cr.Query(uri, projection, selection, null, null);

            if (cursor != null)
            {
                if (cursor.Count > 0)
                {
                    while (cursor.MoveToNext())
                    {
                        string id        = cursor.GetString(cursor.GetColumnIndex("_id"));
                        string mmsType   = cursor.GetString(cursor.GetColumnIndex("ct_t"));
                        long   thread_id = cursor.GetLong(cursor.GetColumnIndexOrThrow("thread_id"));
                        if ("application/vnd.wap.multipart.related".Equals(mmsType) || "application/vnd.wap.multipart.mixed".Equals(mmsType))
                        {
                            //this is MMS
                            Dialogue objDialogue = new Dialogue();
                            objDialogue.Thread_id = thread_id;
                            objDialogue.Address   = GetAddress(id);

                            if (!dialogueSet.IsContain(thread_id))
                            {
                                dialogueSet.DialogueList.Add(thread_id, objDialogue);
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine("DEBUG : LoadMMSMetaDatas duplication thread_id");
                            }
                        }
                        else
                        {
                            //this is SMS
                            //throw new Exception("알 수 없는 MMS 유형");
                        }
                    }
                }
                cursor.Close();
            }
            return(dialogueSet);
        }
Example #20
0
    private void TransferDialogue(DialogueSet dialogue, GameObject sender)
    {
        if (Dialogue != null)
        {
            if (Dialogue.HasPrimary() || dialogue.HasSecondary())
            {
                Dialogue.OnDialogueEnded += ExitInteraction;

                if (Dialogue.FreezePlayerInDialogue)
                {
                    SetPlayerRestriction(true);
                }

                Dialogue.PushDialogue(sender);
                pushedDialogue = true;
            }
        }
    }
        //모든 Lable 데이터를 DB에서 불러온다.
        public DialogueSet Load(Context context)
        {
            SQLiteDatabase db = new MySQLiteOpenHelper(context).ReadableDatabase;

            ICursor cursor = db.Query(_TABLE_NAME, new string[]
            {
                _ColumnNameStr[(int)COLUMN_NAME.THREAD_ID],
                _ColumnNameStr[(int)COLUMN_NAME.ADDRESS],
                _ColumnNameStr[(int)COLUMN_NAME.LABLE_COMMON],
                _ColumnNameStr[(int)COLUMN_NAME.LABLE_DELIVERY],
                _ColumnNameStr[(int)COLUMN_NAME.LABLE_CARD],
                _ColumnNameStr[(int)COLUMN_NAME.LABLE_IDENTIFICATION],
                _ColumnNameStr[(int)COLUMN_NAME.LABLE_PUBLIC],
                _ColumnNameStr[(int)COLUMN_NAME.LABLE_AGENCY],
                _ColumnNameStr[(int)COLUMN_NAME.LABLE_ETC],
            },
                                      null, null, null, null, null);

            DialogueSet result = null;

            if (cursor != null)
            {
                result = new DialogueSet();
                while (cursor.MoveToNext())
                {
                    Dialogue objDialogue = new Dialogue();
                    objDialogue.Thread_id = cursor.GetLong(0);
                    objDialogue.Address   = cursor.GetString(1);

                    for (int i = 0; i < Dialogue.Lable_COUNT; i++)   //DB의 2~8행까지 데이터를 0~6번 레이블에 저장
                    {
                        objDialogue.Lables[i] = cursor.GetInt(i + 2);
                    }
                    result.InsertOrUpdate(objDialogue);
                }
            }

            cursor.Close();
            db.Close();
            return(result);
        }
Example #22
0
        private DialogueSet LoadDialogueSetFromXml(SecurityElement element)
        {
            DialogueSet set = new DialogueSet {
                dialogueSetId  = StrParser.ParseHexInt(element.Attribute("DialogueSetId"), 0),
                combatDialogue = StrParser.ParseBool(element.Attribute("CombatDialogue"), false)
            };

            if (element.Children != null)
            {
                for (int i = 0; i < element.Children.Count; i++)
                {
                    string          str;
                    SecurityElement element2 = element.Children[i] as SecurityElement;
                    if (((str = element2.Tag) != null) && (str == "Dialogues"))
                    {
                        set.dialogues.Add(this.LoadDialoguesFromXml(element2, i));
                    }
                }
            }
            return(set);
        }
Example #23
0
    // Used to put the ship in a different setting before moving them to the main player hub

    private void initializeUnlockWeaponDialogues()
    {
        switch (MiscData.dungeonLevelUnlocked)
        {
        case 2:
            DialogueSet dialogueSet = loadDialogue(weaponUnlockDialogues[0]);
            if (!MiscData.completedHubReturnDialogues.Contains(dialogueSet.gameObject.name))
            {
                returnNotifications.dialoguesToDisplay.Add(dialogueSet);
            }
            break;

        case 3:
            DialogueSet set = loadDialogue(weaponUnlockDialogues[1]);
            if (!MiscData.completedHubReturnDialogues.Contains(set.gameObject.name))
            {
                returnNotifications.dialoguesToDisplay.Add(set);
            }
            break;
        }
    }
Example #24
0
        //연락처에 없는 대화 중 수신 메시지만 메모리에 올린다. inboxType으로 송신/수신 메시지만 불러오는것도 가능.
        public void LoadUnknownMetaDatas()
        {
            //SMS, MMS 메타데이터(주소와 thread_id)만 수집
            DialogueSet smsMetaDatas = LoadSMSMetaDatas();
            DialogueSet mmsMetaDatas = LoadMMSMetaDatas();

            //mms메타데이터와 smsMetaData를 병합, sms메타데이터 리스트에 mms메타데이터를 넣는다.
            foreach (Dialogue objDialogue in mmsMetaDatas.DialogueList.Values)
            {
                //mms만 있는 경우 리스트에 추가
                if (!smsMetaDatas.IsContain(objDialogue.Thread_id))
                {
                    smsMetaDatas.DialogueList.Add(objDialogue.Thread_id, objDialogue);
                }
                //mms와 sms가 둘다 있는 경우 sms 리스트에 mms를 하나씩 추가함.
                else
                {
                    foreach (MultiMediaMessage mms in objDialogue.TextMessageList)
                    {
                        smsMetaDatas.DialogueList[objDialogue.Thread_id].Add(mms);
                    }
                }
            }

            //연락처에 없는 놈들만 찾는다.
            foreach (Dialogue objDialogue in smsMetaDatas.DialogueList.Values)
            {
                if (ContactDBManager.Get().GetContactDataByAddress(objDialogue.Address, false) == null)
                {
                    if (!_UnknownDialogueSet.IsContain(objDialogue.Thread_id))
                    {
                        _UnknownDialogueSet.DialogueList.Add(objDialogue.Thread_id, objDialogue);
                    }
                    else
                    {
                        _UnknownDialogueSet.DialogueList[objDialogue.Thread_id] = objDialogue;
                    }
                }
            }
        }
Example #25
0
        //-------------------------------------------------------------
        //처음사용자용

        //SMS DB 조회하여 address, thread_id만 수집한 목록을 반환함.
        private DialogueSet LoadSMSMetaDatas()
        {
            DialogueSet dialogueSet = new DialogueSet();

            ContentResolver cr = Application.Context.ContentResolver;

            Uri uri = Uri.Parse("content://sms/");

            string[] projection = { "DISTINCT address", "thread_id" };
            string   selection  = "address IS NOT NULL) GROUP BY (address";
            ICursor  cursor     = cr.Query(uri, projection, selection, null, null);

            if (cursor != null)
            {
                if (cursor.Count > 0)
                {
                    while (cursor.MoveToNext())
                    {
                        string address   = cursor.GetString(cursor.GetColumnIndexOrThrow("address"));
                        long   thread_id = cursor.GetLong(cursor.GetColumnIndexOrThrow("thread_id"));

                        Dialogue objDialogue = new Dialogue();
                        objDialogue.Address   = address;
                        objDialogue.Thread_id = thread_id;

                        if (!dialogueSet.IsContain(thread_id))
                        {
                            dialogueSet.DialogueList.Add(thread_id, objDialogue);
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("DEBUG : LoadSMSMetaDatas duplication thread_id");
                        }
                    }
                }
                cursor.Close();
            }
            return(dialogueSet);
        }
Example #26
0
    IEnumerator TalkMultiDialog(DialogueSet _dialSet)
    {
        for (int i = 0; i < _dialSet.dialogs.Count; i++)
        {
            yield return(StartCoroutine(IE_TalkDialog(_dialSet.dialogs[i], !DialogObj.activeSelf)));

            bool clickNextDialogue = false;
            while (!clickNextDialogue)
            {
                if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.E))
                {
                    RaycastHit2D hit = MouseClick(Input.mousePosition);
                    if (hit.collider == null)                           //沒有點擊到其他UI則繼續對話
                    {
                        clickNextDialogue = true;
                    }
                }
                yield return(null);
            }
        }
        StartNextDialogue(_dialSet.nextKey);
    }
        public Dictionary <string, int[]> Predict(DialogueSet dialogueSet)
        {
            //string 연락처  int[] 7개 카테고리의 레이블 수
            Dictionary <string, int[]> receivedDatas = new Dictionary <string, int[]>();
            DataEmbedding dataEmbedding = new DataEmbedding();

            // dialogueSet에 있는 전화번호와 문자메시지에서 유사도를 측정
            foreach (var elem in dialogueSet.DialogueList.Values)
            {
                int[] receive_labels = new int[Dialogue.Lable_COUNT];

                foreach (var textMessage in elem.TextMessageList)
                {
                    //문자메시지에 대해 훈련된 문서로 유사도를 분석

                    Similarity[] sim = tfidf.Similarities(dataEmbedding.to_ngram(dataEmbedding.del_digit(textMessage.Msg), 4));

                    //가장 높은 유사도를 가지는 문서의 레이블을 가져옴
                    Similarity maxObj;
                    if (sim.Length > 1)
                    {
                        maxObj = sim.Aggregate((i1, i2) => i1.similarity > i2.similarity ? i1 : i2);
                    }
                    else if (sim.Length == 1)
                    {
                        maxObj = new Similarity(sim[0].label, sim[0].similarity);
                    }
                    else
                    {
                        maxObj = new Similarity(7, 0);
                    }

                    //System.Diagnostics.Debug.WriteLine("유사도 : " + maxObj.similarity + " 레이블 : " + maxObj.label);
                    receive_labels[maxObj.label - 1]++;
                }
                receivedDatas.Add(elem.Address, receive_labels);
            }
            return(receivedDatas);
        }
Example #28
0
        public void RefreshRecyclerView()
        {
            //데이터 준비 : 현재 탭에 해당되는 대화목록을 가져온다.
            if (_Category == (int)Dialogue.LableType.ALL)
            {
                _DialogueSet = MessageDBManager.Get().TotalDialogueSet;
            }
            else if (_Category == (int)Dialogue.LableType.UNKNOWN)
            {
                _DialogueSet = MessageDBManager.Get().UnknownDialogueSet;
            }
            else
            {
                _DialogueSet = MessageDBManager.Get().DialogueSets[_Category];
            }

            //대화가 있으면 리사이클러 뷰 내용안에 표시하도록 함
            if (_DialogueSet.Count > 0)
            {
                DialogueSetAdpater adapter = new DialogueSetAdpater(_DialogueSet, _Category, _LayoutManager);
                _RecyclerView.SetAdapter(adapter);
            }
            else
            {
                //문자가 없으면 없다고 알려준다.
                _GuideText.Visibility    = ViewStates.Visible;
                _RecyclerView.Visibility = ViewStates.Gone;

                if (MainActivity._Instance._MessageLoadedOnce)
                {
                    _GuideText.Text = "메시지가 존재하지 않습니다";
                }
                else
                {
                    _GuideText.Text = "메시지를 불러오는 중";
                }
            }
        }
        //WelcomeActivity에서 호출되는, 처음하는 레이블 분류.
        public void CreateLableDB(DialogueSet dialogueSet)
        {
            //대화가 하나도 없으면 아무것도 하지 않음.
            if (dialogueSet.DialogueList.Count <= 0)
            {
                return;
            }

            CreateDBProgressEvent("서버에 전송 및 수신하는 중...[2/4]");
            Dictionary <string, int[]> receivedData = NetworkManager.Get().GetLablesFromServer(dialogueSet);                             //서버에서 데이터를 받는다.

            //서버 통신 실패시 아무것도 하지 않음.
            if (receivedData == null || receivedData.Count == 0)
            {
                return;
            }

            CreateDBProgressEvent("수신 성공. 레이블을 로컬 DB에 삽입하는 중...[3/4]");
            //받은 결과값들을 하나하나 DB에 넣는다.
            foreach (KeyValuePair <string, int[]> data in receivedData)
            {
                Dialogue newDialogue = new Dialogue();
                newDialogue.Address = data.Key;

                for (int i = 0; i < Dialogue.Lable_COUNT; i++)
                {
                    newDialogue.Lables[i] = data.Value[i];
                }

                newDialogue.Thread_id = MessageDBManager.Get().GetThreadId(newDialogue.Address);

                InsertOrUpdate(newDialogue);
            }

            CreateDBProgressEvent("레이블을 메모리에 올리는 중...[4/4]");
            //DB를 메모리에 올림
            Load();
        }
Example #30
0
        private void ResetDialogueSet()
        {
            if (_DialogueSets != null)
            {
                foreach (DialogueSet objSet in _DialogueSets)
                {
                    objSet.Clear();
                }
                _DialogueSets.Clear();
                _TotalDialogueSet.Clear();
                _UnknownDialogueSet.Clear();
            }

            for (int i = 0; i < Dialogue.Lable_COUNT; i++)
            {
                _DialogueSets.Add(new DialogueSet(i));
                _DialogueSets[i].Lable = i;
            }
            _TotalDialogueSet         = new DialogueSet();
            _TotalDialogueSet.Lable   = (int)Dialogue.LableType.ALL;
            _UnknownDialogueSet       = new DialogueSet();
            _UnknownDialogueSet.Lable = (int)Dialogue.LableType.UNKNOWN;
        }