예제 #1
0
 public WordLink(RelationItem anItem, WordItem sChild)
 {
     m_sChild      = new RegistryWord(sChild);
     m_bAuto       = anItem.IsAuto;
     m_eLinkType   = (WordLinkType)anItem.RelationType;
     m_nRelGroupId = (short?)anItem.RelationTypeGroup;
 }
예제 #2
0
 public WordLink(RegistryWord sChild, bool bAuto, WordLinkType eType, short relGroupId)
 {
     m_sChild      = sChild;
     m_bAuto       = bAuto;
     m_eLinkType   = eType;
     m_nRelGroupId = relGroupId;
 }
예제 #3
0
 /// <summary>
 /// обновляет статус слова в БД
 /// </summary>
 /// <param name="aWord">слово из БД</param>
 /// <param name="eStatus">новый статус</param>
 /// <returns>слов с обновленным статусом</returns>
 public RegistryWord UpdateWordStatus(RegistryWord aWord, WordStatus eStatus)
 {
     lock (m_dbHelper)
     {
         aWord.Status = eStatus;
         return(new RegistryWord(m_dbHelper.SetStatus(aWord.Word, (DatabaseHelper.WordStatus)eStatus, aWord.Homonym, aWord.Reviewed)));
     }
 }
예제 #4
0
        /// <summary>
        /// Обновляет коллекцию семантических ветвей после запроса списка слов из толкового словаря
        /// </summary>
        /// <param name="nLowerBound">нижняя граница слов, которые надо получить из толкового словаря</param>
        /// <param name="collection" out>коллекция которую надо обновить информацией их толкового словаря</param>
        public void AddDictionaryWords(int nLowerBound, ObservableCollection <WordSemanticBranch> collection)
        {
            //for debug purposes
            //return;
            IExplDic aDic = null;

            try
            {
                aDic = CreateChannel();
                //int nMaxRows = aDic.GetRowCount(string.Empty, false, null, false, m_LsId);
                int nRequestLowerBound = nLowerBound - ROWS_PER_PAGE / 2;
                if (nRequestLowerBound < 1)
                {
                    nRequestLowerBound = 1;
                }
                ExplDictService.elList[] page = aDic.SupplyPageOfData(nRequestLowerBound, ROWS_PER_PAGE, true, string.Empty, false, null, false, m_LsId);
                foreach (ExplDictService.elList elem in page)
                {
                    WordSemanticBranch newBranch = GetSemanticLinkFromDB(RegistryWord.CreateNameWithHomonym(elem.word, elem.omon));
                    if (newBranch == null)
                    {
                        newBranch            = new WordSemanticBranch();
                        newBranch.ParentWord = new RegistryWord(elem);
                    }

                    int nIndex = collection.IndexOf(newBranch);
                    if (nIndex < 0)
                    {
                        collection.Add(newBranch);
                    }
                    else
                    {
                        collection[nIndex] = newBranch;
                    }
                }
                ((IClientChannel)aDic).Close();
            }
            catch (Exception ex)
            {
                if (aDic != null)
                {
                    ((IClientChannel)aDic).Abort();
                }
                MessageBox.Show(string.Format("{0} {1}", "AddDictionaryWords", ex.Message));
            }
        }
예제 #5
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);
        }