예제 #1
0
        /// <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);
        }
예제 #2
0
        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;
            }
        }