Beispiel #1
0
 public ShowHyperRun(WordSemanticBranch aLink, int nDeep, int nCurDeep, bool bNewBranch)
 {
     DeepSearch = nDeep;
     CurDeep    = nCurDeep;
     m_Link     = aLink;
     NewBranch  = bNewBranch;
 }
 public EditRelationsWindow(WordSemanticBranch aLink)
 {
     InitializeComponent();
     m_Link = aLink;
     lvChildren.ItemsSource = aLink.Children;
     this.Title             = string.Format("{0} {1}", this.Title, aLink.ParentWord.Word);
 }
Beispiel #3
0
        public void StartCreateHyper(object showRun)
        {
            try
            {
                ShowHyperRun curRun = (ShowHyperRun)showRun;
                if (curRun.CurDeep > curRun.DeepSearch || Interlocked.Read(ref StopCreateHyper) == 0)
                {
                    return;
                }

                //WordSemanticBranch newBranch = m_SemanticHelper.GetSemanticLinkFromDB(curRun.CurDeep == 1 ? "тест2" : curRun.WordLink.ParentWord.Word);
                WordSemanticBranch newBranch = m_SemanticHelper.GetSemanticLinkFromDB(curRun.WordLink.ParentWord.Word);
                curRun.WordLink = newBranch;
                OnHyperChainAdded(new HyperChainAddedEventArgs(curRun));
                int  nNewDeepSearch = curRun.DeepSearch - 1;
                bool bNewBranch     = false;
                foreach (WordLink link in newBranch.Children)
                {
                    WordSemanticBranch childBranch = m_SemanticHelper.GetSemanticLinkFromDB(link.Child.Word);
                    if (childBranch != null &&
                        (link.RelationType == WordLinkType.eNormal ||
                         link.RelationType == WordLinkType.eTentative))
                    {
                        StartCreateHyper(new ShowHyperRun(childBranch, curRun.DeepSearch, curRun.CurDeep + 1, bNewBranch));
                    }
                    bNewBranch = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}\n{1}", "CLientLogic.StartSearch", ex.Message));
            }
        }
Beispiel #4
0
 public SearchRun(WordSemanticBranch aLink, int nDeep, bool bForce, int nCurDeep)
 {
     WordToSearch = aLink.ParentWord.Word;
     DeepSearch   = nDeep;
     ForceSearch  = bForce;
     CurDeep      = nCurDeep;
     MaxDeep      = nDeep;
     m_Link       = aLink;
 }
Beispiel #5
0
        public void GetSemanticLinkFromDBTest()
        {
            SemanticHelper     target   = new SemanticHelper(); // TODO: Initialize to an appropriate value
            string             sWord    = string.Empty;         // TODO: Initialize to an appropriate value
            WordSemanticBranch expected = null;                 // TODO: Initialize to an appropriate value
            WordSemanticBranch actual;

            actual = target.GetSemanticLinkFromDB(sWord);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Beispiel #6
0
        private void Edit_Handler(object sender, EventArgs e)
        {
            WordSemanticBranch aLink = (WordSemanticBranch)lvRegisrtyWords.SelectedItem;

            //SemanticHelper h = new SemanticHelper();
            //aLink = h.GetSemanticLinkFromDB("тест2");

            if (aLink == null)
            {
                return;
            }

            EditRelationsWindow wnd = new EditRelationsWindow(aLink);
            bool?bRes = wnd.ShowDialog();

            if (bRes != null && bRes == true)
            {
                CollectionViewSource.GetDefaultView(SearchLogic.ListWords).Refresh();
            }
        }
Beispiel #7
0
        private void Edit_HandlerRuns(object sender, EventArgs e)
        {
            WordSemanticBranch aLink = null;

            SearchRun selectedRun = (SearchRun)lvRuns.SelectedItem;

            if (selectedRun != null)
            {
                aLink = selectedRun.WordLink;
            }

            if (aLink == null)
            {
                return;
            }

            EditRelationsWindow wnd = new EditRelationsWindow(aLink);
            bool?bRes = wnd.ShowDialog();

            if (bRes != null && bRes == true)
            {
                CollectionViewSource.GetDefaultView(SearchLogic.ListWords).Refresh();
            }
        }
Beispiel #8
0
        //private WordSemanticLink GetSemanticLink(SearchRun searchRun)
        //{
        //    return null;
        //    //WordSemanticLink link = semanticHelper.GetSemanticLink(searchRun.WordToSearch);
        //    //return link;
        //    //if (m_dbHelper.GetStatus(searchRun.WordToSearch) != WordStatus.eCompleted || searchRun.ForceSeacrh)
        //    //{
        //    //    WordSemanticLink link = semanticHelper.GetSemanticLink(searchRun.WordToSearch);
        //    //    return link;
        //    //}
        //    //else
        //    //{
        //    //    WordSemanticLink link = GetSemanticLink(searchRun.WordToSearch);
        //    //    return link;
        //    //}

        //}

        private void UpdateDatabases(WordSemanticBranch aLink)
        {
            //WordItem anItem = new WordItem();
            //anItem.Word = aLink.
        }
Beispiel #9
0
        public void Search(SearchRun searchRun)
        {
            try
            {
                WordSemanticBranch lnk = null;

                if (!searchRun.ForceSearch)
                {
                    lnk = m_SemanticHelper.GetSemanticLinkFromDB(searchRun.WordLink.ParentWord.Word);

                    if (lnk != null)
                    {
                        if (lnk.ParentWord.Status == WordStatus.eNotProcessed)
                        {
                            lnk = null;
                        }
                    }
                }

                if (lnk == null)
                {
                    m_SemanticHelper.UpdateWordStatus(searchRun.WordLink.ParentWord, WordStatus.eInProgress);
                    OnExplProcessed(new ExplProcessedEventArgs(searchRun, false));
                    GetSemanticLink(searchRun);
                }
                else
                {
                    //searchRun.WordLink = lnk;
                }

                //m_SemanticHelper.UpdateWordStatus(curRun.WordLink.ParentWord, WordStatus.eNotProcessed);//WordStatus.eInProgress);
                //OnExplProcessed(new ExplProcessedEventArgs(curRun, false));

                //searchRun.WordLink =
                //GetSemanticLink(searchRun);
                //WordSemanticLink link = GetSemanticLink(searchRun);
                //if (!m_ListLinks.Keys.Contains(searchRun.WordToSearch))
                //{
                //    m_ListLinks.Add(link.ParentWord.Word, link);
                //    OnExplProcessed(new ExplProcessedEventArgs(searchRun, true));
                //}

                int nNewDeepSearch = searchRun.DeepSearch - 1;
                foreach (WordLink aLink in searchRun.WordLink.Children)
                {
                    if (aLink.RelationType == WordLinkType.eNormal ||
                        aLink.RelationType == WordLinkType.eTentative)
                    {
                        WordSemanticBranch childLink = m_SemanticHelper.GetSemanticLinkFromDB(aLink.Child.Word);
                        if (childLink == null)
                        {
                            m_SemanticHelper.UpdateWordStatus(aLink.Child, WordStatus.eNotProcessed);
                            childLink            = new WordSemanticBranch();
                            childLink.ParentWord = aLink.Child;
                            m_SemanticHelper.AddDictionaryWord(childLink);
                        }
                        OnExplProcessed(new ExplProcessedEventArgs(new SearchRun(childLink, 0, false, 0), true));

                        ThreadPool.QueueUserWorkItem(new WaitCallback(this.StartSearch), new SearchRun(childLink, searchRun.DeepSearch - 1, searchRun.ForceSearch, searchRun.CurDeep + 1));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}\n{1}", "CLientLogic.Search", ex.Message));
            }
        }