/// <summary> /// </summary> /// <param name="parser"></param> /// <param name="task"></param> public void ParserUpdateHandlerForPolling(ParserScheduler parser, TaskReport task) { CheckDisposed(); //store this for clients which just want to poll us, instead of wiring up to the event m_activity = task.Description; m_currentError = task.CurrentError; if (task.NotificationMessage != null && task.Phase != TaskReport.TaskPhase.finished) //keeps us from getting the notification at the end of the task. { m_notificationMessage = task.NotificationMessage; } //will have to do something more smart something when details is used for something else if (task.Details != null) { TraceResult = task.Details; } if (m_currentError != null) { System.Windows.Forms.MessageBox.Show(m_currentError.Message, ParserServiceStrings.ksParserProblem, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
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()); } } }
/// <summary> /// /// </summary> public bool RetrieveModel() { lock (m_syncRoot) { if (m_loaded) { return(false); } m_loaded = true; } // According to the fxt template files, GAFAWS is NFC, all others are NFD. using (new WorkerThreadReadHelper(m_cache.ServiceLocator.GetInstance <IWorkerThreadReadHandler>())) { ILangProject lp = m_cache.LanguageProject; using (var task = new TaskReport(ParserCoreStrings.ksRetrievingGrammarAndLexicon, m_taskUpdateHandler)) { // 1. Export lexicon and/or grammar. m_modelDom = null; M3ModelExportServices.ExportGrammarAndLexicon(m_modelPath, lp); } // 2. Export GAFAWS data. using (var task = new TaskReport(ParserCoreStrings.ksRetrievingTemplateInformation, m_taskUpdateHandler)) { // The following needs to be enabled, in order to avoid an exception bieng thrown after the export work, // but it is such a handy way to get Flex to stop in my profiler. :-) m_templateDom = null; M3ModelExportServices.ExportGafaws(m_outputDirectory, m_cache.ProjectId.Name, lp.PartsOfSpeechOA.PossibilitiesOS); } } return(true); }
// public TaskReport(string description) // { // m_phase=TaskPhase.started; // m_description = description; // m_start = DateTime.Now.Ticks; // } internal TaskReport(string description, TaskReport owningTask) { m_OwningTask = owningTask; m_phase=TaskPhase.started; m_description = description; m_start = DateTime.Now.Ticks; }
private void CheckNeedsUpdate() { using (var task = new TaskReport(ParserCoreStrings.ksUpdatingGrammarAndLexicon, m_taskUpdateHandler)) { if (!m_parser.IsUpToDate()) { m_parser.Update(); } } }
private void InformListeners(TaskReport task) { //the root task executes this if (m_taskUpdate != null) { m_taskUpdate(task); } //all children tasks execute this else if (m_owningTask != null) { m_owningTask.InformListeners(this); } }
/// <summary> /// Try parsing a wordform, optionally getting a trace of the parse /// </summary> /// <param name="sForm">the word form to parse</param> /// <param name="fDoTrace">whether or not to trace the parse</param> /// <param name="sSelectTraceMorphs">list of msa hvos to limit trace to </param> internal void TryAWord(string sForm, bool fDoTrace, string sSelectTraceMorphs) { CheckDisposed(); if (sForm == null) { throw new ArgumentNullException("sForm", "TryAWord cannot trace a Null string."); } if (sForm == String.Empty) { throw new ArgumentException("Can't try a word with no content.", "sForm"); } using (TaskReport task = new TaskReport( String.Format(ParserCoreStrings.ksTraceWordformX, sForm), m_taskUpdateHandler)) { try { string normForm = Icu.Normalize(sForm, Icu.UNormalizationMode.UNORM_NFD); string result = null; if (fDoTrace) { //Debug.WriteLine("Begin tracing wordform " + sForm); result = TraceWord(normForm, sSelectTraceMorphs); //Debug.WriteLine("After tacing wordform " + sForm); //Debug.WriteLine("Result of trace: " + task.Details); } else { result = ParseWord(normForm, 0); } task.Details = Icu.Normalize(result, Icu.UNormalizationMode.UNORM_NFD); return; } catch (Exception error) { Trace.WriteLineIf(tracingSwitch.TraceError, "The word '" + sForm + "' failed to parse. error was: " + error.Message); task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! //might as well keep going. //TODO: create an problem object since we could not parse this word. throw new ApplicationException("Error while parsing '" + sForm + "'.", error); } } }
/// <summary> /// This method was added because child TaskReport objects were /// being disposed of while they were still contained in the parents /// subtask list. Then when the parent was disposed of it would dispose /// of the child TaskReports that it had and one or more would already /// have been disposed. the child /// would be attempted to dispose /// </summary> /// <param name="report"></param> private void RemoveChildTaskReport(TaskReport report) { // If we're in the Dispose, part of it will call dispose on the child // objects which will call back here to let the parent break the ties, // but when we're in the dispose we don't want that to happen as we're // most likely walking the subtask list and this isn't needed. if (m_isInDispose == false && m_subTasks != null) { // Debug.WriteLine("** Disposing subtask <"+report.GetHashCode()+"> owned by " + GetHashCode().ToString()); m_subTasks.Remove(report); if (m_subTasks.Count == 0) // other places in the code expect a non null value to mean data, so set it to null when empty. { m_subTasks = null; } } }
internal void PrepareTemplatesForXAmpleFiles(ref XmlDocument domModel, XmlDocument domTemplate) { using (var task = new TaskReport(ParserCoreStrings.ksPreparingTemplatesForXAmple, m_taskUpdateHandler)) { // 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, task); string sResultFile = ApplyGafawsAlgorithm(sGafawsFile); //based on results of GAFAWS, modify the model dom by inserting orderclass in slots InsertOrderclassInfo(ref domModel, sResultFile); } } }
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); } } }
protected override void DisposeManagedResources() { m_thread.Stop(); m_thread.Dispose(); if (m_parserWorker != null) { m_parserWorker.ParseFiler.WordformUpdated -= ParseFiler_WordformUpdated; m_parserWorker.Dispose(); m_parserWorker = null; } if (m_TaskReport != null) { m_TaskReport.Dispose(); m_TaskReport = null; } }
/// <summary> /// this will be called from the parser's thread; we need to marshal it to the client's thread /// so that it comes in as a normal event in the event handling loop of the client. /// </summary> /// <param name="parser"></param> /// <param name="task"></param> public void ParserUpdateHandler(ParserScheduler parser, TaskReport task) { CheckDisposed(); if (null == m_clientTaskReportHandler) { return; } lock (this) { //using Invoke () here would cause this thread to wait until the event was handled. ((Control)m_clientTaskReportHandler.Target).BeginInvoke(m_clientTaskReportHandler, new object[] { parser, task }); } //testing //((Control)m_clientTaskReportHandler.Target).Invoke(m_clientTaskReportHandler, new object[] {parser, task}); }
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 TimeStamp LoadGrammarAndLexicon(ParserScheduler.NeedsUpdate eNeedsUpdate) { CheckDisposed(); Trace.WriteLineIf(tracingSwitch.TraceInfo, "Worker.LoadGrammarAndLexicon: eNeedsUpdate = " + eNeedsUpdate); string sDescription = SetDescription(eNeedsUpdate); TaskReport task = new TaskReport(sDescription, m_taskUpdateHandler); // no longer need this pop-up; was only for debugging // task.NotificationMessage = "Loading Parser"; if (m_retriever == null) { m_retriever = new M3ParserModelRetriever(m_database); } TimeStamp stamp; using (task) { XmlDocument fxtResult; XmlDocument gafawsFxtResult; try { DateTime startTime = DateTime.Now; stamp = m_retriever.RetrieveModel(m_connection, m_LangProject, task, eNeedsUpdate); long ttlTicks = DateTime.Now.Ticks - startTime.Ticks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "FXT took : " + ttlTicks.ToString()); fxtResult = m_retriever.ModelDom; gafawsFxtResult = m_retriever.TemplateDom; } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw new ApplicationException("Error while retrieving model for the Parser.", error); } LoadParser(ref fxtResult, gafawsFxtResult, task, eNeedsUpdate); } return(stamp); }
/// <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); }
private void HandleTaskUpdate(TaskReport task) { if (IsDisposed) { return; } if (ParserUpdateNormal != null && ((task.Depth == 0) || (task.NotificationMessage != null))) { //notify any delegates ParserUpdateNormal(this, new ParserUpdateEventArgs(task)); } if (ParserUpdateVerbose != null) { //notify any delegates ParserUpdateVerbose(this, new ParserUpdateEventArgs(task.MostRecentTask) /*not sure this is right*/); } }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> private void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) { return; } if (disposing) { m_isInDispose = true; // handle the case where the child is disposed of before the parent and not by the parent directly if (m_OwningTask != null) { m_OwningTask.RemoveChildTaskReport(this); // break assocations before disposing } // Dispose managed resources here. if (m_subTasks != null) { foreach (TaskReport task in m_subTasks) { task.Dispose(); } } Finish(); if (m_subTasks != null) { m_subTasks.Clear(); } m_isInDispose = false; } // Dispose unmanaged resources here, whether disposing is true or false. m_OwningTask = null; m_currentError = null; m_details = null; m_description = null; m_notificationMessage = null; m_subTasks = null; m_isDisposed = true; }
/// <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; }
/// <summary> /// Try parsing a wordform, optionally getting a trace of the parse /// </summary> /// <param name="sForm">the word form to parse</param> /// <param name="fDoTrace">whether or not to trace the parse</param> /// <param name="sSelectTraceMorphs">list of msa hvos to limit trace to </param> public void TryAWord(string sForm, bool fDoTrace, int[] sSelectTraceMorphs) { CheckDisposed(); if (sForm == null) { throw new ArgumentNullException("sForm", "TryAWord cannot trace a Null string."); } if (sForm == String.Empty) { throw new ArgumentException("Can't try a word with no content.", "sForm"); } CheckNeedsUpdate(); using (var task = new TaskReport(string.Format(ParserCoreStrings.ksTraceWordformX, sForm), m_taskUpdateHandler)) { string normForm = Icu.Normalize(sForm, Icu.UNormalizationMode.UNORM_NFD); task.Details = fDoTrace ? m_parser.TraceWordXml(normForm, sSelectTraceMorphs) : m_parser.ParseWordXml(normForm); } }
private void HandleTaskUpdate(TaskReport task) { CheckDisposed(); Trace.WriteLineIf(m_tracingSwitch.TraceInfo, "Scheduler.HandleTaskUpdate() " + task.Description + " " + task.PhaseDescription); if (ParserUpdateNormal != null && ((task.Depth == 0) || (task.NotificationMessage != null))) { //notify any delegates ParserUpdateNormal(this, new ParserUpdateEventArgs(task)); } if (ParserUpdateVerbose != null) { //notify any delegates ParserUpdateVerbose(this, new ParserUpdateEventArgs(task.MostRecentTask) /*not sure this is right*/); } Trace.WriteLineIf(m_tracingSwitch.TraceInfo, " Exiting HandleTaskUpdate()" + task.Description); }
private void DecrementQueueCount(ParserPriority priority) { bool isIdle; lock (SyncRoot) { m_queueCounts[(int)priority]--; isIdle = m_queueCounts[(int)ParserPriority.TryAWord] == 0 && m_queueCounts[(int)ParserPriority.Low] == 0 && m_queueCounts[(int)ParserPriority.Medium] == 0 && m_queueCounts[(int)ParserPriority.High] == 0; } if (isIdle && (m_TaskReport == null || m_TaskReport.Description == ParserCoreStrings.ksIdle_)) { if (m_TaskReport != null) { m_TaskReport.Dispose(); } m_TaskReport = new TaskReport(ParserCoreStrings.ksIdle_, HandleTaskUpdate); } }
protected override void DisposeManagedResources() { if (m_thread.Stop()) { Trace.WriteLineIf(m_tracingSwitch.TraceInfo, "==== ParserScheduler thread Successfully shutdown."); } else { Trace.WriteLineIf(m_tracingSwitch.TraceError, "**** ERROR : ParserScheduler Thread didn't shutdown."); } m_thread.Dispose(); m_parserWorker.ParseFiler.WordformUpdated -= ParseFiler_WordformUpdated; m_parserWorker.Dispose(); if (m_TaskReport != null) { m_TaskReport.Dispose(); m_TaskReport = null; } }
private void LoadXAmpleFiles(TaskReport task) { try { EnsureXampleSupportFilesExist(); string tempPath = System.IO.Path.GetTempPath(); string xPath = XAmpleFixedFilesPath; m_xample.LoadFiles(xPath, tempPath, m_database); m_XAmpleHasBeenLoaded = true; } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } ApplicationException e = new ApplicationException("Error while loading the Parser.", error); task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw e; } }
internal void MakeAmpleFiles(XmlDocument model) { using (var task = new TaskReport(ParserCoreStrings.ksMakingXAmpleFiles, m_taskUpdateHandler)) { DateTime startTime = DateTime.Now; TransformDomToFile("FxtM3ParserToXAmpleADCtl.xsl", model, m_database + "adctl.txt", task); TransformDomToFile("FxtM3ParserToToXAmpleGrammar.xsl", model, m_database + "gram.txt", task); Trace.WriteLineIf(m_tracingSwitch.TraceInfo, "Grammar XSLTs took : " + (DateTime.Now.Ticks - startTime.Ticks)); // 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, task); Trace.WriteLineIf(m_tracingSwitch.TraceInfo, "WordGrammarDebugger XSLT took : " + (DateTime.Now.Ticks - startTime.Ticks)); startTime = DateTime.Now; TransformDomToFile("FxtM3ParserToXAmpleLex.xsl", model, m_database + "lex.txt", task); Trace.WriteLineIf(m_tracingSwitch.TraceInfo, "Lex XSLT took : " + (DateTime.Now.Ticks - startTime.Ticks)); } }
internal TaskReport AddSubTask(string description) { CheckDisposed(); Debug.Assert(m_phase != TaskPhase.Finished); var t = new TaskReport(description, this); if (m_subTasks == null) { m_subTasks = new List <TaskReport>(); } else { //a new set task should not be added until the previous one is finished. TaskPhase phase = m_subTasks[m_subTasks.Count - 1].Phase; Debug.Assert(phase == TaskPhase.Finished); // || phase == TaskPhase.ErrorEncountered); } m_subTasks.Add(t); //this cannot be in the constructor because if the listener asks //for the most recent task, it will not get this one until after //this has been added to the subtasks list. t.InformListeners(TaskPhase.Started); return(t); }
private void InformListeners(TaskReport task) { lock (this) { //the root task executes this if (m_taskUpdateEvent != null) { m_taskUpdateEvent(task); } //all children tasks execute this else if (m_OwningTask != null) { this.m_OwningTask.InformListeners(this); } else { //this is not really an error situation. It just means that no one subscribed to events. //This may happen, for example, when we are just executing unit tests. //Debug.Assert( false); } } }
/// <summary> /// this will be called from the parser's thread; we need to marshal it to the client's thread /// so that it comes in as a normal event in the event handling loop of the client. /// </summary> /// <param name="parser"></param> /// <param name="task"></param> public void ParserUpdateHandler(ParserScheduler parser, TaskReport task) { CheckDisposed(); if(null == m_clientTaskReportHandler) return; lock(this) { //using Invoke () here would cause this thread to wait until the event was handled. ((Control)m_clientTaskReportHandler.Target).BeginInvoke(m_clientTaskReportHandler, new object[] {parser, task}); } //testing //((Control)m_clientTaskReportHandler.Target).Invoke(m_clientTaskReportHandler, new object[] {parser, task}); }
/// <summary> /// </summary> /// <param name="parser"></param> /// <param name="task"></param> public void ParserUpdateHandlerForPolling(ParserScheduler parser, TaskReport task) { CheckDisposed(); //store this for clients which just want to poll us, instead of wiring up to the event m_activity = task.Description; m_currentError = task.CurrentError; if(task.NotificationMessage!=null && task.Phase != TaskReport.TaskPhase.finished )//keeps us from getting the notification at the end of the task. m_notificationMessage = task.NotificationMessage; //will have to do something more smart something when details is used for something else if(task.Details != null) TraceResult = task.Details; if (m_currentError!= null) System.Windows.Forms.MessageBox.Show(m_currentError.Message, ParserServiceStrings.ksParserProblem, MessageBoxButtons.OK,MessageBoxIcon.Exclamation); }
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); } } }
//this is invoked by the parser connection, on our own event handling thread. protected void ParserUpdateHandler(ParserScheduler parser, TaskReport task) { if (m_previousTask != task) { m_log.Text += "\r\n"; Debug.WriteLine(""); } string pad = ""; for(int i= task.Depth; i>0;i--) pad += " "; m_log.Text+=pad; switch(task.Phase) { case TaskReport.TaskPhase.started: m_log.Text += task.Description+" ";//+pad + "{\r\n"; Debug.Write(task.Description+" "); break; case TaskReport.TaskPhase.finished: if (m_previousTask != task) m_log.Text +=" ^ "; m_log.Text += task.DurationSeconds.ToString()+ " seconds"; Debug.Write(task.DurationSeconds.ToString()+ " seconds"); //m_log.Text += "}\r\n"; if (task.Details != null) m_log.Text += "Details:"+task.Details; break; default: m_log.Text += task.Description+" " + task.PhaseDescription ;//+ "\r\n"; Debug.Write(task.Description+" " + task.PhaseDescription); break; } m_log.Select(m_log.Text.Length,0); m_log.ScrollToCaret(); m_previousTask = task; }
internal void HandleTaskUpdate(TaskReport task) { CheckDisposed(); Trace.WriteLineIf(tracingSwitch.TraceInfo, task.Description + " " + task.PhaseDescription); if (ParserUpdateNormal != null && ((task.Depth == 0) || (task.NotificationMessage != null))) { //notify any delegates ParserUpdateNormal(this, task); } if (ParserUpdateVerbose != null) { //notify any delegates ParserUpdateVerbose(this, task.MostRecentTask /*not sure this is right*/); } System.Diagnostics.Trace.WriteLineIf(tracingSwitch.TraceInfo, task.Description); }
private void HandleTaskUpdate(TaskReport task) { if (IsDisposed) return; if (ParserUpdateNormal != null && ((task.Depth == 0) || (task.NotificationMessage != null))) { //notify any delegates ParserUpdateNormal(this, new ParserUpdateEventArgs(task)); } if (ParserUpdateVerbose != null) { //notify any delegates ParserUpdateVerbose(this, new ParserUpdateEventArgs(task.MostRecentTask)/*not sure this is right*/); } }
//this is invoked by the parser connection, on our own event handling thread. protected void ParserUpdateHandler(ParserScheduler parser, TaskReport task) { Trace.WriteLine(" In ParserUpdateHandler"); try { switch (task.Phase) { case TaskReport.TaskPhase.started: m_lblStatus.Text = m_sParserStatusPrefix + task.Description + m_sParserStatusSuffix; Trace.WriteLine(" started: " + task.Description); break; case TaskReport.TaskPhase.finished: m_lblStatus.Text = m_sParserStatusPrefix + task.Description + m_sParserStatusSuffix; Trace.WriteLine(" finished: " + task.Description); Trace.WriteLine(" finished: Duration: " + task.DurationSeconds.ToString() + " seconds"); Trace.WriteLineIf(task.Details != null, "finished: Details: " + task.Details); break; default: m_lblStatus.Text = m_sParserStatusPrefix + task.Description + m_sParserStatusSuffix; Trace.WriteLine(" default: " + task.Description + " " + task.PhaseDescription); break; } } catch (ObjectDisposedException ode) { // By the time we get any "finished" tasks, they have been disposed. Ignore them. Trace.WriteLine(" " + ode.Message); Trace.WriteLine(" " + ode.StackTrace); } }
private void CheckNeedsUpdate() { using (var task = new TaskReport(ParserCoreStrings.ksUpdatingGrammarAndLexicon, m_taskUpdateHandler)) { if (!m_parser.IsUpToDate()) m_parser.Update(); } }
/// <summary> /// This method was added because child TaskReport objects were /// being disposed of while they were still contained in the parents /// subtask list. Then when the parent was disposed of it would dispose /// of the child TaskReports that it had and one or more would already /// have been disposed. the child /// would be attempted to dispose /// </summary> /// <param name="report"></param> private void RemoveChildTaskReport(TaskReport report) { // If we're in the Dispose, part of it will call dispose on the child // objects which will call back here to let the parent break the ties, // but when we're in the dispose we don't want that to happen as we're // most likely walking the subtask list and this isn't needed. if (m_isInDispose == false && m_subTasks != null) { // Debug.WriteLine("** Disposing subtask <"+report.GetHashCode()+"> owned by " + GetHashCode().ToString()); m_subTasks.Remove(report); if (m_subTasks.Count == 0) // other places in the code expect a non null value to mean data, so set it to null when empty. m_subTasks = null; } }
/// <summary> /// Try parsing a wordform, optionally getting a trace of the parse /// </summary> /// <param name="sForm">the word form to parse</param> /// <param name="fDoTrace">whether or not to trace the parse</param> /// <param name="sSelectTraceMorphs">list of msa hvos to limit trace to </param> public void TryAWord(string sForm, bool fDoTrace, string sSelectTraceMorphs) { CheckDisposed(); if (sForm == null) throw new ArgumentNullException("sForm", "TryAWord cannot trace a Null string."); if (sForm == String.Empty) throw new ArgumentException("Can't try a word with no content.", "sForm"); CheckNeedsUpdate(); using (var task = new TaskReport(string.Format(ParserCoreStrings.ksTraceWordformX, sForm), m_taskUpdateHandler)) { string normForm = Icu.Normalize(sForm, Icu.UNormalizationMode.UNORM_NFD); task.Details = fDoTrace ? m_parser.TraceWordXml(normForm, sSelectTraceMorphs) : m_parser.ParseWordXml(normForm); } }
internal TimeStamp LoadGrammarAndLexicon(ParserScheduler.NeedsUpdate eNeedsUpdate) { CheckDisposed(); Trace.WriteLineIf(tracingSwitch.TraceInfo, "Worker.LoadGrammarAndLexicon: eNeedsUpdate = " + eNeedsUpdate); string sDescription = SetDescription(eNeedsUpdate); TaskReport task = new TaskReport(sDescription, m_taskUpdateHandler); // no longer need this pop-up; was only for debugging // task.NotificationMessage = "Loading Parser"; if (m_retriever == null) m_retriever = new M3ParserModelRetriever(m_database); TimeStamp stamp; using (task) { XmlDocument fxtResult; XmlDocument gafawsFxtResult; try { DateTime startTime = DateTime.Now; stamp = m_retriever.RetrieveModel(m_connection, m_LangProject, task, eNeedsUpdate); long ttlTicks = DateTime.Now.Ticks - startTime.Ticks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "FXT took : " + ttlTicks.ToString()); fxtResult = m_retriever.ModelDom; gafawsFxtResult = m_retriever.TemplateDom; } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw new ApplicationException("Error while retrieving model for the Parser.", error); } LoadParser(ref fxtResult, gafawsFxtResult, task, eNeedsUpdate); } return stamp; }
/// <summary> /// Try parsing a wordform, optionally getting a trace of the parse /// </summary> /// <param name="sForm">the word form to parse</param> /// <param name="fDoTrace">whether or not to trace the parse</param> /// <param name="sSelectTraceMorphs">list of msa hvos to limit trace to </param> internal void TryAWord(string sForm, bool fDoTrace, string sSelectTraceMorphs) { CheckDisposed(); if (sForm == null) throw new ArgumentNullException("sForm", "TryAWord cannot trace a Null string."); if (sForm == String.Empty) throw new ArgumentException("Can't try a word with no content.", "sForm"); using (TaskReport task = new TaskReport( String.Format(ParserCoreStrings.ksTraceWordformX, sForm), m_taskUpdateHandler)) { try { string normForm = Icu.Normalize(sForm, Icu.UNormalizationMode.UNORM_NFD); string result = null; if (fDoTrace) { //Debug.WriteLine("Begin tracing wordform " + sForm); result = TraceWord(normForm, sSelectTraceMorphs); //Debug.WriteLine("After tacing wordform " + sForm); //Debug.WriteLine("Result of trace: " + task.Details); } else result = ParseWord(normForm, 0); task.Details = Icu.Normalize(result, Icu.UNormalizationMode.UNORM_NFD); return; } catch (Exception error) { Trace.WriteLineIf(tracingSwitch.TraceError, "The word '" + sForm + "' failed to parse. error was: " + error.Message); task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! //might as well keep going. //TODO: create an problem object since we could not parse this word. throw new ApplicationException("Error while parsing '" + sForm + "'.",error); } } }
protected override void LoadParser(ref XmlDocument model, XmlDocument template, TaskReport task, ParserScheduler.NeedsUpdate eNeedsUpdate) { try { M3ToHCTransformer transformer = new M3ToHCTransformer(m_database); transformer.MakeHCFiles(ref model, task, eNeedsUpdate); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw new ApplicationException("Error while generating files for the Parser.", error); } try { string gramPath = Path.Combine(m_outputDirectory, m_database + "gram.txt"); m_patr.LoadGrammarFile(gramPath); string hcPath = Path.Combine(m_outputDirectory, m_database + "HCInput.xml"); m_loader.Load(hcPath); XmlNode delReappsNode = model.SelectSingleNode("/M3Dump/ParserParameters/HC/DelReapps"); if (delReappsNode != null) { m_loader.CurrentMorpher.DelReapplications = Convert.ToInt32(delReappsNode.InnerText); } } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } ApplicationException e = new ApplicationException("Error while loading the Parser.", error); task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw e; } }
/// <summary> /// transform the POS that has templates to GAFAWS format /// </summary> protected void TransformPOSInfoToGafawsInputFormat(XmlNode templateNode, string sGafawsFile, TaskReport task) { var dom = new XmlDocument(); dom.CreateElement("GAFAWSData"); // create root element dom.InnerXml = templateNode.OuterXml; // copy in POS elements TransformDomToFile("FxtM3ParserToGAFAWS.xsl", dom, sGafawsFile, task); }
private void DecrementQueueCount(ParserPriority priority) { bool isIdle; lock (SyncRoot) { m_queueCounts[(int) priority]--; isIdle = m_queueCounts[(int)ParserPriority.TryAWord] == 0 && m_queueCounts[(int)ParserPriority.Low] == 0 && m_queueCounts[(int)ParserPriority.Medium] == 0 && m_queueCounts[(int)ParserPriority.High] == 0; } if (isIdle && (m_TaskReport == null || m_TaskReport.Description == ParserCoreStrings.ksIdle_)) { if (m_TaskReport != null) m_TaskReport.Dispose(); m_TaskReport = new TaskReport(ParserCoreStrings.ksIdle_, HandleTaskUpdate); } }
public ParserUpdateEventArgs(TaskReport task) { Task = task; }
protected override void LoadParser(ref XmlDocument model, XmlDocument template, TaskReport task, ParserScheduler.NeedsUpdate eNeedsUpdate) { try { M3ToXAmpleTransformer transformer = new M3ToXAmpleTransformer(m_database); if (eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarAndLexicon || eNeedsUpdate == ParserScheduler.NeedsUpdate.LexiconOnly || eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData) { // even though POS is part of Grammar, this is only used by the lexicon DateTime startTime = DateTime.Now; // PrepareTemplatesForXAmpleFiles adds orderclass elements to MoInflAffixSlot elements transformer.PrepareTemplatesForXAmpleFiles(ref model, template, task); long ttlTicks = DateTime.Now.Ticks - startTime.Ticks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "GAFAWS prep took : " + ttlTicks.ToString()); } transformer.MakeAmpleFiles(model, task, eNeedsUpdate); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw new ApplicationException("Error while generating files for the Parser.", error); } int maxAnalCount = 20; XmlNode maxAnalCountNode = model.SelectSingleNode("/M3Dump/ParserParameters/XAmple/MaxAnalysesToReturn"); if (maxAnalCountNode != null) { maxAnalCount = Convert.ToInt16(maxAnalCountNode.FirstChild.Value); if (maxAnalCount < 1) { maxAnalCount = -1; } } try { m_xample.SetParameter("MaxAnalysesToReturn", maxAnalCount.ToString()); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } ApplicationException e = new ApplicationException("Error while setting Parser parameters.", error); task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw e; } LoadXAmpleFiles(task); }
internal void UpdateWordform(int hvoWordform) { CheckDisposed(); //the WFI DLL, created with FieldWorks COM code, can only be accessed by an STA // REVIEW JohnH(RandyR): Is this still relevant, now that ParseFiler isn't in its own DLL? //Debug.Assert( Thread.CurrentThread.ApartmentState == ApartmentState.STA, "Calling thread must set the apartment state to STA"); uint uiCRCWordform; string form = GetWordformStringAndCRC(hvoWordform, out uiCRCWordform); // 'form' will now be null, if it could not find the wordform for whatever reason. // uiCRCWordform will also now be 0, if 'form' is null. // Cf. LT-7203 for how it could be null. if (form == null) { return; } TaskReport task = new TaskReport(String.Format(ParserCoreStrings.ksUpdateX, form), m_taskUpdateHandler); using (task) { Debug.Assert(m_parserFiler != null); string result = ""; try { string sResult = GetOneWordformResult(hvoWordform, form); // GetOneWordformResult can throw an exception //Debug.WriteLine("ParserWorker: Ample result = " + sAmpResult); uint uiCRC = CrcStream.GetCrc(sResult); if (uiCRCWordform != uiCRC) { StringBuilder sb = new StringBuilder(); // use StringBuilder for efficiency sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); // REMOVED THIS FROM THE SAMPLE DOC: xmlns:xsi=\"http://www.w3.org/2000/10/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"C:\ww\code\SampleData\XMLFieldWorksParse.xsd"> sb.Append(" <AnalyzingAgentResults>\n<AnalyzingAgent name=\"" + m_agentInfo.m_name + "\" human=\"" + m_agentInfo.m_isHuman.ToString() + "\" version=\"" + m_agentInfo.m_version + "\">\n"); sb.Append(" <StateInformation />\n</AnalyzingAgent>\n<WordSet>\n"); sb.Append(sResult); sb.Append("</WordSet>\n</AnalyzingAgentResults>\n"); result = sb.ToString(); DateTime startTime = DateTime.Now; m_parserFiler.ProcessParse(result); // ProcessParse can throw exceptions. long ttlTicks = DateTime.Now.Ticks - startTime.Ticks; m_ticksFiler += ttlTicks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "parser filer(" + form + ") took : " + ttlTicks.ToString()); SetChecksum(hvoWordform, uiCRC); } } catch (Exception error) { DebugMsg(error.Message); task.NotificationMessage = error.Message; throw; } } }
protected override void LoadParser(ref XmlDocument model, XmlDocument template, TaskReport task, ParserScheduler.NeedsUpdate eNeedsUpdate) { try { M3ToXAmpleTransformer transformer = new M3ToXAmpleTransformer(m_database); if (eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarAndLexicon || eNeedsUpdate == ParserScheduler.NeedsUpdate.LexiconOnly || eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData) { // even though POS is part of Grammar, this is only used by the lexicon DateTime startTime = DateTime.Now; // PrepareTemplatesForXAmpleFiles adds orderclass elements to MoInflAffixSlot elements transformer.PrepareTemplatesForXAmpleFiles(ref model, template, task); long ttlTicks = DateTime.Now.Ticks - startTime.Ticks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "GAFAWS prep took : " + ttlTicks.ToString()); } transformer.MakeAmpleFiles(model, task, eNeedsUpdate); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw new ApplicationException("Error while generating files for the Parser.", error); } int maxAnalCount = 20; XmlNode maxAnalCountNode = model.SelectSingleNode("/M3Dump/ParserParameters/XAmple/MaxAnalysesToReturn"); if (maxAnalCountNode != null) { maxAnalCount = Convert.ToInt16(maxAnalCountNode.FirstChild.Value); if (maxAnalCount < 1) maxAnalCount = -1; } try { m_xample.SetParameter("MaxAnalysesToReturn", maxAnalCount.ToString()); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } ApplicationException e = new ApplicationException("Error while setting Parser parameters.", error); task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw e; } LoadXAmpleFiles(task); }
protected override void LoadParser(ref XmlDocument model, XmlDocument template, TaskReport task, ParserScheduler.NeedsUpdate eNeedsUpdate) { try { M3ToHCTransformer transformer = new M3ToHCTransformer(m_database); transformer.MakeHCFiles(ref model, task, eNeedsUpdate); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw new ApplicationException("Error while generating files for the Parser.", error); } try { string gramPath = Path.Combine(m_outputDirectory, m_database + "gram.txt"); m_patr.LoadGrammarFile(gramPath); string hcPath = Path.Combine(m_outputDirectory, m_database + "HCInput.xml"); m_loader.Load(hcPath); XmlNode delReappsNode = model.SelectSingleNode("/M3Dump/ParserParameters/HC/DelReapps"); if (delReappsNode != null) m_loader.CurrentMorpher.DelReapplications = Convert.ToInt32(delReappsNode.InnerText); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } ApplicationException e = new ApplicationException("Error while loading the Parser.", error); task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw e; } }
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)); } }
protected abstract void LoadParser(ref XmlDocument model, XmlDocument template, TaskReport task, ParserScheduler.NeedsUpdate eNeedsUpdate);
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> private void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) return; if (disposing) { m_isInDispose = true; // handle the case where the child is disposed of before the parent and not by the parent directly if (m_OwningTask != null) m_OwningTask.RemoveChildTaskReport(this); // break assocations before disposing // Dispose managed resources here. if(m_subTasks != null) { foreach(TaskReport task in m_subTasks) task.Dispose(); } Finish(); if (m_subTasks != null) m_subTasks.Clear(); m_isInDispose = false; } // Dispose unmanaged resources here, whether disposing is true or false. m_OwningTask = null; m_currentError = null; m_details = null; m_description = null; m_notificationMessage = null; m_subTasks = null; m_isDisposed = true; }
internal TaskReport AddSubTask (string description) { CheckDisposed(); Debug.Assert( m_phase != TaskPhase.finished); TaskReport t = new TaskReport(description, this); if (m_subTasks == null) m_subTasks = new List<TaskReport>(); else { //a new set task should not be added until the previous one is finished. TaskPhase phase = m_subTasks[m_subTasks.Count - 1].Phase; Debug.Assert( phase == TaskPhase.finished);// || phase == TaskPhase.errorEncountered); } m_subTasks.Add(t); //this cannot be in the constructor because if the listener asks //for the most recent task, it will not get this one until after //this has been added to the subtasks list. t.InformListeners (TaskPhase.started); return t; }
internal void UpdateWordform(int hvoWordform) { CheckDisposed(); //the WFI DLL, created with FieldWorks COM code, can only be accessed by an STA // REVIEW JohnH(RandyR): Is this still relevant, now that ParseFiler isn't in its own DLL? //Debug.Assert( Thread.CurrentThread.ApartmentState == ApartmentState.STA, "Calling thread must set the apartment state to STA"); uint uiCRCWordform; string form = GetWordformStringAndCRC(hvoWordform, out uiCRCWordform); // 'form' will now be null, if it could not find the wordform for whatever reason. // uiCRCWordform will also now be 0, if 'form' is null. // Cf. LT-7203 for how it could be null. if (form == null) return; TaskReport task = new TaskReport(String.Format(ParserCoreStrings.ksUpdateX, form), m_taskUpdateHandler); using (task) { Debug.Assert(m_parserFiler != null); string result=""; try { string sResult = GetOneWordformResult(hvoWordform, form); // GetOneWordformResult can throw an exception //Debug.WriteLine("ParserWorker: Ample result = " + sAmpResult); uint uiCRC = CrcStream.GetCrc(sResult); if (uiCRCWordform != uiCRC) { StringBuilder sb = new StringBuilder(); // use StringBuilder for efficiency sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); // REMOVED THIS FROM THE SAMPLE DOC: xmlns:xsi=\"http://www.w3.org/2000/10/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"C:\ww\code\SampleData\XMLFieldWorksParse.xsd"> sb.Append(" <AnalyzingAgentResults>\n<AnalyzingAgent name=\"" + m_agentInfo.m_name + "\" human=\"" + m_agentInfo.m_isHuman.ToString() + "\" version=\"" + m_agentInfo.m_version + "\">\n"); sb.Append(" <StateInformation />\n</AnalyzingAgent>\n<WordSet>\n"); sb.Append(sResult); sb.Append("</WordSet>\n</AnalyzingAgentResults>\n"); result = sb.ToString(); DateTime startTime = DateTime.Now; m_parserFiler.ProcessParse(result); // ProcessParse can throw exceptions. long ttlTicks = DateTime.Now.Ticks - startTime.Ticks; m_ticksFiler += ttlTicks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "parser filer(" + form + ") took : " + ttlTicks.ToString()); SetChecksum(hvoWordform, uiCRC); } } catch (Exception error) { DebugMsg(error.Message); task.NotificationMessage = error.Message; throw; } } }
private void InformListeners(TaskReport task) { lock (this) { //the root task executes this if (m_taskUpdateEvent != null) m_taskUpdateEvent(task); //all children tasks execute this else if (m_OwningTask != null) this.m_OwningTask.InformListeners(this); else { //this is not really an error situation. It just means that no one subscribed to events. //This may happen, for example, when we are just executing unit tests. //Debug.Assert( false); } } }
private void InformListeners(TaskReport task) { //the root task executes this if (m_taskUpdate != null) m_taskUpdate(task); //all children tasks execute this else if (m_owningTask != null) m_owningTask.InformListeners(this); }