示例#1
0
		public void Add(XmlImportData.PendingLink link)
		{
			var owner = link.FieldInformation.Owner;
			List<XmlImportData.PendingLink> linksForOwner;
			if (!m_lookupLinks.TryGetValue(owner, out linksForOwner))
			{
				linksForOwner = new List<XmlImportData.PendingLink>();
				m_lookupLinks[owner] = linksForOwner;
			}
			linksForOwner.Add(link);
		}
示例#2
0
        private void ProcessLogFile(string processedInputFile, int startPhase, XmlImportData xid)
        {
            string inputFileName = processedInputFile;

            if (startPhase > 0)
            {
                inputFileName = m_sPhase1FileName;
                inputFileName = inputFileName.Replace("1", startPhase.ToString());
            }
            ProcessPhase4Log(inputFileName, xid);

            if (m_fDisplayImportReport)
            {
                string sHtmlFile = Path.Combine(m_sTempDir, "ImportLog.htm");
                using (Process.Start(sHtmlFile))
                {
                }
            }
        }
示例#3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// does the import
        /// </summary>
        /// <param name="dlg">The progress dialog.</param>
        /// <param name="parameters">The parameters: 1) runToCompletion, 2) last step,
        /// 3) start phase, 4) database file name, 5) number of entries, 6) true to display
        /// the import report, 7) name of phase 1 HTML report file, 8) name of phase 1 file.
        /// </param>
        /// <returns><c>true</c> if import was successful, otherwise <c>false</c>.</returns>
        /// ------------------------------------------------------------------------------------
        public object Import(IThreadedProgress dlg, object[] parameters)
        {
            Debug.Assert(parameters.Length == 8);
            bool   runToCompletion  = (bool)parameters[0];
            int    lastStep         = (int)parameters[1];
            int    startPhase       = (int)parameters[2];
            string databaseFileName = (string)parameters[3];
            int    cEntries         = (int)parameters[4];

            m_fDisplayImportReport = (bool)parameters[5];
            m_sPhase1HtmlReport    = (string)parameters[6];
            m_sPhase1FileName      = (string)parameters[7];

            string sErrorMsg          = LexTextControls.ksTransformProblem_X;
            bool   fAttemptedXml      = false;
            string processedInputFile = databaseFileName;
            string sPhase1Output      = Path.Combine(m_sTempDir, s_sPhase1FileName);
            string sPhase2Output      = Path.Combine(m_sTempDir, s_sPhase2FileName);
            string sPhase3Output      = Path.Combine(m_sTempDir, s_sPhase3FileName);

            m_sPhase4Output = Path.Combine(m_sTempDir, s_sPhase4FileName);

            XmlImportData xid = null;

            try
            {
                // if starting with a phase file, rename the phase file with the input file
                switch (startPhase)
                {
                case 1:
                    sPhase1Output = databaseFileName;
                    break;

                case 2:
                    sPhase2Output = databaseFileName;
                    break;

                case 3:
                    sPhase3Output = databaseFileName;
                    break;

                case 4:
                    m_sPhase4Output = databaseFileName;
                    break;

                default:
                    break;                             // no renaming needed
                }

                if (startPhase < 2)
                {
                    dlg.Title = String.Format(LexTextControls.ksImportingXEntriesFromY,
                                              cEntries, processedInputFile);
                    dlg.Message = String.Format(LexTextControls.ksPhase1ofX_Preview, lastStep);
                    sErrorMsg   = LexTextControls.ksTransformProblemPhase1_X;
                    DoTransform(m_sBuildPhase2XSLT, sPhase1Output, m_sPhase2XSLT);
                }
                dlg.Step(10);
                if (dlg.Canceled)
                {
                    return(false);
                }

                sErrorMsg   = LexTextControls.ksTransformProblemPhase2_X;
                dlg.Message = String.Format(LexTextControls.ksPhase2ofX, lastStep);
                if (startPhase < 2)
                {
                    DoTransform(m_sPhase2XSLT, sPhase1Output, sPhase2Output);
                }
                dlg.Step(10);
                if (dlg.Canceled)
                {
                    return(false);
                }

                sErrorMsg   = LexTextControls.ksTransformProblemPhase3_X;
                dlg.Message = String.Format(LexTextControls.ksPhase3ofX, lastStep);
                if (startPhase < 3)
                {
                    DoTransform(m_sPhase3XSLT, sPhase2Output, sPhase3Output);
                }
                dlg.Step(10);
                if (dlg.Canceled)
                {
                    return(false);
                }

                sErrorMsg   = LexTextControls.ksTransformProblemPhase4_X;
                dlg.Message = String.Format(LexTextControls.ksPhase4ofX, lastStep);
                if (startPhase < 4)
                {
                    DoTransform(m_sPhase4XSLT, sPhase3Output, m_sPhase4Output);
                }
                dlg.Step(20);
                if (dlg.Canceled)
                {
                    return(false);
                }

                if (runToCompletion)
                {
                    sErrorMsg   = LexTextControls.ksXmlParsingProblem5_X;
                    dlg.Message = LexTextControls.ksPhase5of5_LoadingData;
                    if (dlg.Canceled)
                    {
                        return(false);
                    }
                    dlg.Step(1);
                    // There's no way to cancel from here on out.
                    dlg.AllowCancel = false;
                    xid             = new XmlImportData(m_cache);
                    fAttemptedXml   = true;
                    if (startPhase == 4 && processedInputFile.Length == 0)
                    {
                        processedInputFile = m_sPhase4Output;
                    }
                    xid.ImportData(m_sPhase4Output, dlg);
                    sErrorMsg = LexTextControls.ksLogFileProblem5_X;
                    ProcessLogFile(processedInputFile, startPhase, xid);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex.Message);

                ReportError(string.Format(sErrorMsg, ex.Message), LexTextControls.ksUnhandledError);

                if (fAttemptedXml)
                {
                    // We want to see the log file even (especially) if the Xml blows up.
                    ProcessLogFile(processedInputFile, startPhase, xid);
                }
            }

            return(false);
        }
示例#4
0
        private void ProcessPhase4Log(string inputFileName, XmlImportData xid)
        {
            string sLogFile = m_sPhase4Output;
            int    ich      = m_sPhase4Output.LastIndexOf('.');

            if (ich != -1)
            {
                sLogFile = m_sPhase4Output.Remove(ich, sLogFile.Length - ich);
            }
            sLogFile += "-Import.log";
            StreamReader sr;

            try
            {
                sr = File.OpenText(sLogFile);
            }
            catch
            {
                return;
            }
            try
            {
                string sHtmlFile = Path.Combine(m_sTempDir, "ImportLog.htm");
                using (StreamWriter sw = File.CreateText(sHtmlFile))
                {
                    sw.WriteLine("<html>");
                    sw.WriteLine("<head>");
                    sw.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>");
                    string sHeadInfo = String.Format(LexTextControls.ksImportLogForX, inputFileName);
                    sw.WriteLine(String.Format("  <title>{0}</title>", sHeadInfo));
                    // add the script
                    string script = GetHtmlJavaScript();
                    sw.WriteLine(script);
                    // done adding the java script for jumping to errors
                    sw.WriteLine("</head>");
                    sw.WriteLine("<body>");
                    sw.WriteLine(String.Format("<h2>{0}</h2>", sHeadInfo));
                    sw.WriteLine(String.Format("<h3>{0}</h3>", LexTextControls.ksMessagesFromPreview));
                    sw.WriteLine(m_sPhase1HtmlReport);
                    string sInput;
                    // LT-1901 : make a first pass through the log file and put all "Warning:" errors together
                    bool   bWarningFound = false;                       // none yet
                    string sWarning_     = LexTextControls.ksWarning_;  // localized version of "Warning:"
                    string sInfo_        = LexTextControls.ksInfo_;     // localized version of "Info:"
                    while ((sInput = sr.ReadLine()) != null)
                    {
                        ich = sInput.IndexOf(sWarning_);
                        if (ich == -1)
                        {
                            ich = sInput.IndexOf("Warning:");                                   // in case warning message not localized...
                        }
                        if (ich != -1)
                        {
                            if (!bWarningFound)                                 // first time put out the header
                            {
                                bWarningFound = true;
                                sw.WriteLine(String.Format("<p><h3>{0}</h3>",
                                                           LexTextControls.ksMayBeBugInImport));
                                sw.WriteLine("<ul>");
                            }

                            // Need to quote any occurrences of <, >, or & in the message text.
                            sInput = sInput.Replace("&", "&amp;");
                            sInput = sInput.Replace("<", "&lt;");
                            sInput = sInput.Replace(">", "&gt;");
                            sw.WriteLine("<li>" + sInput);
                        }
                    }
                    sr.Dispose();
                    sr = File.OpenText(sLogFile);

                    if (bWarningFound)
                    {
                        sw.WriteLine("</ul>");
                    }

                    sw.WriteLine(String.Format("<p><h3>{0}</h3>",
                                               LexTextControls.ksMessagesFromLoading));
                    string sTiming = null;
                    sw.WriteLine("<ul>");

                    string        sPath      = m_sPhase4Output.Replace("\\", "\\\\");
                    List <string> rgsCreated = xid.CreatedForMessages;
                    List <Regex>  rgxMsgs    = new List <Regex>();
                    foreach (string sMsg in rgsCreated)
                    {
                        string sRegex = "^" + sMsg + "$";
                        sRegex = sRegex.Replace("{0}", sPath);
                        sRegex = sRegex.Replace("{1}", "[0-9]+");
                        sRegex = sRegex.Replace("{2}", "[^\"]+");
                        Regex xMsg = new Regex(sRegex);
                        rgxMsgs.Add(xMsg);
                    }

                    string sElapsedTimeMsg = xid.ElapsedTimeMsg;
                    ich = sElapsedTimeMsg.IndexOf("{0:F1}");
                    Debug.Assert(ich >= 0);
                    sElapsedTimeMsg = sElapsedTimeMsg.Substring(0, ich);
                    // Print the Info: messages together, save everything else for a later loop.
                    List <string> rgsNotInfo = new List <string>();
                    while ((sInput = sr.ReadLine()) != null)
                    {
                        // warning msgs were already handled, so don't show them again
                        ich = sInput.IndexOf(sWarning_);
                        if (ich == -1)
                        {
                            ich = sInput.IndexOf("Warning:");                                   // in case warning message not localized...
                        }
                        if (ich != -1)
                        {
                            continue;
                        }
                        ich = sInput.IndexOf(m_sPhase4Output + ":");
                        if (ich != -1)
                        {
                            int ichNumber = ich + m_sPhase4Output.Length + 1;
                            ich = sInput.IndexOf(": ", ichNumber);
                            if (ich != -1)
                            {
                                // Need to quote any occurrences of <, >, or & in the message text.
                                string sOutput = sInput.Remove(0, ich + 2);
                                sOutput = sOutput.Replace("&", "&amp;");
                                sOutput = sOutput.Replace("<", "&lt;");
                                sOutput = sOutput.Replace(">", "&gt;");
                                if (AnyMsgMatches(rgxMsgs, sInput))
                                {
                                    string sNumber = sInput.Substring(ichNumber, ich - ichNumber);
                                    int    hvo;
                                    if (Int32.TryParse(sNumber, out hvo))
                                    {
                                        // Convert text between ichBegin and ichEnd into a link to the Flex entry.
                                        string sLinkRef = LinkRef(hvo);
                                        if (sLinkRef != null)
                                        {
                                            int ichBegin = sOutput.IndexOf('"') + 1;
                                            int ichEnd   = sOutput.IndexOf('"', ichBegin);
                                            Debug.Assert(ichBegin > 0 && ichEnd > ichBegin);
                                            sOutput = sOutput.Insert(ichEnd, "</a>");
                                            sOutput = sOutput.Insert(ichBegin, String.Format("<a href=\"{0}\">", sLinkRef));
                                        }
                                    }
                                }
                                sOutput = sOutput.Insert(0, "<li>");
                                if (sOutput.IndexOf(sInfo_) >= 0 || sOutput.IndexOf("Info:") >= 0)
                                {
                                    sw.WriteLine(sOutput);
                                }
                                else
                                {
                                    rgsNotInfo.Add(sOutput);
                                }
                            }
                        }
                        else
                        {
                            ich = sInput.IndexOf(sElapsedTimeMsg);
                            if (ich != -1)
                            {
                                sTiming = sInput;
                            }
                        }
                    }
                    sr.Close();
                    for (int i = 0; i < rgsNotInfo.Count; ++i)
                    {
                        sw.WriteLine(rgsNotInfo[i]);
                    }
                    sw.WriteLine("</ul>");
                    if (sTiming != null)
                    {
                        sw.WriteLine("<p>" + sTiming);
                    }
                    sw.WriteLine("</body>");
                    sw.WriteLine("</html>");
                    sw.Close();
                }
            }
            finally
            {
                sr.Dispose();
            }
        }
示例#5
0
		private bool Convert6()
		{
			try
			{
				XmlImportData xid = new XmlImportData(m_cache);
				xid.ImportData(m_nextInput, m_progress);
				return true;
			}
			catch
			{
				string sLogFile = Path.Combine(m_sTempDir, m_nextInput);
				ReportError(string.Format(ITextStrings.ksFailedLoadingLL,
					m_LinguaLinksXmlFileName, m_cache.ProjectId.Name,
					Environment.NewLine, sLogFile),
					ITextStrings.ksLLImportFailed);
				return false;
			}

		}
示例#6
0
		private void ProcessPhase4Log(string inputFileName, XmlImportData xid)
		{
			string sLogFile = m_sPhase4Output;
			int ich = m_sPhase4Output.LastIndexOf('.');
			if (ich != -1)
				sLogFile = m_sPhase4Output.Remove(ich, sLogFile.Length - ich);
			sLogFile += "-Import.log";
			StreamReader sr;
			try
			{
				sr = File.OpenText(sLogFile);
			}
			catch
			{
				return;
			}
			try
			{
				string sHtmlFile = Path.Combine(m_sTempDir, "ImportLog.htm");
				using (StreamWriter sw = File.CreateText(sHtmlFile))
				{
					sw.WriteLine("<html>");
					sw.WriteLine("<head>");
					sw.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>");
					string sHeadInfo = String.Format(LexTextControls.ksImportLogForX, inputFileName);
					sw.WriteLine(String.Format("  <title>{0}</title>", sHeadInfo));
					// add the script
					string script = GetHtmlJavaScript();
					sw.WriteLine(script);
					// done adding the java script for jumping to errors
					sw.WriteLine("</head>");
					sw.WriteLine("<body>");
					sw.WriteLine(String.Format("<h2>{0}</h2>", sHeadInfo));
					sw.WriteLine(String.Format("<h3>{0}</h3>", LexTextControls.ksMessagesFromPreview));
					sw.WriteLine(m_sPhase1HtmlReport);
					string sInput;
					// LT-1901 : make a first pass through the log file and put all "Warning:" errors together
					bool bWarningFound = false;	// none yet
					string sWarning_ = LexTextControls.ksWarning_;	// localized version of "Warning:"
					string sInfo_ = LexTextControls.ksInfo_;		// localized version of "Info:"
					while ((sInput = sr.ReadLine()) != null)
					{
						ich = sInput.IndexOf(sWarning_);
						if (ich == -1)
							ich = sInput.IndexOf("Warning:");	// in case warning message not localized...
						if (ich != -1)
						{
							if (!bWarningFound)	// first time put out the header
							{
								bWarningFound = true;
								sw.WriteLine(String.Format("<p><h3>{0}</h3>",
									LexTextControls.ksMayBeBugInImport));
								sw.WriteLine("<ul>");
							}

							// Need to quote any occurrences of <, >, or & in the message text.
							sInput = sInput.Replace("&", "&amp;");
							sInput = sInput.Replace("<", "&lt;");
							sInput = sInput.Replace(">", "&gt;");
							sw.WriteLine("<li>" + sInput);
						}
					}
					sr.Dispose();
					sr = File.OpenText(sLogFile);

					if (bWarningFound)
						sw.WriteLine("</ul>");

					sw.WriteLine(String.Format("<p><h3>{0}</h3>",
						LexTextControls.ksMessagesFromLoading));
					string sTiming = null;
					sw.WriteLine("<ul>");

					string sPath = m_sPhase4Output.Replace("\\", "\\\\");
					List<string> rgsCreated = xid.CreatedForMessages;
					List<Regex> rgxMsgs = new List<Regex>();
					foreach (string sMsg in rgsCreated)
					{
						string sRegex = "^" + sMsg + "$";
						sRegex = sRegex.Replace("{0}", sPath);
						sRegex = sRegex.Replace("{1}", "[0-9]+");
						sRegex = sRegex.Replace("{2}", "[^\"]+");
						Regex xMsg = new Regex(sRegex);
						rgxMsgs.Add(xMsg);
					}

					string sElapsedTimeMsg = xid.ElapsedTimeMsg;
					ich = sElapsedTimeMsg.IndexOf("{0:F1}");
					Debug.Assert(ich >= 0);
					sElapsedTimeMsg = sElapsedTimeMsg.Substring(0, ich);
					// Print the Info: messages together, save everything else for a later loop.
					List<string> rgsNotInfo = new List<string>();
					while ((sInput = sr.ReadLine()) != null)
					{
						// warning msgs were already handled, so don't show them again
						ich = sInput.IndexOf(sWarning_);
						if (ich == -1)
							ich = sInput.IndexOf("Warning:");	// in case warning message not localized...
						if (ich != -1)
							continue;
						ich = sInput.IndexOf(m_sPhase4Output + ":");
						if (ich != -1)
						{
							int ichNumber = ich + m_sPhase4Output.Length + 1;
							ich = sInput.IndexOf(": ", ichNumber);
							if (ich != -1)
							{
								// Need to quote any occurrences of <, >, or & in the message text.
								string sOutput = sInput.Remove(0, ich + 2);
								sOutput = sOutput.Replace("&", "&amp;");
								sOutput = sOutput.Replace("<", "&lt;");
								sOutput = sOutput.Replace(">", "&gt;");
								if (AnyMsgMatches(rgxMsgs, sInput))
								{
									string sNumber = sInput.Substring(ichNumber, ich - ichNumber);
									int hvo;
									if (Int32.TryParse(sNumber, out hvo))
									{
										// Convert text between ichBegin and ichEnd into a link to the Flex entry.
										string sLinkRef = LinkRef(hvo);
										if (sLinkRef != null)
										{
											int ichBegin = sOutput.IndexOf('"') + 1;
											int ichEnd = sOutput.IndexOf('"', ichBegin);
											Debug.Assert(ichBegin > 0 && ichEnd > ichBegin);
											sOutput = sOutput.Insert(ichEnd, "</a>");
											sOutput = sOutput.Insert(ichBegin, String.Format("<a href=\"{0}\">", sLinkRef));
										}
									}
								}
								sOutput = sOutput.Insert(0, "<li>");
								if (sOutput.IndexOf(sInfo_) >= 0 || sOutput.IndexOf("Info:") >= 0)
									sw.WriteLine(sOutput);
								else
									rgsNotInfo.Add(sOutput);
							}
						}
						else
						{
							ich = sInput.IndexOf(sElapsedTimeMsg);
							if (ich != -1)
								sTiming = sInput;
						}
					}
					sr.Close();
					for (int i = 0; i < rgsNotInfo.Count; ++i)
						sw.WriteLine(rgsNotInfo[i]);
					sw.WriteLine("</ul>");
					if (sTiming != null)
						sw.WriteLine("<p>" + sTiming);
					sw.WriteLine("</body>");
					sw.WriteLine("</html>");
					sw.Close();
				}
			}
			finally
			{
				sr.Dispose();
			}
		}
示例#7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// does the import
		/// </summary>
		/// <param name="dlg">The progress dialog.</param>
		/// <param name="parameters">The parameters: 1) runToCompletion, 2) last step,
		/// 3) start phase, 4) database file name, 5) number of entries, 6) true to display
		/// the import report, 7) name of phase 1 HTML report file, 8) name of phase 1 file.
		/// </param>
		/// <returns><c>true</c> if import was successful, otherwise <c>false</c>.</returns>
		/// ------------------------------------------------------------------------------------
		public object Import(IThreadedProgress dlg, object[] parameters)
		{
			Debug.Assert(parameters.Length == 8);
			bool runToCompletion = (bool)parameters[0];
			int lastStep = (int)parameters[1];
			int startPhase = (int)parameters[2];
			string databaseFileName = (string)parameters[3];
			int cEntries = (int)parameters[4];
			m_fDisplayImportReport = (bool)parameters[5];
			m_sPhase1HtmlReport = (string)parameters[6];
			m_sPhase1FileName = (string)parameters[7];

			string sErrorMsg = LexTextControls.ksTransformProblem_X;
			bool fAttemptedXml = false;
			string processedInputFile = databaseFileName;
			string sPhase1Output = Path.Combine(m_sTempDir, s_sPhase1FileName);
			string sPhase2Output = Path.Combine(m_sTempDir, s_sPhase2FileName);
			string sPhase3Output = Path.Combine(m_sTempDir, s_sPhase3FileName);
			m_sPhase4Output = Path.Combine(m_sTempDir, s_sPhase4FileName);

			XmlImportData xid = null;
			try
			{
				// if starting with a phase file, rename the phase file with the input file
				switch (startPhase)
				{
					case 1:
						sPhase1Output = databaseFileName;
						break;
					case 2:
						sPhase2Output = databaseFileName;
						break;
					case 3:
						sPhase3Output = databaseFileName;
						break;
					case 4:
						m_sPhase4Output = databaseFileName;
						break;
					default:
						break; // no renaming needed
				}

				if (startPhase < 2)
				{
					dlg.Title = String.Format(LexTextControls.ksImportingXEntriesFromY,
						cEntries, processedInputFile);
					dlg.Message = String.Format(LexTextControls.ksPhase1ofX_Preview, lastStep);
					sErrorMsg = LexTextControls.ksTransformProblemPhase1_X;
					DoTransform(m_sBuildPhase2XSLT, sPhase1Output, m_sPhase2XSLT);
				}
				dlg.Step(10);
				if (dlg.Canceled)
					return false;

				sErrorMsg = LexTextControls.ksTransformProblemPhase2_X;
				dlg.Message = String.Format(LexTextControls.ksPhase2ofX, lastStep);
				if (startPhase < 2)
					DoTransform(m_sPhase2XSLT, sPhase1Output, sPhase2Output);
				dlg.Step(10);
				if (dlg.Canceled)
					return false;

				sErrorMsg = LexTextControls.ksTransformProblemPhase3_X;
				dlg.Message = String.Format(LexTextControls.ksPhase3ofX, lastStep);
				if (startPhase < 3)
					DoTransform(m_sPhase3XSLT, sPhase2Output, sPhase3Output);
				dlg.Step(10);
				if (dlg.Canceled)
					return false;

				sErrorMsg = LexTextControls.ksTransformProblemPhase4_X;
				dlg.Message = String.Format(LexTextControls.ksPhase4ofX, lastStep);
				if (startPhase < 4)
					DoTransform(m_sPhase4XSLT, sPhase3Output, m_sPhase4Output);
				dlg.Step(20);
				if (dlg.Canceled)
					return false;

				if (runToCompletion)
				{
					sErrorMsg = LexTextControls.ksXmlParsingProblem5_X;
					dlg.Message = LexTextControls.ksPhase5of5_LoadingData;
					if (dlg.Canceled)
						return false;
					dlg.Step(1);
					// There's no way to cancel from here on out.
					dlg.AllowCancel = false;
					xid = new XmlImportData(m_cache);
					fAttemptedXml = true;
					if (startPhase == 4 && processedInputFile.Length == 0)
						processedInputFile = m_sPhase4Output;
					xid.ImportData(m_sPhase4Output, dlg);
					sErrorMsg = LexTextControls.ksLogFileProblem5_X;
					ProcessLogFile(processedInputFile, startPhase, xid);
					return true;
				}
			}
			catch (Exception ex)
			{
				Debug.WriteLine("Error: " + ex.Message);

				ReportError(string.Format(sErrorMsg, ex.Message), LexTextControls.ksUnhandledError);

				if (fAttemptedXml)
				{
					// We want to see the log file even (especially) if the Xml blows up.
					ProcessLogFile(processedInputFile, startPhase, xid);
				}
			}

			return false;
		}
示例#8
0
		public void ImportData1()
		{
			DateTime dtLexOrig = m_cache.LangProject.LexDbOA.DateCreated;
			TimeSpan span = new TimeSpan(dtLexOrig.Ticks - m_now.Ticks);
			Assert.LessOrEqual(span.TotalMinutes, 1.0);		// should be only a second or two...
			XmlImportData xid = new XmlImportData(m_cache);
			using (var rdr = new StringReader(
				"<FwDatabase>" +
				"<LangProject>" +
				"<LexDb>" +
				"<LexDb id=\"I1D5042E0D192A7D\">" +
				"<DateCreated><Time val=\"1995-12-19 10:31:25.000\" /></DateCreated>" +
				"<DateModified><Time val=\"2007-06-25 15:54:13.000\" /></DateModified>" +
				"<Name>" +
				"<AUni ws=\"en\">English Lexical Database</AUni>" +
				"</Name>" +
				"<Entries>" +
				"<LexEntry id=\"I1D504E40D1AA689\">" +
				"<LexemeForm>" +
				"<MoStemAllomorph id=\"I1860116246B081E\">" +
				"<Form>" +
				"<AUni ws=\"qaa-x-ame\">adult</AUni>" +
				"</Form>" +
				"<MorphType><Link ws=\"en\" abbr=\"rt\" name=\"root\" /></MorphType>" +
				"</MoStemAllomorph>" +
				"</LexemeForm>" +
				"<DateCreated><Time val=\"1995-12-20 13:32:57.000\" /></DateCreated>" +
				"<DateModified><Time val=\"2008-05-12 16:36:46.000\" /></DateModified>" +
				"<MorphoSyntaxAnalyses>" +
				"<MoStemMsa id=\"I1860117246B081E\">" +
				"<PartOfSpeech><Link ws=\"en\" abbr=\"com n\" name=\"common noun\" /></PartOfSpeech>" +
				"</MoStemMsa>" +
				"</MorphoSyntaxAnalyses>" +
				"<Senses>" +
				"<LexSense id=\"I1D504E50D1AA689\">" +
				"<MorphoSyntaxAnalysis><Link target=\"I1860117246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" +
				"<Gloss>" +
				"<AUni ws=\"en\">adult</AUni>" +
				"<AUni ws=\"fr\">adulte</AUni>" +
				"</Gloss>" +
				"<Definition>" +
				"<AStr ws=\"en\">" +
				"<Run ws=\"en\">a man or woman who is fully grown up</Run>" +
				"</AStr>" +
				"<AStr ws=\"fr\">" +
				"<Run ws=\"fr\">un homme ou une femme qui est parvenu au terme de la croissance</Run>" +
				"</AStr>" +
				"</Definition>" +
				"<AnthroCodes>" +
				"<Link ws=\"en\" abbr=\"156\" name=\"156 Social Personality\" />" +
				"<Link ws=\"en\" abbr=\"157\" name=\"157 Personality Traits\" />" +
				"<Link ws=\"en\" abbr=\"183\" name=\"183 Norms\" />" +
				"<Link ws=\"en\" abbr=\"828\" name=\"828 Ethnopsychology\" />" +
				"</AnthroCodes>" +
				"<SemanticDomains>" +
				"<Link ws=\"en\" abbr=\"4.3.1.3\" />" +
				"<Link ws=\"en\" abbr=\"4.3.1.3.1\" />" +
				"<Link ws=\"en\" abbr=\"2\" />" +
				"</SemanticDomains>" +
				"</LexSense>" +
				"</Senses>" +
				"</LexEntry>" +
				"</Entries>" +
				"</LexDb>" +
				"</LexDb>" +
				"</LangProject>" +
				"</FwDatabase>"))
			{
			StringBuilder sbLog = new StringBuilder();
			Assert.AreEqual(0, m_cache.LangProject.LexDbOA.Entries.Count(), "The lexicon starts out empty.");
			Assert.AreEqual(0, m_cache.LangProject.AnthroListOA.PossibilitiesOS.Count);
			Assert.AreEqual(0, m_cache.LangProject.SemanticDomainListOA.PossibilitiesOS.Count);
			Assert.AreEqual(0, m_cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Count);
			xid.ImportData(rdr, new StringWriter(sbLog), null);
			DateTime dtLexNew = m_cache.LangProject.LexDbOA.DateCreated;
			DateTime dt2 = new DateTime(1995, 12, 19, 10, 31, 25);
			Assert.AreEqual(dt2, dtLexNew, "LexDb DateCreated changed to reflect import value.");
			Assert.AreEqual(1, m_cache.LangProject.LexDbOA.Entries.Count(), "The import data had one entry.");
			Assert.AreEqual(0, m_cache.LangProject.LexDbOA.ReversalIndexesOC.Count);
			ILexEntry entry = m_cache.LangProject.LexDbOA.Entries.ToArray()[0];
			Assert.IsTrue(entry.LexemeFormOA is IMoStemAllomorph, "The entry is a stem.");
			IMultiUnicode mu = entry.LexemeFormOA.Form;
			Assert.AreEqual(1, mu.StringCount);
			int ws;
			ITsString tss = mu.GetStringFromIndex(0, out ws);
			Assert.AreEqual("adult", tss.Text);
			string sWs = m_cache.WritingSystemFactory.GetStrFromWs(ws);
			Assert.AreEqual("qaa-x-ame", sWs);
			Assert.AreEqual(1, entry.MorphoSyntaxAnalysesOC.Count, "The entry has only one MSA.");
			Assert.AreEqual(1, entry.SensesOS.Count, "The imported entry had one sense.");
			ILexSense sense = entry.SensesOS[0];
			mu = sense.Gloss;
			Assert.AreEqual(2, mu.StringCount, "The gloss is given in two writing systems/languages.");
			int wsEn = m_cache.WritingSystemFactory.GetWsFromStr("en");
			int wsFr = m_cache.WritingSystemFactory.GetWsFromStr("fr");
			tss = mu.get_String(wsEn);
			Assert.AreEqual("adult", tss.Text, "The English gloss imported okay.");
			tss = mu.get_String(wsFr);
			Assert.AreEqual("adulte", tss.Text, "The French gloss imported okay.");
			IMultiString ms = sense.Definition;
			Assert.AreEqual(2, ms.StringCount, "The definition is given in two writing systems/languages.");
			tss = ms.get_String(wsEn);
			ITsString tss0 = m_cache.TsStrFactory.MakeString("a man or woman who is fully grown up", wsEn);
			Assert.IsTrue(tss.Equals(tss0), "The English definition imported okay.");
			tss = ms.get_String(wsFr);
			tss0 = m_cache.TsStrFactory.MakeString("un homme ou une femme qui est parvenu au terme de la croissance", wsFr);
			Assert.IsTrue(tss.Equals(tss0), "The French definition imported okay.");
			Assert.AreEqual(4, sense.AnthroCodesRC.Count, "The sense has 4 anthopology category codes.");
			Assert.AreEqual(3, sense.SemanticDomainsRC.Count, "The sense is linked to 3 semantic domains.");
			Assert.IsTrue(sense.MorphoSyntaxAnalysisRA is IMoStemMsa, "The sense's MSA is a stem type MSA.");
			IMoStemMsa msa = sense.MorphoSyntaxAnalysisRA as IMoStemMsa;
			Assert.AreEqual(msa.Owner, sense.Owner, "The sense's MSA is owned by the sense's owner.");
			string pos = msa.PartOfSpeechRA.Name.get_String(wsEn).Text;
			Assert.AreEqual("common noun", pos, "The sense's part of speech is 'common noun'.");

			Assert.AreEqual(4, m_cache.LangProject.AnthroListOA.PossibilitiesOS.Count);
			ICmPossibility poss = m_cache.LangProject.AnthroListOA.PossibilitiesOS[0];
			Assert.IsTrue(poss is ICmAnthroItem);
			tss = poss.Name.get_String(wsEn);
			Assert.AreEqual("Social Personality", tss.Text);
			tss = poss.Abbreviation.get_String(wsEn);
			Assert.AreEqual("156", tss.Text);
			poss = m_cache.LangProject.AnthroListOA.PossibilitiesOS[1];
			Assert.IsTrue(poss is ICmAnthroItem);
			tss = poss.Name.get_String(wsEn);
			Assert.AreEqual("Personality Traits", tss.Text);
			tss = poss.Abbreviation.get_String(wsEn);
			Assert.AreEqual("157", tss.Text);
			poss = m_cache.LangProject.AnthroListOA.PossibilitiesOS[2];
			Assert.IsTrue(poss is ICmAnthroItem);
			tss = poss.Name.get_String(wsEn);
			Assert.AreEqual("Norms", tss.Text);
			tss = poss.Abbreviation.get_String(wsEn);
			Assert.AreEqual("183", tss.Text);
			poss = m_cache.LangProject.AnthroListOA.PossibilitiesOS[3];
			Assert.IsTrue(poss is ICmAnthroItem);
			tss = poss.Name.get_String(wsEn);
			Assert.AreEqual("Ethnopsychology", tss.Text);
			tss = poss.Abbreviation.get_String(wsEn);
			Assert.AreEqual("828", tss.Text);

			Assert.AreEqual(3, m_cache.LangProject.SemanticDomainListOA.PossibilitiesOS.Count);
			poss = m_cache.LangProject.SemanticDomainListOA.PossibilitiesOS[0];
			Assert.IsTrue(poss is ICmSemanticDomain);
			tss = poss.Name.get_String(wsEn);
			Assert.AreEqual("4.3.1.3", tss.Text);
			tss = poss.Abbreviation.get_String(wsEn);
			Assert.AreEqual("4.3.1.3", tss.Text);
			poss = m_cache.LangProject.SemanticDomainListOA.PossibilitiesOS[1];
			Assert.IsTrue(poss is ICmSemanticDomain);
			tss = poss.Name.get_String(wsEn);
			Assert.AreEqual("4.3.1.3.1", tss.Text);
			tss = poss.Abbreviation.get_String(wsEn);
			Assert.AreEqual("4.3.1.3.1", tss.Text);
			poss = m_cache.LangProject.SemanticDomainListOA.PossibilitiesOS[2];
			Assert.IsTrue(poss is ICmSemanticDomain);
			tss = poss.Name.get_String(wsEn);
			Assert.AreEqual("2", tss.Text);
			tss = poss.Abbreviation.get_String(wsEn);
			Assert.AreEqual("2", tss.Text);

			Assert.AreEqual(1, m_cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Count);
			poss = m_cache.LangProject.PartsOfSpeechOA.PossibilitiesOS[0];
			Assert.IsTrue(poss is IPartOfSpeech);
			tss = poss.Name.get_String(wsEn);
			Assert.AreEqual("common noun", tss.Text);
			tss = poss.Abbreviation.get_String(wsEn);
			Assert.AreEqual("com n", tss.Text);

			IWfiWordformRepository repoWfi = m_cache.ServiceLocator.GetInstance<IWfiWordformRepository>();
			Assert.AreEqual(0, repoWfi.Count);

			string sLog = sbLog.ToString();
			Assert.IsFalse(String.IsNullOrEmpty(sLog), "There should be some log information!");
			string[] rgsLog = sLog.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
			Assert.LessOrEqual(9, rgsLog.Length);
			Assert.AreEqual("data stream:0: Info: Creating new writing system for \"qaa-x-ame\".", rgsLog[0]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"com n\", and name=\"common noun\" in the Parts of Speech list.", rgsLog[1]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"156\", and name=\"Social Personality\" in the Anthropology Categories list.", rgsLog[2]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"157\", and name=\"Personality Traits\" in the Anthropology Categories list.", rgsLog[3]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"183\", and name=\"Norms\" in the Anthropology Categories list.", rgsLog[4]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"828\", and name=\"Ethnopsychology\" in the Anthropology Categories list.", rgsLog[5]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"4.3.1.3\", and name=\"4.3.1.3\" in the Semantic Domain list.", rgsLog[6]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"4.3.1.3.1\", and name=\"4.3.1.3.1\" in the Semantic Domain list.", rgsLog[7]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"2\", and name=\"2\" in the Semantic Domain list.", rgsLog[8]);
		}
		}
示例#9
0
		private void ProcessLogFile(string processedInputFile, int startPhase, XmlImportData xid)
		{
			string inputFileName = processedInputFile;
			if (startPhase > 0)
			{
				inputFileName = m_sPhase1FileName;
				inputFileName = inputFileName.Replace("1", startPhase.ToString());
			}
			ProcessPhase4Log(inputFileName, xid);

			if (m_fDisplayImportReport)
			{
				string sHtmlFile = Path.Combine(m_sTempDir, "ImportLog.htm");
				using (Process.Start(sHtmlFile))
				{
				}
			}
		}
示例#10
0
		//[Ignore("This needs to be rewritten so that imported files are in resources.")]
		public void ImportData3()
		{
			XmlImportData xid = new XmlImportData(m_cache);
			string sFwSrcDir = FwDirectoryFinder.SourceDirectory;
			using (var rdr = new StringReader(
				"<FwDatabase>" + Environment.NewLine +
				"<LangProject>" + Environment.NewLine +
				"<LexDb>" + Environment.NewLine +
				"<LexDb id=\"I1D5042E0D192A7D\">" + Environment.NewLine +
				"<Entries>" + Environment.NewLine +
				"<LexEntry id=\"I1D507650D33C672\">" + Environment.NewLine +
				"<LexemeForm>" + Environment.NewLine +
				"<MoStemAllomorph id=\"I186011A246B081E\">" + Environment.NewLine +
				"<Form><AUni ws=\"qaa-x-ame\">an</AUni></Form>" + Environment.NewLine +
				"<MorphType><Link ws=\"en\" abbr=\"rt\" name=\"root\" /></MorphType>" + Environment.NewLine +
				"</MoStemAllomorph>" + Environment.NewLine +
				"</LexemeForm>" + Environment.NewLine +
				"<AlternateForms>" + Environment.NewLine +
				"<MoStemAllomorph id=\"I186011B246B081E\">" + Environment.NewLine +
				"<Form><AUni ws=\"qaa-x-ame\">a</AUni></Form>" + Environment.NewLine +
				"<MorphType><Link ws=\"en\" abbr=\"rt\" name=\"root\" /></MorphType>" + Environment.NewLine +
				"</MoStemAllomorph>" + Environment.NewLine +
				"</AlternateForms>" + Environment.NewLine +
				"<DateCreated><Time val=\"1996-01-8 14:55:46.000\" /></DateCreated>" + Environment.NewLine +
				"<DateModified><Time val=\"2008-05-12 16:36:46.000\" /></DateModified>" + Environment.NewLine +
				"<Pronunciations>" + Environment.NewLine +
				"<LexPronunciation id=\"I18607B11FBCF4A0\">" + Environment.NewLine +
				"<Form><AUni ws=\"qaa-x-ame-fonipa\">an</AUni></Form>" + Environment.NewLine +
				"<MediaFiles>" + Environment.NewLine +
				"<CmMedia><MediaFile><Link path=\"" +
				Path.Combine(sFwSrcDir, "FDO/FDOTests/TestData/house.wav") +
				"\" /></MediaFile></CmMedia>" + Environment.NewLine +
				"</MediaFiles>" + Environment.NewLine +
				"</LexPronunciation>" + Environment.NewLine +
				"</Pronunciations>" + Environment.NewLine +
				"<MorphoSyntaxAnalyses>" + Environment.NewLine +
				"<MoStemMsa id=\"I186011C246B081E\">" + Environment.NewLine +
				"<PartOfSpeech><Link ws=\"en\" abbr=\"adj, indef art\" name=\"indefinite article\" /></PartOfSpeech>" + Environment.NewLine +
				"</MoStemMsa>" + Environment.NewLine +
				"</MorphoSyntaxAnalyses>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense id=\"I1D507670D33C672\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Link target=\"I186011C246B081E\" class=\"MoMorphoSyntaxAnalysis\" />" + Environment.NewLine +
				"</MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">sense group heading</Run></AStr></Definition>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense id=\"I1D507660D33C672\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I186011C246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">one</AUni></Gloss>" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">one; one sort of</Run></AStr></Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D5087F0D33C9E7\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I186011C246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">any</AUni></Gloss>" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">each; any one</Run></AStr></Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D508C10D33CF1F\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I186011C246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">per</AUni></Gloss>" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">to each; in each; for each;</Run></AStr></Definition>" + Environment.NewLine +
				"<ScientificName><Str><Run ws=\"la\">Latin term</Run></Str></ScientificName>" + Environment.NewLine +
				"<Pictures>" + Environment.NewLine +
				"<CmPicture id=\"I1860A701FBCF6DA\">" + Environment.NewLine +
				"<PictureFile><Link path=\"" +
				Path.Combine(sFwSrcDir, "FDO/FDOTests/TestData/penguin.jpg") +
				"\" /></PictureFile>" + Environment.NewLine +
				"<Caption><AStr ws=\"en\"><Run ws=\"en\">English caption</Run></AStr></Caption>" + Environment.NewLine +
				"</CmPicture>" + Environment.NewLine +
				"</Pictures>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexEntry>" + Environment.NewLine +
				"<LexEntry id=\"I1D501320D3373F8\">" + Environment.NewLine +
				"<EntryRefs>" + Environment.NewLine +
				"<LexEntryRef>" + Environment.NewLine +
				"<VariantEntryTypes><Link ws=\"en\" name=\"Irregularly Inflected Form\" /></VariantEntryTypes>" + Environment.NewLine +
				"<ComponentLexemes><Link target=\"I1D50AF20D2FCBF6\" wsa=\"en\" abbr=\"llcr\" wsv=\"qaa-x-ame\" entry=\"be\" /></ComponentLexemes>" + Environment.NewLine +
				"<Summary><AStr ws=\"en\"><Run ws=\"en\">1ps PRES INDIC</Run></AStr></Summary>" + Environment.NewLine +
				"</LexEntryRef>" + Environment.NewLine +
				"</EntryRefs>" + Environment.NewLine +
				"<LexemeForm>" + Environment.NewLine +
				"<MoStemAllomorph id=\"I1860118246B081E\">" + Environment.NewLine +
				"<Form><AUni ws=\"qaa-x-ame\">am</AUni></Form>" + Environment.NewLine +
				"<MorphType><Link ws=\"en\" abbr=\"stm\" name=\"stem\" /></MorphType>" + Environment.NewLine +
				"</MoStemAllomorph>" + Environment.NewLine +
				"</LexemeForm>" + Environment.NewLine +
				"<DateCreated><Time val=\"1996-01-8 09:03:52.000\" /></DateCreated>" + Environment.NewLine +
				"<DateModified><Time val=\"2008-05-12 16:36:46.000\" /></DateModified>" + Environment.NewLine +
				"<MorphoSyntaxAnalyses><MoStemMsa id=\"I1860119246B081E\" /></MorphoSyntaxAnalyses>" + Environment.NewLine +
				"</LexEntry>" + Environment.NewLine +
				"<LexEntry id=\"I1D50AF20D2FCBF6\">" + Environment.NewLine +
				"<LexemeForm>" + Environment.NewLine +
				"<MoStemAllomorph id=\"I1860121246B081E\">" + Environment.NewLine +
				"<Form><AUni ws=\"qaa-x-ame\">be</AUni></Form>" + Environment.NewLine +
				"<MorphType><Link ws=\"en\" abbr=\"stm\" name=\"stem\" /></MorphType>" + Environment.NewLine +
				"</MoStemAllomorph>" + Environment.NewLine +
				"</LexemeForm>" + Environment.NewLine +
				"<AlternateForms>" + Environment.NewLine +
				"<MoStemAllomorph id=\"I1860122246B081E\">" + Environment.NewLine +
				"<Form><AUni ws=\"qaa-x-ame\">is</AUni></Form>" + Environment.NewLine +
				"<MorphType><Link ws=\"en\" abbr=\"stm\" name=\"stem\" /></MorphType>" + Environment.NewLine +
				"</MoStemAllomorph>" + Environment.NewLine +
				"</AlternateForms>" + Environment.NewLine +
				"<DateCreated><Time val=\"1996-01-5 14:30:14.000\" /></DateCreated>" + Environment.NewLine +
				"<DateModified><Time val=\"2008-05-12 16:36:46.000\" /></DateModified>" + Environment.NewLine +
				"<MorphoSyntaxAnalyses>" + Environment.NewLine +
				"<MoStemMsa id=\"I1860123246B081E\">" + Environment.NewLine +
				"<PartOfSpeech><Link ws=\"en\" abbr=\"vi\" name=\"intransitive verb\" /></PartOfSpeech>" + Environment.NewLine +
				"</MoStemMsa>" + Environment.NewLine +
				"<MoStemMsa id=\"I1860124246B081E\">" + Environment.NewLine +
				"<PartOfSpeech><Link ws=\"en\" abbr=\"aux\" name=\"auxiliary verb\" /></PartOfSpeech>" + Environment.NewLine +
				"</MoStemMsa>" + Environment.NewLine +
				"</MorphoSyntaxAnalyses>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense id=\"I1D50AF40D2FCBF6\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense id=\"I1D503D10D337764\">" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">As a substantive verb:</Run></AStr></Definition>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense id=\"I1D50AF30D2FCBF6\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">exist</AUni></Gloss>" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">to exist; live</Run></AStr></Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D50B470D2FCC77\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">happen</AUni></Gloss>" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">to happen or occur</Run></AStr></Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D50B5C0D2FCC9F\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">remain</AUni></Gloss>" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">to remain or continue</Run></AStr></Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D50B780D2FCCCF\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" />" + Environment.NewLine +
				"</MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">belong</AUni></Gloss>" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">to come to; belong</Run></AStr></Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D50B970D2FCD31\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">have place</AUni></Gloss>" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">to have a place or position</Run></AStr></Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D503E70D337812\">" + Environment.NewLine +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">As a copula:</Run></AStr></Definition>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense id=\"I1D504240D3378B9\">" + Environment.NewLine +
				"<SenseType><Link ws=\"en\" abbr=\"prim\" name=\"primary\" /></SenseType>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense id=\"I1D503F40D33782C\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">is</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">the linker between a subject and a predicate nominative, adjective, or pronoun so as to express attribution</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D504160D33789F\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" />" + Environment.NewLine +
				"</MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">equals</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">the linker between a subject and a predicate nominative, adjective, or pronoun so as to express identity</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D5049A0D337999\">" + Environment.NewLine +
				"<SenseType><Link ws=\"en\" abbr=\"sec\" name=\"secondary\" /></SenseType>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense id=\"I1D5049B0D337999\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss>" + Environment.NewLine +
				"<AUni ws=\"en\">costs</AUni>" + Environment.NewLine +
				"</Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">the linker between a subject and a predicate nominative, adjective, or pronoun so as to express value</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D5049D0D337999\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">causes</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">the linker between a subject and a predicate nominative, adjective, or pronoun so as to express cause</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"<SenseType><Link ws=\"en\" abbr=\"sec\" name=\"secondary\" /></SenseType>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D505150D337AC7\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860123246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">signify</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">the linker between a subject and a predicate nominative, adjective, or pronoun so as to express signification</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D50BAC0D2FCD6A\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860124246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense id=\"I1D50BCF0D2FCD84\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860124246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">PASS</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">used with the past participle of a transitive verb to form the passive voice</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D50C750D2FCFD4\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860124246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">PERF</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">used with the past participle of certain intransitive verbs to form a perfect tense</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D50CA00D2FD01A\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860124246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">CONT</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">used with the present participle of another verb to express continuation</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D5058A0D33814A\">" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">IRREALIS</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense id=\"I1D50CB70D2FD062\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860124246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">IRR FUT</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">used with the present participle or infinitive of another verb to express futurity</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D505A90D3381B9\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860124246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">IRR OBLIG</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">used with the present participle or infinitive of another verb to express obligation</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D505EA0D33826E\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860124246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">IRR POSS</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">used with the present participle or infinitive of another verb to express possibility</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"<LexSense id=\"I1D506120D338294\">" + Environment.NewLine +
				"<MorphoSyntaxAnalysis><Link target=\"I1860124246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" + Environment.NewLine +
				"<Gloss><AUni ws=\"en\">IRR INT</AUni></Gloss>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\"><Run ws=\"en\">used with the present participle or infinitive of another verb to express intention</Run></AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexEntry>" + Environment.NewLine +
				"</Entries>" + Environment.NewLine +
				"</LexDb>" + Environment.NewLine +
				"</LexDb>" + Environment.NewLine +
				"<AnalyzingAgents>" + Environment.NewLine +
				"<CmAgent id=\"I18601E1246B081E\">" + Environment.NewLine +
				"<Name><AUni ws=\"en\">default user</AUni></Name>" + Environment.NewLine +
				"<Human><Boolean val=\"true\" /></Human>" + Environment.NewLine +
				"<Approves>" + Environment.NewLine +
				"<CmAgentEvaluation id=\"I18601F5246B081F\">" + Environment.NewLine +
				"</CmAgentEvaluation>" + Environment.NewLine +
				"</Approves>" + Environment.NewLine +
				"</CmAgent>" + Environment.NewLine +
				"</AnalyzingAgents>" + Environment.NewLine +
				"</LangProject>" + Environment.NewLine +
				"<Text id=\"I1D500E90D2FB820\">" + Environment.NewLine +
				"<Name><AUni ws=\"qaa-x-ame\">Life begins each morning!: Praise the Lord!</AUni></Name>" + Environment.NewLine +
				"<Contents>" + Environment.NewLine +
				"<StText>" + Environment.NewLine +
				"<Paragraphs>" + Environment.NewLine +
				"<StTxtPara id=\"I1D5016C0D2FB8D7\">" + Environment.NewLine +
				"<Contents>" + Environment.NewLine +
				"<Str>" + Environment.NewLine +
				"<Run ws=\"qaa-x-ame\">Whether one is 20, 40, or 60; </Run>" + Environment.NewLine +
				"<Run ws=\"qaa-x-ame\">whether one has succeeded, failed, or just muddled along; </Run>" + Environment.NewLine +
				"<Run ws=\"qaa-x-ame\">whether yesterday was full of sun or storm, </Run>" + Environment.NewLine +
				"<Run ws=\"qaa-x-ame\">or one of those dull days with no weather at all, </Run>" + Environment.NewLine +
				"<Run ws=\"qaa-x-ame\">Life Begins Each Morning!</Run>" + Environment.NewLine +
				"</Str>" + Environment.NewLine +
				"</Contents>" + Environment.NewLine +
				"</StTxtPara>" + Environment.NewLine +
				"<StTxtPara id=\"I18604621FBF274E\">" + Environment.NewLine +
				"<Contents>" + Environment.NewLine +
				"<Str>" + Environment.NewLine +
				"<Run ws=\"qaa-x-ame\">an apple</Run>" + Environment.NewLine +
				"</Str>" + Environment.NewLine +
				"</Contents>" + Environment.NewLine +
				"</StTxtPara>" + Environment.NewLine +
				"</Paragraphs>" + Environment.NewLine +
				"</StText>" + Environment.NewLine +
				"</Contents>" + Environment.NewLine +
				"</Text>" + Environment.NewLine +
				"<WfiWordform id=\"I18607CF1FBCF598\">" + Environment.NewLine +
				"<Form><AUni ws=\"qaa-x-ame\">an</AUni></Form>" + Environment.NewLine +
				"<Analyses>" + Environment.NewLine +
				"<WfiAnalysis id=\"I18605F01FBF27FC\">" + Environment.NewLine +
				"<Category><Link ws=\"en\" abbr=\"adj, indef art\" name=\"indefinite article\" /></Category>" + Environment.NewLine +
				"<Evaluations><Link target=\"I18601F5246B081F\" class=\"CmAgentEvaluation\" /></Evaluations>" +
				"<MorphBundles>" + Environment.NewLine +
				"<WfiMorphBundle id=\"I18601F4246B081F\">" + Environment.NewLine +
				"<Msa><Link target=\"I186011C246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></Msa>" + Environment.NewLine +
				"<Morph><Link target=\"I186011A246B081E\" class=\"MoStemAllomorph\" /></Morph>" + Environment.NewLine +
				"<Sense><Link target=\"I1D508C10D33CF1F\" wsa=\"en\" abbr=\"llcr\" wsv=\"qaa-x-ame\" sense=\"an 1.3\" /></Sense>" + Environment.NewLine +
				"</WfiMorphBundle>" + Environment.NewLine +
				"</MorphBundles>" + Environment.NewLine +
				"<Meanings>" + Environment.NewLine +
				"<WfiGloss id=\"I18606651FBF2823\">" + Environment.NewLine +
				"</WfiGloss>" + Environment.NewLine +
				"</Meanings>" + Environment.NewLine +
				"</WfiAnalysis>" + Environment.NewLine +
				"</Analyses>" + Environment.NewLine +
				"</WfiWordform>" + Environment.NewLine +
				"<WfiWordform id=\"I1B904B70D76B9BE\">" + Environment.NewLine +
				"<Form><AUni ws=\"qaa-x-ame\">apple</AUni></Form>" + Environment.NewLine +
				"</WfiWordform>" + Environment.NewLine +
				"<CmBaseAnnotation id=\"I18604631FBF274E\">" + Environment.NewLine +
				"<BeginObject><Link target=\"I18604621FBF274E\" class=\"StTxtPara\" /></BeginObject>" + Environment.NewLine +
				"<EndObject><Link target=\"I18604621FBF274E\" class=\"StTxtPara\" /></EndObject>" + Environment.NewLine +
				"<Flid><Integer val=\"16002\" /></Flid>" + Environment.NewLine +
				"<BeginOffset><Integer val=\"1\" /></BeginOffset>" + Environment.NewLine +
				"<AnnotationType><Link ws=\"en\" name=\"Text Segment\" /></AnnotationType>" + Environment.NewLine +
				"<CompDetails><Uni>LLImport</Uni></CompDetails>" + Environment.NewLine +
				"</CmBaseAnnotation>" + Environment.NewLine +
				"<CmIndirectAnnotation>" + Environment.NewLine +
				"<AppliesTo><Link target=\"I18604631FBF274E\" class=\"Segment\" /></AppliesTo>" + Environment.NewLine +
				"<AnnotationType><Link ws=\"en\" name=\"Free Translation\" /></AnnotationType>" + Environment.NewLine +
				"<Comment><AStr ws=\"en\"><Run ws=\"en\">A free translation for an apple.</Run></AStr></Comment>" + Environment.NewLine +
				"<CompDetails><Uni>LLImport</Uni></CompDetails>" + Environment.NewLine +
				"</CmIndirectAnnotation>" + Environment.NewLine +
				"<CmBaseAnnotation id=\"I186047D1FBF278D\">" + Environment.NewLine +
				"<BeginObject><Link target=\"I18604621FBF274E\" class=\"StTxtPara\" /></BeginObject>" + Environment.NewLine +
				"<EndObject><Link target=\"I18604621FBF274E\" class=\"StTxtPara\" /></EndObject>" + Environment.NewLine +
				"<Flid><Integer val=\"16002\" /></Flid>" + Environment.NewLine +
				"<BeginOffset><Integer val=\"1\" /></BeginOffset>" + Environment.NewLine +
				"<EndOffset><Integer val=\"2\" /></EndOffset>" + Environment.NewLine +
				"<InstanceOf><Link target=\"I18606651FBF2823\" class=\"WfiGloss\" /></InstanceOf>" + Environment.NewLine +
				"<AnnotationType><Link ws=\"en\" name=\"Wordform In Context\" /></AnnotationType>" + Environment.NewLine +
				"<CompDetails><Uni>LLImport</Uni></CompDetails>" + Environment.NewLine +
				"</CmBaseAnnotation>" + Environment.NewLine +
				"<CmBaseAnnotation id=\"I186047E1FBF278D\">" + Environment.NewLine +
				"<BeginObject><Link target=\"I18604621FBF274E\" class=\"StTxtPara\" /></BeginObject>" + Environment.NewLine +
				"<EndObject><Link target=\"I18604621FBF274E\" class=\"StTxtPara\" /></EndObject>" + Environment.NewLine +
				"<Flid><Integer val=\"16002\" /></Flid>" + Environment.NewLine +
				"<BeginOffset><Integer val=\"2\" /></BeginOffset>" + Environment.NewLine +
				"<EndOffset><Integer val=\"5\" /></EndOffset>" + Environment.NewLine +
				"<InstanceOf><Link target=\"I1B904B70D76B9BE\" class=\"WfiWordform\" /></InstanceOf>" + Environment.NewLine +
				"<AnnotationType><Link ws=\"en\" name=\"Wordform In Context\" /></AnnotationType>" + Environment.NewLine +
				"<CompDetails><Uni>LLImport</Uni></CompDetails>" + Environment.NewLine +
				"</CmBaseAnnotation>" + Environment.NewLine +
				"</FwDatabase>" + Environment.NewLine
				))
			{
			StringBuilder sbLog = new StringBuilder();
			xid.ImportData(rdr, new StringWriter(sbLog), null);
			int wsEn = m_cache.WritingSystemFactory.GetWsFromStr("en");
			int wsAme = m_cache.WritingSystemFactory.GetWsFromStr("qaa-x-ame");
			Assert.AreEqual(0, m_cache.LangProject.LexDbOA.ReversalIndexesOC.Count);
			Assert.AreEqual(3, m_cache.LangProject.LexDbOA.Entries.Count());
			ILexEntry[] rgle = m_cache.LangProject.LexDbOA.Entries.ToArray();
			CheckFirstEntry(rgle[0], wsEn, wsAme);
			CheckSecondEntry(rgle[1], wsEn, wsAme, rgle[2]);
			CheckThirdEntry(rgle[2], wsEn, wsAme);
			Assert.AreEqual(1, m_cache.LangProject.Texts.Count);
			CheckTheText(m_cache.LangProject.Texts.ToArray()[0]);
			Assert.AreEqual(4, m_cache.LangProject.AnalyzingAgentsOC.Count);	// There are 3 standard agents.
			CheckTheAgent(m_cache.LangProject.AnalyzingAgentsOC.ToArray()[3], wsAme);
			CheckWfiWordforms(wsEn, wsAme);
			CheckAnnotations(wsEn, wsAme);

			string sLog = sbLog.ToString();
			Assert.IsFalse(String.IsNullOrEmpty(sLog), "There should be some log information!");
			string[] rgsLog = sLog.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
			Assert.LessOrEqual(12, rgsLog.Length);
			Assert.AreEqual("data stream:0: Info: Creating new writing system for \"qaa-x-ame\".", rgsLog[0]);
			Assert.AreEqual("data stream:0: Info: Creating new writing system for \"qaa-x-ame-fonipa\".", rgsLog[1]);
			Assert.AreEqual("data stream:0: Info: Creating new writing system for \"la\".", rgsLog[3]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"adj, indef art\", and name=\"indefinite article\" in the Parts of Speech list.", rgsLog[2]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"\", and name=\"Irregularly Inflected Form\" in the *** list.", rgsLog[4]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"vi\", and name=\"intransitive verb\" in the Parts of Speech list.", rgsLog[5]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"aux\", and name=\"auxiliary verb\" in the Parts of Speech list.", rgsLog[6]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"prim\", and name=\"primary\" in the *** list.", rgsLog[7]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"sec\", and name=\"secondary\" in the *** list.", rgsLog[8]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"\", and name=\"Text Segment\" in the *** list.", rgsLog[9]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"\", and name=\"Free Translation\" in the *** list.", rgsLog[10]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"\", and name=\"Wordform In Context\" in the *** list.", rgsLog[11]);
		}
		}
示例#11
0
		public void ImportData2()
		{
			XmlImportData xid = new XmlImportData(m_cache);
			using (var rdr = new StringReader(
				"<FwDatabase>" +
				"<LangProject>" +
				"<LexDb>" +
				"<LexDb id=\"I1D5042E0D192A7D\">" +
				"<ReversalIndexes>" +
				"<ReversalIndex id=\"I1B901C10D93932B\">" +
				"<Name><AUni ws=\"en\">English Index</AUni></Name>" +
				"<WritingSystem><Uni>en</Uni></WritingSystem>" +
				"<Entries>" +
				"<ReversalIndexEntry id=\"I1B901F80D939332\">" +
				"<ReversalForm><AUni ws=\"en\">adolescent</AUni></ReversalForm>" +
				"<PartOfSpeech><Link target=\"I1B901DD0D93932D\"/></PartOfSpeech>" +
				"</ReversalIndexEntry>" +
				"</Entries>" +
				"<PartsOfSpeech>" +
				"<CmPossibilityList id=\"I1B901C20D93932B\">" +
				"<Name><AUni ws=\"en\">Parts Of Speech</AUni></Name>" +
				"<Abbreviation><AUni ws=\"en\">Parts Of Speech</AUni></Abbreviation>" +
				"<WsSelector><Integer val=\"-3\" /></WsSelector>" +
				"<IsSorted><Boolean val=\"true\" /></IsSorted>" +
				"<IsClosed><Boolean val=\"false\" /></IsClosed>" +
				"<ItemClsid><Integer val=\"7\" /></ItemClsid>" +
				"<UseExtendedFields><Boolean val=\"true\" /></UseExtendedFields>" +
				"<Possibilities>" +
				"<PartOfSpeech id=\"I1B901DC0D93932D\">" +
				"<Name><AUni ws=\"en\">noun</AUni></Name>" +
				"<Abbreviation><AUni ws=\"en\">n</AUni></Abbreviation>" +
				"<SubPossibilities>" +
				"<PartOfSpeech id=\"I1B901DD0D93932D\">" +
				"<Name><AUni ws=\"en\">common noun</AUni></Name>" +
				"<Abbreviation><AUni ws=\"en\">comm</AUni></Abbreviation>" +
				"</PartOfSpeech>" +
				"<PartOfSpeech id=\"I1B901DE0D93932D\">" +
				"<Name><AUni ws=\"en\">concrete noun</AUni></Name>" +
				"<Abbreviation><AUni ws=\"en\">conc</AUni></Abbreviation>" +
				"</PartOfSpeech>" +
				"<PartOfSpeech id=\"I1B901DF0D93932D\">" +
				"<Name><AUni ws=\"en\">nominal</AUni></Name>" +
				"<Abbreviation><AUni ws=\"en\">nom</AUni></Abbreviation>" +
				"</PartOfSpeech>" +
				"<PartOfSpeech id=\"I1B901E00D93932D\">" +
				"<Name><AUni ws=\"en\">possessive noun</AUni></Name>" +
				"<Abbreviation><AUni ws=\"en\">poss</AUni></Abbreviation>" +
				"</PartOfSpeech>" +
				"<PartOfSpeech id=\"I1B901E10D93932D\">" +
				"<Name><AUni ws=\"en\">proper noun</AUni></Name>" +
				"<Abbreviation><AUni ws=\"en\">prop</AUni></Abbreviation>" +
				"</PartOfSpeech>" +
				"</SubPossibilities>" +
				"</PartOfSpeech>" +
				"</Possibilities>" +
				"</CmPossibilityList>" +
				"</PartsOfSpeech>" +
				"</ReversalIndex>" +
				"</ReversalIndexes>" +
				"<Entries>" +
				"<LexEntry id=\"I1D5049B0D1AA622\">" +
				"<LexemeForm>" +
				"<MoStemAllomorph id=\"I1860114246B081E\">" +
				"<Form><AUni ws=\"qaa-x-ame\">adolescent</AUni></Form>" +
				"<MorphType><Link ws=\"en\" abbr=\"rt\" name=\"root\" /></MorphType>" +
				"</MoStemAllomorph>" +
				"</LexemeForm>" +
				"<MorphoSyntaxAnalyses>" +
				"<MoStemMsa id=\"I1860115246B081E\">" +
				"<PartOfSpeech><Link ws=\"en\" abbr=\"com n\" name=\"common noun\" /></PartOfSpeech>" +
				"</MoStemMsa>" +
				"</MorphoSyntaxAnalyses>" +
				"<Senses>" +
				"<LexSense id=\"I1D5049D0D1AA622\">" +
				"<MorphoSyntaxAnalysis><Link target=\"I1860115246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" +
				"<Senses>" +
				"<LexSense id=\"I1D5049C0D1AA622\">" +
				"<MorphoSyntaxAnalysis><Link target=\"I1860115246B081E\" class=\"MoMorphoSyntaxAnalysis\" /></MorphoSyntaxAnalysis>" +
				"<Gloss><AUni ws=\"en\">adolescent</AUni></Gloss>" +
				"<Definition><AStr ws=\"en\"><Run ws=\"en\">a boy or girl from the period of puberty to adulthood</Run></AStr></Definition>" +
				"<AnthroCodes><Link ws=\"en\" abbr=\"561\" name=\"561 Age Stratification\" /></AnthroCodes>" +
				"<ReversalEntries><Link ws=\"en\" form=\"adolescent\" /></ReversalEntries>" +
				"<SemanticDomains><Link ws=\"en\" abbr=\"2.6.4.2\" /></SemanticDomains>" +
				"</LexSense>" +
				"</Senses>" +
				"</LexSense>" +
				"</Senses>" +
				"</LexEntry>" +
				"</Entries>" +
				"</LexDb>" +
				"</LexDb>" +
				"</LangProject>" +
				"<WfiWordform id=\"I1B904B50D76B9BD\">" +
				"<Form><AUni ws=\"qaa-x-ame\">this</AUni></Form>" +
				"</WfiWordform>" +
				"<WfiWordform id=\"I1D5021A0D2FB9E9\">" +
				"<Form><AUni ws=\"qaa-x-ame\">those</AUni></Form>" +
				"</WfiWordform>" +
				"</FwDatabase>"
				))
			{
			StringBuilder sbLog = new StringBuilder();
			xid.ImportData(rdr, new StringWriter(sbLog), null);
			IWritingSystem wsEn = m_cache.ServiceLocator.WritingSystemManager.Get("en");
			Assert.AreEqual(1, m_cache.LangProject.LexDbOA.ReversalIndexesOC.Count);
			IReversalIndex revIdx = m_cache.LangProject.LexDbOA.ReversalIndexesOC.ToArray()[0];
			IMultiUnicode mu = revIdx.Name;
			Assert.AreEqual(1, mu.StringCount);
			ITsString tss = mu.get_String(wsEn.Handle);
			Assert.AreEqual("English Index", tss.Text);
			Assert.AreEqual(wsEn.Id, revIdx.WritingSystem);
			Assert.AreEqual(1, revIdx.EntriesOC.Count);
			IReversalIndexEntry revEntry = revIdx.EntriesOC.ToArray()[0];
			mu = revEntry.ReversalForm;
			tss = mu.get_String(wsEn.Handle);
			Assert.AreEqual("adolescent", tss.Text);
			Assert.AreEqual("Parts Of Speech", revIdx.PartsOfSpeechOA.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual("Parts Of Speech", revIdx.PartsOfSpeechOA.Abbreviation.get_String(wsEn.Handle).Text);
			Assert.AreEqual(-3, revIdx.PartsOfSpeechOA.WsSelector);
			Assert.IsTrue(revIdx.PartsOfSpeechOA.IsSorted);
			Assert.IsFalse(revIdx.PartsOfSpeechOA.IsClosed);
			Assert.AreEqual(7, revIdx.PartsOfSpeechOA.ItemClsid);
			Assert.IsTrue(revIdx.PartsOfSpeechOA.UseExtendedFields);
			Assert.AreEqual(1, revIdx.PartsOfSpeechOA.PossibilitiesOS.Count);
			ICmPossibility poss = revIdx.PartsOfSpeechOA.PossibilitiesOS[0];
			Assert.AreEqual("noun", poss.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual("n", poss.Abbreviation.get_String(wsEn.Handle).Text);
			Assert.AreEqual(5, poss.SubPossibilitiesOS.Count);
			ICmPossibility subposs;
			subposs = poss.SubPossibilitiesOS[0];
			Assert.AreEqual("common noun", subposs.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual("comm", subposs.Abbreviation.get_String(wsEn.Handle).Text);
			Assert.AreEqual(revEntry.PartOfSpeechRA, subposs as IPartOfSpeech);
			subposs = poss.SubPossibilitiesOS[1];
			Assert.AreEqual("concrete noun", subposs.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual("conc", subposs.Abbreviation.get_String(wsEn.Handle).Text);
			subposs = poss.SubPossibilitiesOS[2];
			Assert.AreEqual("nominal", subposs.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual("nom", subposs.Abbreviation.get_String(wsEn.Handle).Text);
			subposs = poss.SubPossibilitiesOS[3];
			Assert.AreEqual("possessive noun", subposs.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual("poss", subposs.Abbreviation.get_String(wsEn.Handle).Text);
			subposs = poss.SubPossibilitiesOS[4];
			Assert.AreEqual("proper noun", subposs.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual("prop", subposs.Abbreviation.get_String(wsEn.Handle).Text);

			Assert.AreEqual(1, m_cache.LangProject.LexDbOA.Entries.Count(), "The import data had one entry.");
			ILexEntry entry = m_cache.LangProject.LexDbOA.Entries.ToArray()[0];
			IMoForm form = entry.LexemeFormOA;
			Assert.IsTrue(form is IMoStemAllomorph);
			int wsAme = m_cache.WritingSystemFactory.GetWsFromStr("qaa-x-ame");
			Assert.AreEqual(1, form.Form.StringCount);
			Assert.AreEqual("adolescent", form.Form.get_String(wsAme).Text);
			Assert.AreEqual("root", form.MorphTypeRA.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual(1, entry.MorphoSyntaxAnalysesOC.Count);
			IMoStemMsa msaStem = entry.MorphoSyntaxAnalysesOC.ToArray()[0] as IMoStemMsa;
			Assert.IsNotNull(msaStem);
			Assert.AreEqual("common noun", msaStem.PartOfSpeechRA.Name.get_String(wsEn.Handle).Text);
			Assert.AreNotEqual(revEntry.PartOfSpeechRA, msaStem.PartOfSpeechRA);
			Assert.AreEqual(revEntry.PartOfSpeechRA.Name.get_String(wsEn.Handle).Text,
				msaStem.PartOfSpeechRA.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual(1, entry.SensesOS.Count);
			ILexSense sense = entry.SensesOS[0];
			Assert.AreEqual(msaStem, sense.MorphoSyntaxAnalysisRA);
			Assert.AreEqual(1, sense.SensesOS.Count);
			ILexSense subsense = sense.SensesOS[0];
			Assert.AreEqual(msaStem, subsense.MorphoSyntaxAnalysisRA);
			Assert.AreEqual(1, subsense.Gloss.StringCount);
			Assert.AreEqual("adolescent", subsense.Gloss.get_String(wsEn.Handle).Text);
			Assert.AreEqual(1, subsense.Definition.StringCount);
			ITsString tss0 = m_cache.TsStrFactory.MakeString("a boy or girl from the period of puberty to adulthood", wsEn.Handle);
			Assert.IsTrue(tss0.Equals(subsense.Definition.get_String(wsEn.Handle)));
			Assert.AreEqual(1, subsense.AnthroCodesRC.Count);
			ICmAnthroItem anth = subsense.AnthroCodesRC.ToArray()[0];
			Assert.AreEqual("Age Stratification", anth.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual("561", anth.Abbreviation.get_String(wsEn.Handle).Text);
			Assert.AreEqual(1, subsense.SemanticDomainsRC.Count);
			ICmSemanticDomain sem = subsense.SemanticDomainsRC.ToArray()[0];
			Assert.AreEqual("2.6.4.2", sem.Name.get_String(wsEn.Handle).Text);
			Assert.AreEqual("2.6.4.2", sem.Abbreviation.get_String(wsEn.Handle).Text);
			Assert.AreEqual(1, subsense.ReversalEntriesRC.Count);
			IReversalIndexEntry rieSense = subsense.ReversalEntriesRC.ToArray()[0];
			Assert.AreEqual(revEntry, rieSense);
			IWfiWordformRepository repoWfi = m_cache.ServiceLocator.GetInstance<IWfiWordformRepository>();
			Assert.AreEqual(2, repoWfi.Count);
			IWfiWordform wfiThis = repoWfi.GetMatchingWordform(wsAme, "this");
			Assert.IsNotNull(wfiThis);
			Assert.AreEqual(0, wfiThis.AnalysesOC.Count);
			IWfiWordform wfiThose = repoWfi.GetMatchingWordform(wsAme, "those");
			Assert.IsNotNull(wfiThose);
			Assert.AreEqual(0, wfiThose.AnalysesOC.Count);

			string sLog = sbLog.ToString();
			Assert.IsFalse(String.IsNullOrEmpty(sLog), "There should be some log information!");
			string[] rgsLog = sLog.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
			Assert.LessOrEqual(4, rgsLog.Length);
			Assert.AreEqual("data stream:0: Info: Creating new writing system for \"qaa-x-ame\".", rgsLog[0]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"com n\", and name=\"common noun\" in the Parts of Speech list.", rgsLog[1]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"561\", and name=\"Age Stratification\" in the Anthropology Categories list.", rgsLog[2]);
			Assert.AreEqual("data stream:0: Info: Creating new item with ws=\"en\", abbr=\"2.6.4.2\", and name=\"2.6.4.2\" in the Semantic Domain list.", rgsLog[3]);
		}
		}
示例#12
0
		public void ImportTreeRelation()
		{
			DateTime dtLexOrig = m_cache.LangProject.LexDbOA.DateCreated;
			TimeSpan span = new TimeSpan(dtLexOrig.Ticks - m_now.Ticks);
			Assert.LessOrEqual(span.TotalMinutes, 1.0);
			// should be only a second or two
			XmlImportData xid = new XmlImportData(m_cache);
			var input = @"<LexDb xmlns:msxsl='urn:schemas-microsoft-com:xslt' xmlns:user='******'>
	<Entries>
		<LexEntry>
			<LexemeForm>
				<MoStemAllomorph>
					<MorphType>
						<Link ws='en' name='stem' />
					</MorphType>
					<Form>
						<AUni ws='fr'>house</AUni>
					</Form>
				</MoStemAllomorph>
			</LexemeForm>
			<MorphoSyntaxAnalyses>
				<MoStemMsa id='MSA1003'>
					<PartOfSpeech>
						<Link ws='en' abbr='n' />
					</PartOfSpeech>
				</MoStemMsa>
			</MorphoSyntaxAnalyses>
			<Senses>
				<LexSense>
					<MorphoSyntaxAnalysis>
						<Link target='MSA1003' />
					</MorphoSyntaxAnalysis>
					<LexicalRelations>
						<Link wsa='en' abbr='part' wsv='fr' sense='wall2 2' />
						<Link wsa='en' abbr='part' wsv='fr' sense='ceiling' />
					</LexicalRelations>
				</LexSense>
			</Senses>
		</LexEntry>
		<LexEntry>
			<LexemeForm>
				<MoStemAllomorph>
					<MorphType>
						<Link ws='en' name='stem' />
					</MorphType>
					<Form>
						<AUni ws='fr'>wall</AUni>
					</Form>
				</MoStemAllomorph>
			</LexemeForm>
			<HomographNumber>
				<Integer val='1' />
			</HomographNumber>
			<MorphoSyntaxAnalyses>
				<MoStemMsa id='MSA1004'>
					<PartOfSpeech>
						<Link ws='en' abbr='v' />
					</PartOfSpeech>
				</MoStemMsa>
			</MorphoSyntaxAnalyses>
			<Senses>
				<LexSense>
					<MorphoSyntaxAnalysis>
						<Link target='MSA1004' />
					</MorphoSyntaxAnalysis>
				</LexSense>
			</Senses>
		</LexEntry>
		<LexEntry>
			<LexemeForm>
				<MoStemAllomorph>
					<MorphType>
						<Link ws='en' name='stem' />
					</MorphType>
					<Form>
						<AUni ws='fr'>wall</AUni>
					</Form>
				</MoStemAllomorph>
			</LexemeForm>
			<HomographNumber>
				<Integer val='2' />
			</HomographNumber>
			<MorphoSyntaxAnalyses>
				<MoStemMsa id='MSA1005'>
					<PartOfSpeech>
						<Link ws='en' abbr='v' />
					</PartOfSpeech>
				</MoStemMsa>
				<MoStemMsa id='MSA1006'>
					<PartOfSpeech>
						<Link ws='en' abbr='n' />
					</PartOfSpeech>
				</MoStemMsa>
			</MorphoSyntaxAnalyses>
			<Senses>
				<LexSense>
					<MorphoSyntaxAnalysis>
						<Link target='MSA1005' />
					</MorphoSyntaxAnalysis>
				</LexSense>
				<LexSense>
					<MorphoSyntaxAnalysis>
						<Link target='MSA1006' />
					</MorphoSyntaxAnalysis>
					<LexicalRelations />
				</LexSense>
			</Senses>
		</LexEntry>
		<LexEntry>
			<LexemeForm>
				<MoStemAllomorph>
					<MorphType>
						<Link ws='en' name='stem' />
					</MorphType>
					<Form>
						<AUni ws='fr'>ceiling</AUni>
					</Form>
				</MoStemAllomorph>
			</LexemeForm>
			<MorphoSyntaxAnalyses>
				<MoStemMsa id='MSA1007'>
					<PartOfSpeech>
						<Link ws='en' abbr='n' />
					</PartOfSpeech>
				</MoStemMsa>
			</MorphoSyntaxAnalyses>
			<Senses>
				<LexSense>
					<MorphoSyntaxAnalysis>
						<Link target='MSA1007' />
					</MorphoSyntaxAnalysis>
					<LexicalRelations />
				</LexSense>
			</Senses>
		</LexEntry>
	</Entries>
</LexDb>";
			Assert.AreEqual(0, m_cache.LangProject.LexDbOA.Entries.Count(), "The lexicon starts out empty.");
			Assert.AreEqual(0, m_cache.LangProject.AnthroListOA.PossibilitiesOS.Count);
			Assert.AreEqual(0, m_cache.LangProject.SemanticDomainListOA.PossibilitiesOS.Count);
			Assert.AreEqual(0, m_cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Count);
			ILexRefType partWhole = null;
			UndoableUnitOfWorkHelper.Do("do", "undo", m_cache.ActionHandlerAccessor, () =>
			{
				m_cache.LangProject.LexDbOA.ReferencesOA = m_cache.ServiceLocator.GetInstance<ICmPossibilityListFactory>().Create();
				partWhole = m_cache.ServiceLocator.GetInstance<ILexRefTypeFactory>().Create();
				m_cache.LangProject.LexDbOA.ReferencesOA.PossibilitiesOS.Add(partWhole);
				// The importer would create this relation, but it would not defaul to the desired type
				partWhole.Name.SetAnalysisDefaultWritingSystem("part");
				partWhole.MappingType = (int)LexRefTypeTags.MappingTypes.kmtSenseTree;
			});
			StringBuilder sbLog = new StringBuilder();
			using (var rdr = new StringReader(input))
			{
				xid.ImportData(rdr, new StringWriter(sbLog), null);
			}
			// The entries are house, wall, wall, ceiling.
			// The input specifies that there is a part-whole relation house, wall(2.2), ceiling.
			Assert.AreEqual(4, m_cache.LangProject.LexDbOA.Entries.Count());
			var lrtRepo = m_cache.ServiceLocator.GetInstance<ILexRefTypeRepository>();
			foreach (var lrt in lrtRepo.AllInstances())
			{
				if (lrt.Name.AnalysisDefaultWritingSystem.Text == "part")
				{
					Assert.That(lrt, Is.EqualTo(partWhole), "Should only have one part-whole LRT");
				}
			}
			var relations = partWhole.MembersOC.ToArray();
			Assert.That(relations, Has.Length.EqualTo(1), "should have produced exactly one lexical relation");
			var items = relations[0].TargetsRS;
			Assert.That(items, Has.Count.EqualTo(3), "relation should have three items");
			Assert.That(((ILexEntry)items[0].Owner).LexemeFormOA.Form.VernacularDefaultWritingSystem.Text, Is.EqualTo("house"),
				"First thing in relation should be house");
			// The order of the next two does not technically matter.
			Assert.That(((ILexEntry)items[1].Owner).LexemeFormOA.Form.VernacularDefaultWritingSystem.Text, Is.EqualTo("wall"),
				"Second thing in relation should be wall");
			Assert.That(((ILexEntry)items[2].Owner).LexemeFormOA.Form.VernacularDefaultWritingSystem.Text,
				Is.EqualTo("ceiling"),
				"Third thing in relation should be ceiling");

			// Now import it again.
			// This addition may be useful one day if we actually use the code that looks for existing tree relations.
			// Currently a tree relation only occurs once in the file, and the objects in it can't be pre-existing,
			// so we can't ever match an existing relation.
			//var wall = items[1];
			//var ceiling = items[2];
			//UndoableUnitOfWorkHelper.Do("do", "undo", m_cache.ActionHandlerAccessor, () =>
			//{
			//	// Move wall to the end. Should still match on a new import, since the order of the leaves is not significant.
			//	relations[0].TargetsRS.Remove(wall);
			//	relations[0].TargetsRS.Add(wall);
			//});
			//xid = new XmlImportData(m_cache); // need a new one for each import
			//using (var rdr = new StringReader(input))
			//{
			//	xid.ImportData(rdr, new StringWriter(sbLog), null);
			//}
			//Assert.AreEqual(4, m_cache.LangProject.LexDbOA.Entries.Count());
			//relations = partWhole.MembersOC.ToArray();
			//Assert.That(relations, Has.Length.EqualTo(1), "should not have produced another lexical relation");
			//items = relations[0].TargetsRS;
			//Assert.That(items, Has.Count.EqualTo(3), "relation should still have three items");
		}
示例#13
0
		public void ImportSequenceRelation()
		{
			DateTime dtLexOrig = m_cache.LangProject.LexDbOA.DateCreated;
			TimeSpan span = new TimeSpan(dtLexOrig.Ticks - m_now.Ticks);
			Assert.LessOrEqual(span.TotalMinutes, 1.0);
			// should be only a second or two
			XmlImportData xid = new XmlImportData(m_cache);
			using (var rdr = new StringReader(@"<LexDb xmlns:msxsl='urn:schemas-microsoft-com:xslt' xmlns:user='******'>
	<Entries>
		<LexEntry>
			<LexemeForm>
				<MoStemAllomorph>
					<MorphType>
						<Link ws='en' name='stem' />
					</MorphType>
					<Form>
						<AUni ws='fr'>Wed</AUni>
					</Form>
				</MoStemAllomorph>
			</LexemeForm>
			<MorphoSyntaxAnalyses>
				<MoStemMsa id='MSA1000'>
					<PartOfSpeech>
						<Link ws='en' abbr='n' />
					</PartOfSpeech>
				</MoStemMsa>
			</MorphoSyntaxAnalyses>
			<Senses>
				<LexSense>
					<MorphoSyntaxAnalysis>
						<Link target='MSA1000' />
					</MorphoSyntaxAnalysis>
					<LexicalRelations>
						<Link wsa='en' abbr='calendar' wsv='fr' sense='Mon' />
						<Link wsa='en' abbr='calendar' wsv='fr' sense='Tue' />
						<Link wsa='en' abbr='calendar' wsv='fr' sense='Wed' />
					</LexicalRelations>
				</LexSense>
			</Senses>
		</LexEntry>
		<LexEntry>
			<LexemeForm>
				<MoStemAllomorph>
					<MorphType>
						<Link ws='en' name='stem' />
					</MorphType>
					<Form>
						<AUni ws='fr'>Tue</AUni>
					</Form>
				</MoStemAllomorph>
			</LexemeForm>
			<MorphoSyntaxAnalyses>
				<MoStemMsa id='MSA1001'>
					<PartOfSpeech>
						<Link ws='en' abbr='n' />
					</PartOfSpeech>
				</MoStemMsa>
			</MorphoSyntaxAnalyses>
			<Senses>
				<LexSense>
					<MorphoSyntaxAnalysis>
						<Link target='MSA1001' />
					</MorphoSyntaxAnalysis>
					<LexicalRelations>
						<Link wsa='en' abbr='calendar' wsv='fr' sense='Mon' />
						<Link wsa='en' abbr='calendar' wsv='fr' sense='Tue' />
						<Link wsa='en' abbr='calendar' wsv='fr' sense='Wed' />
					</LexicalRelations>
				</LexSense>
			</Senses>
		</LexEntry>
		<LexEntry>
			<LexemeForm>
				<MoStemAllomorph>
					<MorphType>
						<Link ws='en' name='stem' />
					</MorphType>
					<Form>
						<AUni ws='fr'>Mon</AUni>
					</Form>
				</MoStemAllomorph>
			</LexemeForm>
			<MorphoSyntaxAnalyses>
				<MoStemMsa id='MSA1002'>
					<PartOfSpeech>
						<Link ws='en' abbr='n' />
					</PartOfSpeech>
				</MoStemMsa>
			</MorphoSyntaxAnalyses>
			<Senses>
				<LexSense>
					<MorphoSyntaxAnalysis>
						<Link target='MSA1002' />
					</MorphoSyntaxAnalysis>
					<LexicalRelations>
						<Link wsa='en' abbr='calendar' wsv='fr' sense='Mon' />
						<Link wsa='en' abbr='calendar' wsv='fr' sense='Tue' />
						<Link wsa='en' abbr='calendar' wsv='fr' sense='Wed' />
					</LexicalRelations>
				</LexSense>
			</Senses>
		</LexEntry>
	</Entries>
</LexDb>"))
			{
				Assert.AreEqual(0, m_cache.LangProject.LexDbOA.Entries.Count(), "The lexicon starts out empty.");
				Assert.AreEqual(0, m_cache.LangProject.AnthroListOA.PossibilitiesOS.Count);
				Assert.AreEqual(0, m_cache.LangProject.SemanticDomainListOA.PossibilitiesOS.Count);
				Assert.AreEqual(0, m_cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Count);
				ILexRefType calendar = null;
				UndoableUnitOfWorkHelper.Do("do", "undo", m_cache.ActionHandlerAccessor, () =>
				{
					m_cache.LangProject.LexDbOA.ReferencesOA = m_cache.ServiceLocator.GetInstance<ICmPossibilityListFactory>().Create();
					calendar = m_cache.ServiceLocator.GetInstance<ILexRefTypeFactory>().Create();
					m_cache.LangProject.LexDbOA.ReferencesOA.PossibilitiesOS.Add(calendar);
					// The importer would create this relation, but it would not defaul to the desired type
					calendar.Name.SetAnalysisDefaultWritingSystem("calendar");
					calendar.MappingType = (int)LexRefTypeTags.MappingTypes.kmtSenseSequence;
				});
				StringBuilder sbLog = new StringBuilder();
				xid.ImportData(rdr, new StringWriter(sbLog), null);
				// The entries are Mon, Tue, Wed.
				// The input specifies (three times!) that there is a Calendar relation Mon, Tue, Wed.
				Assert.AreEqual(3, m_cache.LangProject.LexDbOA.Entries.Count());
				var lrtRepo = m_cache.ServiceLocator.GetInstance<ILexRefTypeRepository>();
				foreach (var lrt in lrtRepo.AllInstances())
				{
					if (lrt.Name.AnalysisDefaultWritingSystem.Text == "calendar")
					{
						Assert.That(lrt, Is.EqualTo(calendar), "Should only have one Calendar LRT");
					}
				}
				var relations = calendar.MembersOC.ToArray();
				Assert.That(relations, Has.Length.EqualTo(1), "should have produced exactly one lexical relation");
				var items = relations[0].TargetsRS;
				Assert.That(items, Has.Count.EqualTo(3), "relation should have three items");
				Assert.That(((ILexEntry)items[0].Owner).LexemeFormOA.Form.VernacularDefaultWritingSystem.Text, Is.EqualTo("Mon"),
					"First thing in relation should be Mon");
				Assert.That(((ILexEntry)items[1].Owner).LexemeFormOA.Form.VernacularDefaultWritingSystem.Text, Is.EqualTo("Tue"),
					"Second thing in relation should be Tue");
				Assert.That(((ILexEntry)items[2].Owner).LexemeFormOA.Form.VernacularDefaultWritingSystem.Text, Is.EqualTo("Wed"),
					"Third thing in relation should be Wed");
			}
		}
示例#14
0
		public void ImportData4()
		{
			DateTime dtLexOrig = m_cache.LangProject.LexDbOA.DateCreated;
			TimeSpan span = new TimeSpan(dtLexOrig.Ticks - m_now.Ticks);
			Assert.LessOrEqual(span.TotalMinutes, 1.0);
			// should be only a second or two
			XmlImportData xid = new XmlImportData(m_cache);
			using (var rdr = new StringReader(
				"<LexDb>" + Environment.NewLine +
				"<Entries>" + Environment.NewLine +
				"<LexEntry>" + Environment.NewLine +
				"<LexemeForm>" + Environment.NewLine +
				"<MoStemAllomorph>" + Environment.NewLine +
				"<MorphType>" + Environment.NewLine +
				"<Link ws=\"en\" name=\"phrase\" />" + Environment.NewLine +
				"</MorphType>" + Environment.NewLine +
				"<Form>" + Environment.NewLine +
				"<AUni ws=\"qaa-x-kal\">inline test entry</AUni>" + Environment.NewLine +
				"</Form>" + Environment.NewLine +
				"</MoStemAllomorph>" + Environment.NewLine +
				"</LexemeForm>" + Environment.NewLine +
				"<Etymology>" + Environment.NewLine +
				"<LexEtymology>" + Environment.NewLine +
				"<Source>" + Environment.NewLine +
				"<Uni>|bBold|r regular |iItalic|r|fw{greek}ignored*bold*words|b|ibold-italic|r|r|bBOLD  |r</Uni>" + Environment.NewLine +
				"</Source>" + Environment.NewLine +
				"</LexEtymology>" + Environment.NewLine +
				"</Etymology>" + Environment.NewLine +
				"<Senses>" + Environment.NewLine +
				"<LexSense>" + Environment.NewLine +
				"<Definition>" + Environment.NewLine +
				"<AStr ws=\"en\">" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Heavy\">Bold</Run>" + Environment.NewLine +
				"<Run ws=\"en\"> regular </Run>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Emphasized Text\">Italic</Run>" + Environment.NewLine +
				"<Run ws=\"es\">greek</Run>" + Environment.NewLine +
				"<Run ws=\"es\">ignored</Run>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Emphasized Text\">bold</Run>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Emphasized Text\">words</Run>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Emphasized Text\">bold-italic</Run>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Heavy\">BOLD </Run>" + Environment.NewLine +
				"</AStr>" + Environment.NewLine +
				"</Definition>" + Environment.NewLine +
				"<Gloss>" + Environment.NewLine +
				"<AUni ws=\"es\">|bBold|r regular |iItalic|r|fw{greek}ignored*bold*words|b|ibold-italic|r|r|bBOLD |r</AUni>" + Environment.NewLine +
				"</Gloss>" + Environment.NewLine +
				"<Examples>" + Environment.NewLine +
				"<LexExampleSentence>" + Environment.NewLine +
				"<Translations />" + Environment.NewLine +
				"<Reference>" + Environment.NewLine +
				"<Str>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Heavy\">Bold</Run>" + Environment.NewLine +
				"<Run ws=\"en\"> regular </Run>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Emphasized Text\">Italic</Run>" + Environment.NewLine +
				"<Run ws=\"es\">greek</Run>" + Environment.NewLine +
				"<Run ws=\"es\">ignored</Run>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Emphasized Text\">bold</Run>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Emphasized Text\">words</Run>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Emphasized Text\">bold-italic</Run>" + Environment.NewLine +
				"<Run ws=\"en\" namedStyle=\"Heavy\">BOLD  </Run>" + Environment.NewLine +
				"</Str>" + Environment.NewLine +
				"</Reference>" + Environment.NewLine +
				"</LexExampleSentence>" + Environment.NewLine +
				"</Examples>" + Environment.NewLine +
				"</LexSense>" + Environment.NewLine +
				"</Senses>" + Environment.NewLine +
				"</LexEntry>" + Environment.NewLine +
				"</Entries>" + Environment.NewLine +
				"</LexDb>" + Environment.NewLine))
			{
			Assert.AreEqual(0, m_cache.LangProject.LexDbOA.Entries.Count(), "The lexicon starts out empty.");
			Assert.AreEqual(0, m_cache.LangProject.AnthroListOA.PossibilitiesOS.Count);
			Assert.AreEqual(0, m_cache.LangProject.SemanticDomainListOA.PossibilitiesOS.Count);
			Assert.AreEqual(0, m_cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Count);
			StringBuilder sbLog = new StringBuilder();
			xid.ImportData(rdr, new StringWriter(sbLog), null);
			Assert.AreEqual(1, m_cache.LangProject.LexDbOA.Entries.Count());
			ILexEntry le = m_cache.LangProject.LexDbOA.Entries.ToArray()[0];
			int wsKal = m_cache.WritingSystemFactory.GetWsFromStr("qaa-x-kal");
			Assert.AreEqual("inline test entry", le.LexemeFormOA.Form.get_String(wsKal).Text);
			Assert.AreEqual(MoMorphTypeTags.kguidMorphPhrase, le.LexemeFormOA.MorphTypeRA.Guid);
			Assert.AreEqual(1, le.SensesOS.Count);
			int wsEn = m_cache.WritingSystemFactory.GetWsFromStr("en");
			Assert.AreEqual("Bold regular Italicgreekignoredboldwordsbold-italicBOLD ", le.SensesOS[0].Definition.get_String(wsEn).Text);
			Assert.AreEqual(0, le.SensesOS[0].SensesOS.Count);

			string sLog = sbLog.ToString();
			Assert.IsFalse(String.IsNullOrEmpty(sLog), "There should be some log information!");
			string[] rgsLog = sLog.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
			Assert.LessOrEqual(1, rgsLog.Length);
			Assert.AreEqual("data stream:0: Info: Creating new writing system for \"qaa-x-kal\".", rgsLog[0]);
			}
		}