Esempio n. 1
0
        private static void CreateAnalysisForWord(string word, ISegment segment, int ws,
                                                  bool fCreateGlosses)
        {
            FdoCache               cache              = segment.Cache;
            IWfiWordformFactory    wfFactory          = cache.ServiceLocator.GetInstance <IWfiWordformFactory>();
            IWfiWordformRepository wfRepo             = cache.ServiceLocator.GetInstance <IWfiWordformRepository>();
            IWfiGlossFactory       glossFactory       = cache.ServiceLocator.GetInstance <IWfiGlossFactory>();
            IWfiAnalysisFactory    wfiAnalysisFactory = cache.ServiceLocator.GetInstance <IWfiAnalysisFactory>();

            ITsString    tssForm = cache.TsStrFactory.MakeString(word, cache.DefaultVernWs);
            IWfiWordform form;
            IAnalysis    analysis;

            if (wfRepo.TryGetObject(tssForm, out form))
            {
                analysis = (fCreateGlosses) ? (IAnalysis)form.AnalysesOC.First().MeaningsOC.First() : form;
            }
            else
            {
                analysis = form = wfFactory.Create(tssForm);
                IWfiAnalysis actualWfiAnalysis = wfiAnalysisFactory.Create();
                form.AnalysesOC.Add(actualWfiAnalysis);
                if (fCreateGlosses)
                {
                    IWfiGloss gloss = glossFactory.Create();
                    actualWfiAnalysis.MeaningsOC.Add(gloss);
                    gloss.Form.set_String(ws, "G" + word + "g");
                    analysis = gloss;
                }
            }
            segment.AnalysesRS.Add(analysis);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParseFiler"/> class.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="taskUpdateHandler">The task update handler.</param>
        /// <param name="idleQueue">The idle queue.</param>
        /// <param name="parserAgent">The parser agent.</param>
        public ParseFiler(FdoCache cache, Action <TaskReport> taskUpdateHandler, IdleQueue idleQueue, ICmAgent parserAgent)
        {
            Debug.Assert(cache != null);
            Debug.Assert(taskUpdateHandler != null);
            Debug.Assert(idleQueue != null);
            Debug.Assert(parserAgent != null);

            m_cache             = cache;
            m_taskUpdateHandler = taskUpdateHandler;
            m_idleQueue         = idleQueue;
            m_parserAgent       = parserAgent;
            m_resultQueue       = new Queue <ParseResult>();
            m_syncRoot          = new object();

            var servLoc = cache.ServiceLocator;

            m_wordformRepository       = servLoc.GetInstance <IWfiWordformRepository>();
            m_analysisFactory          = servLoc.GetInstance <IWfiAnalysisFactory>();
            m_mbFactory                = servLoc.GetInstance <IWfiMorphBundleFactory>();
            m_baseAnnotationRepository = servLoc.GetInstance <ICmBaseAnnotationRepository>();
            m_baseAnnotationFactory    = servLoc.GetInstance <ICmBaseAnnotationFactory>();
            m_moFormRepository         = servLoc.GetInstance <IMoFormRepository>();
            m_msaRepository            = servLoc.GetInstance <IMoMorphSynAnalysisRepository>();
            m_userAgent                = m_cache.LanguageProject.DefaultUserAgent;

            m_analysesWithOldEvaluation = new HashSet <IWfiAnalysis>(
                m_cache.ServiceLocator.GetInstance <IWfiAnalysisRepository>().AllInstances().Where(
                    analysis => analysis.GetAgentOpinion(m_parserAgent) != Opinions.noopinion));
        }
Esempio n. 3
0
        public virtual void Init(Mediator mediator, XmlNode configurationParameters)
        {
            CheckDisposed();

            m_mediator = mediator;
            m_configurationParameters = configurationParameters;
            m_mediator.AddColleague(this);
            m_cache         = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
            m_wordformRepos = m_cache.ServiceLocator.GetInstance <IWfiWordformRepository>();
            m_cache.DomainDataByFlid.AddNotification(this);
            if (IsVernacularSpellingEnabled())
            {
                OnEnableVernacularSpelling();
            }
        }
Esempio n. 4
0
		public virtual void Init(Mediator mediator, XmlNode configurationParameters)
		{
			CheckDisposed();

			m_mediator = mediator;
			m_configurationParameters = configurationParameters;
			m_mediator.AddColleague(this);
			m_cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
			m_wordformRepos = m_cache.ServiceLocator.GetInstance<IWfiWordformRepository>();
			m_cache.DomainDataByFlid.AddNotification(this);
			if (IsVernacularSpellingEnabled())
				OnEnableVernacularSpelling();
		}
Esempio n. 5
0
		private void Init(FdoCache cache)
		{
			m_cache = cache;
			m_paragraphTextScanner = new WordMaker(null, cache.WritingSystemFactory);
			m_wfr = m_cache.ServiceLocator.GetInstance<IWfiWordformRepository>();
			m_wordfactory = m_cache.ServiceLocator.GetInstance<IWfiWordformFactory>();
			m_cbaf = m_cache.ServiceLocator.GetInstance<ICmBaseAnnotationFactory>();
			m_cbar = m_cache.ServiceLocator.GetInstance<ICmBaseAnnotationRepository>();
		}
Esempio n. 6
0
		/// <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>
		protected virtual void Dispose(bool disposing)
		{
			System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				if (RebuildingConcordanceWordforms)
					RebuildingConcordanceWordforms = false;	// don't get rid of m_wfi until we do this.
			}
			m_wordformAnnotationPossibilities = null;
			m_paragraphTextScanner = null;
			m_wordfactory = null;
			m_wfr = null;
			m_cbaf = null;
			m_cbar = null;
			m_wordMaker = null;
			m_tssPara = null;
			m_para = null;
			m_cache = null;

			m_isDisposed = true;
		}