private void UpdateKB()
        {
            System.Diagnostics.Debug.Assert(m_aEC != null);
            AddKBEntry dlg = new AddKBEntry(SelectedWord, SelectedWord, m_fontSource, m_fontTarget);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
#if !MovedToEncCnvtrs
                try
                {
                    m_aEC.AddEntryPair(dlg.Source, dlg.Target, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(String.Format("Unable to access the knowledge base because:{0}{0}{1}",
                                                  Environment.NewLine, ex.Message), DiscourseChartForm.cstrCaption);
                }

                m_bTurnOffSelectedIndexChange = true;
                SelectedWord = dlg.Target;
                m_bTurnOffSelectedIndexChange = false;
#else
                AdaptItKnowledgeBase aikb = new AdaptItKnowledgeBase();
                string strKbPath          = m_aEC.GetEncConverter.ConverterIdentifier;
                aikb.ReadXml(strKbPath);
                if ((aikb.KB.Count > 0) && (aikb.MAP.Count > 0))
                {
                    // first see if there's already a row with this word in it (in which case, we just add a new entry)
                    if (!FindExistingEntry(aikb, strKbPath, dlg.Source, dlg.Target))
                    {
                        AdaptItKnowledgeBase.TURow aTURow = aikb.TU.AddTURow("0", dlg.Source, aikb.MAP[0]);
                        aikb.RS.AddRSRow("1", dlg.Target, aTURow);
                        aikb.WriteXml(strKbPath);
                    }

                    m_bTurnOffSelectedIndexChange = true;
                    SelectedWord = dlg.Target;
                    m_bTurnOffSelectedIndexChange = false;
                }
#endif
            }
        }
Exemplo n.º 2
0
		private void UpdateKB()
		{
			System.Diagnostics.Debug.Assert(m_aEC != null);
			AddKBEntry dlg = new AddKBEntry(SelectedWord, SelectedWord, m_fontSource, m_fontTarget);
			if (dlg.ShowDialog() == DialogResult.OK)
			{
#if !MovedToEncCnvtrs
				try
				{
					m_aEC.AddEntryPair(dlg.Source, dlg.Target);
				}
				catch (Exception ex)
				{
					MessageBox.Show(String.Format("Unable to access the knowledge base because:{0}{0}{1}",
						Environment.NewLine, ex.Message), DiscourseChartForm.cstrCaption);
				}

				m_bTurnOffSelectedIndexChange = true;
				SelectedWord = dlg.Target;
				m_bTurnOffSelectedIndexChange = false;
#else
				AdaptItKnowledgeBase aikb = new AdaptItKnowledgeBase();
				string strKbPath = m_aEC.GetEncConverter.ConverterIdentifier;
				aikb.ReadXml(strKbPath);
				if ((aikb.KB.Count > 0) && (aikb.MAP.Count > 0))
				{
					// first see if there's already a row with this word in it (in which case, we just add a new entry)
					if (!FindExistingEntry(aikb, strKbPath, dlg.Source, dlg.Target))
					{
						AdaptItKnowledgeBase.TURow aTURow = aikb.TU.AddTURow("0", dlg.Source, aikb.MAP[0]);
						aikb.RS.AddRSRow("1", dlg.Target, aTURow);
						aikb.WriteXml(strKbPath);
					}

					m_bTurnOffSelectedIndexChange = true;
					SelectedWord = dlg.Target;
					m_bTurnOffSelectedIndexChange = false;
				}
#endif
			}
		}