Example #1
0
        internal void MakeHCFiles(ref XmlDocument model, TaskReport parentTask, ParserScheduler.NeedsUpdate eNeedsUpdate)
        {
            using (m_topLevelTask = parentTask.AddSubTask(ParserCoreStrings.ksMakingXAmpleFiles))
            {
                if (eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarAndLexicon ||
                    eNeedsUpdate == ParserScheduler.NeedsUpdate.LexiconOnly ||
                    eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData)
                {
                    DateTime startTime = DateTime.Now;
                    TransformDomToFile("FxtM3ParserToHCInput.xsl", model, m_database + "HCInput.xml");
                    long ttlTicks = DateTime.Now.Ticks - startTime.Ticks;
                    Trace.WriteLineIf(tracingSwitch.TraceInfo, "Lex XSLT took : " + ttlTicks.ToString());
                }

                if (eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarAndLexicon ||
                    eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarOnly ||
                    eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData)
                {
                    DateTime startTime = DateTime.Now;
                    TransformDomToFile("FxtM3ParserToToXAmpleGrammar.xsl", model, m_database + "gram.txt");
                    long ttlTicks = DateTime.Now.Ticks - startTime.Ticks;
                    Trace.WriteLineIf(tracingSwitch.TraceInfo, "Grammar XSLTs took : " + ttlTicks.ToString());
                    // TODO: Putting this here is not necessarily efficient because it happens every time
                    //       the parser is run.  It would be more efficient to run this only when the user
                    //       is trying a word.  But we need the "model" to apply this transform an it is
                    //       available here, so we're doing this for now.
                    startTime = DateTime.Now;
                    string sName = m_database + "XAmpleWordGrammarDebugger.xsl";
                    TransformDomToFile("FxtM3ParserToXAmpleWordGrammarDebuggingXSLT.xsl", model, sName);
                    ttlTicks = DateTime.Now.Ticks - startTime.Ticks;
                    Trace.WriteLineIf(tracingSwitch.TraceInfo, "WordGrammarDebugger XSLT took : " + ttlTicks.ToString());
                }
            }
        }
Example #2
0
        protected void TransformDomToFile(string transformName, XmlDocument inputDOM, string outputName)
        {
            using (m_topLevelTask.AddSubTask(String.Format(ParserCoreStrings.ksCreatingX, outputName)))
            {
#if UsingDotNetAndNotUsingUtilityTool
                TextWriter writer = null;
                try
                {
                    XslCompiledTransform transformer = new XslCompiledTransform();
                    transformer.Load(PathToWordworksTransforms() + transformName);
                    writer = File.CreateText(m_outputDirectory + "\\" + outputName);
                    transformer.Transform(inputDOM, new XsltArgumentList(), writer, null);
                }
                finally
                {
                    if (writer != null)
                    {
                        writer.Close();
                    }
                }
#else
                SIL.Utils.XmlUtils.TransformDomToFile(Path.Combine(PathToWordworksTransforms(), transformName), inputDOM, Path.Combine(m_outputDirectory, outputName));
#endif
            }
        }
Example #3
0
 protected void TransformDomToFile(string transformName, XmlDocument inputDOM, string outputName, TaskReport task)
 {
     using (task.AddSubTask(String.Format(ParserCoreStrings.ksCreatingX, outputName)))
     {
         XmlUtils.TransformDomToFile(Path.Combine(DirectoryFinder.FWCodeDirectory + "/Language Explorer/Transforms/", transformName),
                                     inputDOM, Path.Combine(m_outputDirectory, outputName));
     }
 }
Example #4
0
		public new void  UpdateWordform(int hvo)
		{
			TaskReport task = new TaskReport("Update Wordform", m_taskUpdateHandler);
			using (task)
			{
				m_xample.ParseWord("testing");

				using(task.AddSubTask("step 1"))
				{
					Delay(2000000);
				}
				using(task.AddSubTask("step 2"))
				{
					Delay(2000000);
				}
			}
		}
Example #5
0
        public new void  UpdateWordform(int hvo)
        {
            TaskReport task = new TaskReport("Update Wordform", m_taskUpdateHandler);

            using (task)
            {
                m_xample.ParseWord("testing");

                using (task.AddSubTask("step 1"))
                {
                    Delay(2000000);
                }
                using (task.AddSubTask("step 2"))
                {
                    Delay(2000000);
                }
            }
        }
 internal void PrepareTemplatesForXAmpleFiles(ref XmlDocument domModel, XmlDocument domTemplate, TaskReport parentTask)
 {
     using (m_topLevelTask = parentTask.AddSubTask(ParserCoreStrings.ksPreparingTemplatesForXAmple))
     {
         // get top level POS that has at least one template with slots
         XmlNodeList templateNodeList = domTemplate.SelectNodes("//PartsOfSpeech/PartOfSpeech[descendant-or-self::MoInflAffixTemplate[PrefixSlots or SuffixSlots]]");
         foreach (XmlNode templateNode in templateNodeList)
         {
             // transform the POS that has templates to GAFAWS format
             string sGafawsFile = m_database + "gafawsData.xml";
             TransformPOSInfoToGafawsInputFormat(templateNode, sGafawsFile);
             string sResultFile = ApplyGafawsAlgorithm(sGafawsFile);
             //based on results of GAFAWS, modify the model dom by inserting orderclass in slots
             InsertOrderclassInfo(ref domModel, sResultFile);
         }
     }
 }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        internal TimeStamp RetrieveModel(SqlConnection connection, string LangProject, TaskReport parentTask, ParserScheduler.NeedsUpdate eNeedsUpdate)
        {
            TimeStamp began = new TimeStamp(connection);

            using (FdoCache cache = FdoCache.Create(connection.DataSource, connection.Database, null))
            {
                BaseVirtualHandler.InstallVirtuals(@"Language Explorer\Configuration\Main.xml",
                                                   new string[] { "SIL.FieldWorks.FDO.", "SIL.FieldWorks.IText." }, cache, true);

                string sDescription;
                string sFxtFile;
                SetDescriptionAndFxtFile(eNeedsUpdate, out sDescription, out sFxtFile);
                using (m_topLevelTask = parentTask.AddSubTask(sDescription))
                {
                    m_taskStack.Push(m_topLevelTask);
                    string sFxtPath = Path.Combine(DirectoryFinder.FWCodeDirectory, sFxtFile);
                    m_sFxtOutputPath = Path.Combine(m_outputDirectory, m_database + "ParserFxtResult.xml");
                    if ((eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData) &&
                        File.Exists(m_sFxtTemplateOutputPath))
                    {
                        try
                        {
                            DoUpdate(cache, sFxtPath, ref m_modelDom);
                            DoUpdate(cache, m_sGafawsFxtPath, ref m_templateDom);
                        }
                        // (SteveMiller): Unremarked, the following often causes an error:
                        // Warning as Error: The variable 'e' is declared but never used
                        catch (XUpdaterException)
                        {
                            //Trace.WriteLine("XUpdater exception caught: " + e.Message);
                            // do something useful for the user
                            DoDump(eNeedsUpdate, cache, sFxtPath);
                        }
                    }
                    else
                    {
                        DoDump(eNeedsUpdate, cache, sFxtPath);
                    }
                }
            }
            m_topLevelTask = null;
            return(began);
        }
Example #8
0
		/// <summary>
		///
		/// </summary>
		internal TimeStamp RetrieveModel(SqlConnection connection, string LangProject, TaskReport parentTask, ParserScheduler.NeedsUpdate eNeedsUpdate)
		{
			TimeStamp began = new TimeStamp(connection);
			using (FdoCache cache = FdoCache.Create(connection.DataSource, connection.Database, null))
			{

				BaseVirtualHandler.InstallVirtuals(@"Language Explorer\Configuration\Main.xml",
					new string[] { "SIL.FieldWorks.FDO.", "SIL.FieldWorks.IText." }, cache, true);

				string sDescription;
				string sFxtFile;
				SetDescriptionAndFxtFile(eNeedsUpdate, out sDescription, out sFxtFile);
				using (m_topLevelTask = parentTask.AddSubTask(sDescription))
				{
					m_taskStack.Push(m_topLevelTask);
					string sFxtPath = Path.Combine(DirectoryFinder.FWCodeDirectory, sFxtFile);
					m_sFxtOutputPath = Path.Combine(m_outputDirectory, m_database + "ParserFxtResult.xml");
					if ((eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData) &&
						File.Exists(m_sFxtTemplateOutputPath))
					{
						try
						{
							DoUpdate(cache, sFxtPath, ref m_modelDom);
							DoUpdate(cache, m_sGafawsFxtPath, ref m_templateDom);
						}
						// (SteveMiller): Unremarked, the following often causes an error:
						// Warning as Error: The variable 'e' is declared but never used
						catch (XUpdaterException)
						{
							//Trace.WriteLine("XUpdater exception caught: " + e.Message);
							// do something useful for the user
							DoDump(eNeedsUpdate, cache, sFxtPath);
						}

					}
					else
						DoDump(eNeedsUpdate, cache, sFxtPath);
				}
			}
			m_topLevelTask = null;
			return began;
		}
Example #9
0
		internal void MakeHCFiles(ref XmlDocument model, TaskReport parentTask, ParserScheduler.NeedsUpdate eNeedsUpdate)
		{
			using (m_topLevelTask = parentTask.AddSubTask(ParserCoreStrings.ksMakingXAmpleFiles))
			{
				if (eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarAndLexicon ||
					eNeedsUpdate == ParserScheduler.NeedsUpdate.LexiconOnly ||
					eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData)
				{
					DateTime startTime = DateTime.Now;
					TransformDomToFile("FxtM3ParserToHCInput.xsl", model, m_database + "HCInput.xml");
					long ttlTicks = DateTime.Now.Ticks - startTime.Ticks;
					Trace.WriteLineIf(tracingSwitch.TraceInfo, "Lex XSLT took : " + ttlTicks.ToString());
				}

				if (eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarAndLexicon ||
					eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarOnly ||
					eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData)
				{
					DateTime startTime = DateTime.Now;
					TransformDomToFile("FxtM3ParserToToXAmpleGrammar.xsl", model, m_database + "gram.txt");
					long ttlTicks = DateTime.Now.Ticks - startTime.Ticks;
					Trace.WriteLineIf(tracingSwitch.TraceInfo, "Grammar XSLTs took : " + ttlTicks.ToString());
					// TODO: Putting this here is not necessarily efficient because it happens every time
					//       the parser is run.  It would be more efficient to run this only when the user
					//       is trying a word.  But we need the "model" to apply this transform an it is
					//       available here, so we're doing this for now.
					startTime = DateTime.Now;
					string sName = m_database + "XAmpleWordGrammarDebugger.xsl";
					TransformDomToFile("FxtM3ParserToXAmpleWordGrammarDebuggingXSLT.xsl", model, sName);
					ttlTicks = DateTime.Now.Ticks - startTime.Ticks;
					Trace.WriteLineIf(tracingSwitch.TraceInfo, "WordGrammarDebugger XSLT took : " + ttlTicks.ToString());
				}
			}
		}
		internal void PrepareTemplatesForXAmpleFiles(ref XmlDocument domModel, XmlDocument domTemplate, TaskReport parentTask)
		{
			using (m_topLevelTask = parentTask.AddSubTask(ParserCoreStrings.ksPreparingTemplatesForXAmple))
			{
				// get top level POS that has at least one template with slots
				XmlNodeList templateNodeList = domTemplate.SelectNodes("//PartsOfSpeech/PartOfSpeech[descendant-or-self::MoInflAffixTemplate[PrefixSlots or SuffixSlots]]");
				foreach (XmlNode templateNode in templateNodeList)
				{
					// transform the POS that has templates to GAFAWS format
					string sGafawsFile = m_database + "gafawsData.xml";
					TransformPOSInfoToGafawsInputFormat(templateNode, sGafawsFile);
					string sResultFile = ApplyGafawsAlgorithm(sGafawsFile);
					//based on results of GAFAWS, modify the model dom by inserting orderclass in slots
					InsertOrderclassInfo(ref domModel, sResultFile);
				}
			}
		}