/// <summary> /// Loads the parser. /// </summary> /// <param name="model">The model.</param> /// <param name="template">The template.</param> protected override void LoadParser(ref XmlDocument model, XmlDocument template) { var transformer = new M3ToXAmpleTransformer(m_projectName, m_taskUpdateHandler); var startTime = DateTime.Now; // PrepareTemplatesForXAmpleFiles adds orderclass elements to MoInflAffixSlot elements transformer.PrepareTemplatesForXAmpleFiles(ref model, template); var ttlTicks = DateTime.Now.Ticks - startTime.Ticks; Trace.WriteLineIf(m_tracingSwitch.TraceInfo, "GAFAWS prep took : " + ttlTicks); transformer.MakeAmpleFiles(model); 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; } } m_xample.SetParameter("MaxAnalysesToReturn", maxAnalCount.ToString()); string tempPath = Path.GetTempPath(); m_xample.LoadFiles(DirectoryFinder.FWCodeDirectory + @"/Language Explorer/Configuration/Grammar", tempPath, m_projectName); }
protected void LoadFilesHelper(XAmpleWrapper wrapper) { var tempPath = "../../Src/LexText/ParserEngine/ParserCore/ParserCoreTests/M3ToXAmpleTransformerTestsDataFiles"; // TODO: use DirectoryFinder.FWCodeDirectory var xPath = "../../DistFiles/" + "/Language Explorer/Configuration/Grammar"; wrapper.LoadFiles(xPath, tempPath, "StemName3"); }
public void Update() { CheckDisposed(); if (m_changeListener.Reset() || m_forceUpdate) { XDocument model, template; // 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; // 1. Export lexicon and/or grammar. model = M3ModelExportServices.ExportGrammarAndLexicon(lp); // 2. Export GAFAWS data. template = M3ModelExportServices.ExportGafaws(lp.PartsOfSpeechOA.PossibilitiesOS); } // PrepareTemplatesForXAmpleFiles adds orderclass elements to MoInflAffixSlot elements m_transformer.PrepareTemplatesForXAmpleFiles(model, template); m_transformer.MakeAmpleFiles(model); int maxAnalCount = 20; XElement maxAnalCountElem = model.Elements("M3Dump").Elements("ParserParameters").Elements("XAmple").Elements("MaxAnalysesToReturn").FirstOrDefault(); if (maxAnalCountElem != null) { maxAnalCount = (int)maxAnalCountElem; if (maxAnalCount < 1) { maxAnalCount = -1; } } m_xample.SetParameter("MaxAnalysesToReturn", maxAnalCount.ToString(CultureInfo.InvariantCulture)); m_xample.LoadFiles(Path.Combine(m_dataDir, "Configuration", "Grammar"), Path.GetTempPath(), m_database); m_forceUpdate = false; } }