Beispiel #1
0
        /// <summary>
        /// Создает канал для вебсервиса словаря словоформ
        /// </summary>
        /// <returns>канал вебсервиса словаря словоформ</returns>
        internal Ilib5 CreateWordFormsChannel()
        {
            Ilib5 wordFormsService = wordFormsFactory.CreateChannel();

            ((IClientChannel)wordFormsService).Open();
            return(wordFormsService);
        }
Beispiel #2
0
        public void CreateWordFormsChannelTest()
        {
            SemanticHelper target   = new SemanticHelper(); // TODO: Initialize to an appropriate value
            Ilib5          expected = null;                 // TODO: Initialize to an appropriate value
            Ilib5          actual;

            actual = target.CreateWordFormsChannel();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Beispiel #3
0
        /// <summary>
        /// находит все исходные формы слова
        /// </summary>
        /// <param name="sParent">слово родитель</param>
        /// <param name="sAnyFormWord">слово из правой части словарной статьи</param>
        /// <param name="explChannel">канал толкового словаря</param>
        /// <param name="relGroupId">номер группы отношений. используется если одно слово имеет несколько равнозначных исходных форм</param>
        /// <returns>список потомков с снайденным типом связи</returns>
        List <WordLink> GetChildren(string sParent, string sAnyFormWord, IExplDic explChannel, short relGroupId)
        {
            Ilib5           wordFormsChannel = null;
            List <WordLink> listChildren     = null;

            try
            {
                listChildren = new List <WordLink>();
                if (sAnyFormWord.Length == 0)
                {
                    return(listChildren);
                }

                wordFormsChannel = CreateWordFormsChannel();

                WordUniAndPartAndOmon[] forms = wordFormsChannel.getAllFirstWFormsWithParts(sAnyFormWord);

                foreach (WordUniAndPartAndOmon form in forms)
                {
                    string s             = form.part;
                    string sOriginalForm = form.forma;
                    if (IsNoun(form.part))
                    {
                        sOriginalForm = RemoveAccents(sOriginalForm);
                        if (sOriginalForm.Length > 0)
                        {
                            //can this be equal to zero?
                            int nVal = explChannel.ExplCheckReestr(sOriginalForm, form.omon, m_LsId);
                            if (nVal < 0 && form.omon != 0)
                            {
                                nVal          = explChannel.ExplCheckReestr(sOriginalForm, 0, m_LsId);
                                sOriginalForm = RegistryWord.CreateNameWithHomonym(sOriginalForm, string.Empty);
                            }
                            else
                            {
                                sOriginalForm = RegistryWord.CreateNameWithHomonym(sOriginalForm, form.omon == 0 ? string.Empty : form.omon.ToString());
                            }

                            lock (m_dbHelper)
                            {
                                RelationItem newItem = m_dbHelper.GetRelationItem(sParent, sOriginalForm);
                                if (newItem == null)
                                {
                                    RelationType relType = (nVal < 0) ? RelationType.Absent : (listChildren.Count > 0 ? RelationType.Tentative : RelationType.Normal);
                                    newItem = m_dbHelper.AddRelation(sParent, sOriginalForm, relType, relGroupId);
                                }
                                WordItem aWord = m_dbHelper.GetWord(sOriginalForm);
                                WordLink aLink = new WordLink(newItem, aWord);
                                if (!listChildren.Contains(aLink))
                                {
                                    listChildren.Add(aLink);
                                }
                            }
                        }
                    }
                }

                ((IClientChannel)wordFormsChannel).Close();
            }
            catch (Exception ex)
            {
                if (wordFormsChannel != null)
                {
                    ((IClientChannel)wordFormsChannel).Abort();
                }
                MessageBox.Show(string.Format("{0} {1}", "GetChildren", ex.Message));
            }

            return(listChildren);
        }