Esempio n. 1
0
        private void LoadParser()
        {
            m_morpher = null;

            int    delReapps      = 0;
            string loadErrorsFile = Path.Combine(m_outputDirectory, m_cache.ProjectId.Name + "HCLoadErrors.xml");

            using (XmlWriter writer = XmlWriter.Create(loadErrorsFile))
                using (new WorkerThreadReadHelper(m_cache.ServiceLocator.GetInstance <IWorkerThreadReadHandler>()))
                {
                    writer.WriteStartElement("LoadErrors");
                    m_language = HCLoader.Load(m_spanFactory, m_cache, new XmlHCLoadErrorLogger(writer));
                    writer.WriteEndElement();
                    XElement parserParamsElem = XElement.Parse(m_cache.LanguageProject.MorphologicalDataOA.ParserParameters);
                    XElement delReappsElem    = parserParamsElem.Elements("ParserParameters").Elements("HC").Elements("DelReapps").FirstOrDefault();
                    if (delReappsElem != null)
                    {
                        delReapps = (int)delReappsElem;
                    }
                }
            m_morpher = new Morpher(m_spanFactory, m_traceManager, m_language)
            {
                DeletionReapplications = delReapps
            };
        }
Esempio n. 2
0
        static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                WriteHelp();
                return(0);
            }

            if (!File.Exists(args[0]))
            {
                Console.WriteLine("The FieldWorks project file could not be found.");
                return(1);
            }

            FwRegistryHelper.Initialize();
            FwUtils.InitializeIcu();
            Sldr.Initialize();
            var synchronizeInvoke = new SingleThreadedSynchronizeInvoke();
            var spanFactory       = new ShapeSpanFactory();

            var projectId = new ProjectIdentifier(args[0]);
            var logger    = new ConsoleLogger(synchronizeInvoke);
            var dirs      = new NullFdoDirectories();
            var settings  = new LcmSettings {
                DisableDataMigration = true
            };
            var progress = new NullThreadedProgress(synchronizeInvoke);

            Console.WriteLine("Loading FieldWorks project...");
            try
            {
                using (LcmCache cache = LcmCache.CreateCacheFromExistingData(projectId, "en", logger, dirs, settings, progress))
                {
                    Language language = HCLoader.Load(spanFactory, cache, logger);
                    Console.WriteLine("Loading completed.");
                    Console.WriteLine("Writing HC configuration file...");
                    XmlLanguageWriter.Save(language, args[1]);
                    Console.WriteLine("Writing completed.");
                }
                return(0);
            }
            catch (LcmFileLockedException)
            {
                Console.WriteLine("Loading failed.");
                Console.WriteLine("The FieldWorks project is currently open in another application.");
                Console.WriteLine("Close the application and try to run this command again.");
                return(1);
            }
            catch (LcmDataMigrationForbiddenException)
            {
                Console.WriteLine("Loading failed.");
                Console.WriteLine("The FieldWorks project was created with an older version of FLEx.");
                Console.WriteLine("Migrate the project to the latest version by opening it in FLEx.");
                return(1);
            }
        }