예제 #1
0
파일: Worker.cs 프로젝트: sillsdev/WorldPad
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="DummyParser"/> class.
        /// </summary>
        /// -----------------------------------------------------------------------------------
        public ParserWorker(SqlConnection connection, string database, string LangProject, TaskUpdateEventHandler handler,
                            string parserName, string parserVersion)
        {
            Debug.Assert(connection != null && connection.State == System.Data.ConnectionState.Open);

            m_LangProject       = LangProject;
            m_database          = database;
            m_taskUpdateHandler = handler;
            Trace.WriteLineIf(tracingSwitch.TraceInfo, "ParserWorker(): CurrentThreadId = " + Win32.GetCurrentThreadId().ToString());
            // Don't create the XAmpleWrapper yet because we're still on the UI thread.  If we
            // create it now, the apartment thread it uses will be the UI thread, which is not
            // what we want!
            //CreateXAmpleWrapper();
            m_agentInfo.m_isHuman = false;
            m_agentInfo.m_name    = parserName;
            m_agentInfo.m_version = parserVersion;
            m_connection          = connection;
            m_parserFiler         = new ParseFiler(m_connection, AnalyzingAgentId);
            try
            {
                SqlCommand command = m_connection.CreateCommand();
                command.CommandText = "select top 1 Dst\n"
                                      + "from LangProject_CurVernWss\n"
                                      + "order by Ord\n";
                m_vernacularWS = (int)command.ExecuteScalar();
            }
            catch (Exception error)
            {
                throw new ApplicationException("Error while getting the default vernacular writing system.", error);
            }
            m_iNumberOfWordForms = GetWfiSize();
            m_ticksParser        = 0L;
            m_ticksFiler         = 0L;
        }
예제 #2
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="ParserWorker"/> class.
 /// </summary>
 /// -----------------------------------------------------------------------------------
 protected ParserWorker(FdoCache cache, Action <TaskReport> taskUpdateHandler, IdleQueue idleQueue, ICmAgent agent)
 {
     m_cache             = cache;
     m_taskUpdateHandler = taskUpdateHandler;
     m_parseFiler        = new ParseFiler(cache, taskUpdateHandler, idleQueue, agent);
     m_projectName       = cache.ProjectId.Name;
     m_retriever         = new M3ParserModelRetriever(m_cache, m_taskUpdateHandler);
     Trace.WriteLineIf(m_tracingSwitch.TraceInfo, "ParserWorker(): CurrentThreadId = " + Win32.GetCurrentThreadId());
 }
예제 #3
0
        public override void FixtureTeardown()
        {
            m_vernacularWS = null;
            m_filer        = null;
            m_idleQueue.Dispose();
            m_idleQueue               = null;
            m_entryFactory            = null;
            m_senseFactory            = null;
            m_stemAlloFactory         = null;
            m_afxAlloFactory          = null;
            m_stemMsaFactory          = null;
            m_inflAffMsaFactory       = null;
            m_lexEntryRefFactory      = null;
            m_lexEntryInflTypeFactory = null;

            base.FixtureTeardown();
        }
예제 #4
0
 public override void FixtureSetup()
 {
     base.FixtureSetup();
     m_vernacularWS = Cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem;
     m_idleQueue    = new IdleQueue {
         IsPaused = true
     };
     m_filer                   = new ParseFiler(Cache, task => {}, m_idleQueue, Cache.LanguageProject.DefaultParserAgent);
     m_entryFactory            = Cache.ServiceLocator.GetInstance <ILexEntryFactory>();
     m_senseFactory            = Cache.ServiceLocator.GetInstance <ILexSenseFactory>();
     m_stemAlloFactory         = Cache.ServiceLocator.GetInstance <IMoStemAllomorphFactory>();
     m_afxAlloFactory          = Cache.ServiceLocator.GetInstance <IMoAffixAllomorphFactory>();
     m_stemMsaFactory          = Cache.ServiceLocator.GetInstance <IMoStemMsaFactory>();
     m_inflAffMsaFactory       = Cache.ServiceLocator.GetInstance <IMoInflAffMsaFactory>();
     m_lexEntryRefFactory      = Cache.ServiceLocator.GetInstance <ILexEntryRefFactory>();
     m_lexEntryInflTypeFactory = Cache.ServiceLocator.GetInstance <ILexEntryInflTypeFactory>();
 }
예제 #5
0
파일: Worker.cs 프로젝트: sillsdev/WorldPad
        /// <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)
            {
                Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total number of wordforms = " + m_iNumberOfWordForms.ToString());
                Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total time for XAmple parser = " + m_ticksParser.ToString());

                if (m_iNumberOfWordForms != 0)
                {
                    long lAvg = m_ticksParser / m_iNumberOfWordForms;
                    Trace.WriteLineIf(tracingSwitch.TraceInfo, "Average time for XAmple parser = " + lAvg.ToString());
                }

                Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total time for parser filer = " + m_ticksFiler);

                if (m_iNumberOfWordForms != 0)
                {
                    long lAvg = m_ticksFiler / m_iNumberOfWordForms;
                    Trace.WriteLineIf(tracingSwitch.TraceInfo, "Average time for parser filer = " + lAvg.ToString());
                }

                // Dispose managed resources here.
                if (m_parserFiler != null)
                {
                    m_parserFiler.Dispose();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_taskUpdateHandler = null;
            m_parserFiler       = null;
            m_connection        = null;      // Client needs to close and Dispose the connection, since it gave it to us.
            CleanupParser();
            m_LangProject = null;
            m_database    = null;
            m_isDisposed  = true;
        }
예제 #6
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="ParserWorker"/> class.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		public ParserWorker(FdoCache cache, Action<TaskReport> taskUpdateHandler, IdleQueue idleQueue, string dataDir)
		{
			m_cache = cache;
			m_taskUpdateHandler = taskUpdateHandler;
			ICmAgent agent;
			switch (m_cache.LanguageProject.MorphologicalDataOA.ActiveParser)
			{
				case "XAmple":
					m_parser = new XAmpleParser(cache, dataDir);
					agent = cache.ServiceLocator.GetInstance<ICmAgentRepository>().GetObject(CmAgentTags.kguidAgentXAmpleParser);
					break;
				case "HC":
					m_parser = new HCParser(cache, dataDir);
					agent = cache.ServiceLocator.GetInstance<ICmAgentRepository>().GetObject(CmAgentTags.kguidAgentHermitCrabParser);
					break;
				default:
					throw new InvalidOperationException("The language project is set to use an unrecognized parser.");
			}
			m_parseFiler = new ParseFiler(cache, taskUpdateHandler, idleQueue, agent);
		}
예제 #7
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ParserWorker"/> class.
        /// </summary>
        /// -----------------------------------------------------------------------------------
        public ParserWorker(FdoCache cache, Action <TaskReport> taskUpdateHandler, IdleQueue idleQueue, string dataDir)
        {
            m_cache             = cache;
            m_taskUpdateHandler = taskUpdateHandler;
            ICmAgent agent;

            switch (m_cache.LanguageProject.MorphologicalDataOA.ActiveParser)
            {
            case "XAmple":
                m_parser = new XAmpleParser(cache, dataDir);
                agent    = cache.ServiceLocator.GetInstance <ICmAgentRepository>().GetObject(CmAgentTags.kguidAgentXAmpleParser);
                break;

            case "HC":
                m_parser = new HCParser(cache);
                agent    = cache.ServiceLocator.GetInstance <ICmAgentRepository>().GetObject(CmAgentTags.kguidAgentHermitCrabParser);
                break;

            default:
                throw new InvalidOperationException("The language project is set to use an unrecognized parser.");
            }
            m_parseFiler = new ParseFiler(cache, taskUpdateHandler, idleQueue, agent);
        }
예제 #8
0
파일: Worker.cs 프로젝트: sillsdev/WorldPad
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="DummyParser"/> class.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		public ParserWorker(SqlConnection connection, string database, string LangProject, TaskUpdateEventHandler handler,
			string parserName, string parserVersion)
		{
			Debug.Assert(connection != null && connection.State == System.Data.ConnectionState.Open);

			m_LangProject = LangProject;
			m_database = database;
			m_taskUpdateHandler = handler;
			Trace.WriteLineIf(tracingSwitch.TraceInfo, "ParserWorker(): CurrentThreadId = " + Win32.GetCurrentThreadId().ToString());
			// Don't create the XAmpleWrapper yet because we're still on the UI thread.  If we
			// create it now, the apartment thread it uses will be the UI thread, which is not
			// what we want!
			//CreateXAmpleWrapper();
			m_agentInfo.m_isHuman = false;
			m_agentInfo.m_name = parserName;
			m_agentInfo.m_version = parserVersion;
			m_connection = connection;
			m_parserFiler = new ParseFiler(m_connection, AnalyzingAgentId);
			try
			{
				SqlCommand command = m_connection.CreateCommand();
				command.CommandText = "select top 1 Dst\n"
					+ "from LangProject_CurVernWss\n"
					+ "order by Ord\n";
				m_vernacularWS = (int)command.ExecuteScalar();
			}
			catch (Exception error)
			{
				throw new ApplicationException("Error while getting the default vernacular writing system.", error);
			}
			m_iNumberOfWordForms = GetWfiSize();
			m_ticksParser = 0L;
			m_ticksFiler = 0L;
		}
예제 #9
0
파일: Worker.cs 프로젝트: sillsdev/WorldPad
		/// <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)
			{
				Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total number of wordforms = " + m_iNumberOfWordForms.ToString());
				Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total time for XAmple parser = " + m_ticksParser.ToString());

				if (m_iNumberOfWordForms != 0)
				{
					long lAvg = m_ticksParser/m_iNumberOfWordForms;
					Trace.WriteLineIf(tracingSwitch.TraceInfo, "Average time for XAmple parser = " + lAvg.ToString());
				}

				Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total time for parser filer = " + m_ticksFiler);

				if (m_iNumberOfWordForms != 0)
				{
					long lAvg = m_ticksFiler/m_iNumberOfWordForms;
					Trace.WriteLineIf(tracingSwitch.TraceInfo, "Average time for parser filer = " + lAvg.ToString());
				}

				// Dispose managed resources here.
				if (m_parserFiler != null)
					m_parserFiler.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_taskUpdateHandler = null;
			m_parserFiler = null;
			m_connection = null; // Client needs to close and Dispose the connection, since it gave it to us.
			CleanupParser();
			m_LangProject = null;
			m_database = null;
			m_isDisposed = true;
		}
		public override void FixtureTeardown()
		{
			m_vernacularWS = null;
			m_filer = null;
			m_idleQueue.Dispose();
			m_idleQueue = null;
			m_entryFactory = null;
			m_senseFactory = null;
			m_stemAlloFactory = null;
			m_afxAlloFactory = null;
			m_stemMsaFactory = null;
			m_inflAffMsaFactory = null;
			m_lexEntryRefFactory = null;
			m_lexEntryInflTypeFactory = null;

			base.FixtureTeardown();
		}
		public override void FixtureSetup()
		{
			base.FixtureSetup();
			m_vernacularWS = Cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem;
			m_idleQueue = new IdleQueue {IsPaused = true};
			m_filer = new ParseFiler(Cache, task => {}, m_idleQueue, Cache.LanguageProject.DefaultParserAgent);
			m_entryFactory = Cache.ServiceLocator.GetInstance<ILexEntryFactory>();
			m_senseFactory = Cache.ServiceLocator.GetInstance<ILexSenseFactory>();
			m_stemAlloFactory = Cache.ServiceLocator.GetInstance<IMoStemAllomorphFactory>();
			m_afxAlloFactory = Cache.ServiceLocator.GetInstance<IMoAffixAllomorphFactory>();
			m_stemMsaFactory = Cache.ServiceLocator.GetInstance<IMoStemMsaFactory>();
			m_inflAffMsaFactory = Cache.ServiceLocator.GetInstance<IMoInflAffMsaFactory>();
			m_lexEntryRefFactory = Cache.ServiceLocator.GetInstance<ILexEntryRefFactory>();
			m_lexEntryInflTypeFactory = Cache.ServiceLocator.GetInstance<ILexEntryInflTypeFactory>();
		}
예제 #12
0
		protected void SetUp()
		{
			string server = Environment.MachineName + "\\SILFW";
			string database = "TestLangProj";

			string cnxString = "Server=" + server
				+ "; Database=" + database
				+ "; User ID=FWDeveloper;"
				+ "Password=careful; Pooling=false;";
			m_connection = new SqlConnection(cnxString);
			m_connection.Open();
			SqlCommand command = m_connection.CreateCommand();
			command.CommandText = "select top 1 Dst "
				+ "from LangProject_CurVernWss "
				+ "order by Ord";
			m_vernacularWS = (int)command.ExecuteScalar();
			command = m_connection.CreateCommand();
			command.CommandText = "select top 1 Id "
				+ "from WordformInventory";
			m_wfiID = (int)command.ExecuteScalar();
			m_filer = new ParseFiler(m_connection, AnalyzingAgentId);
		}