Exemplo n.º 1
0
        /// <summary>
        /// This patch removes all analyses from the DB that have no annotations from IText,
        /// and that have no human evaluations. Since some analyses can be approved by the parser that
        /// are duplicates (old IText bug), it also includes parser approved analyses.
        /// These will come back the next time the parser is run, if the grammar and lexicon allow such.
        /// </summary>
        protected void RemoveExtraAnalyses()
        {
            int count = 0;

            Console.WriteLine("");
            Console.WriteLine("RemoveExtraAnalyses()...");
            foreach (WfiWordform wf in m_cache.LangProj.WordformInventoryOA.WordformsOC)
            {
                ArrayList anals = new ArrayList();
                foreach (WfiAnalysis anal in wf.AnalysesOC)
                {
                    bool isHumanApproved = false;
                    bool hasAnnotation   = false;
                    foreach (LinkedObjectInfo loi in anal.LinkedObjects)
                    {
                        int relObjClass = loi.RelObjClass;
                        if (relObjClass == CmAnnotation.kclsidCmAnnotation)
                        {
                            hasAnnotation = true;
                            break;
                        }
                        else if (relObjClass == CmAgentEvaluation.kclsidCmAgentEvaluation)
                        {
                            // See if the evaluation is from a human.
                            CmAgentEvaluation eval  = CmAgentEvaluation.CreateFromDBObject(m_cache, loi.RelObjId);
                            CmAgent           agent = CmAgent.CreateFromDBObject(m_cache, eval.OwnerHVO);
                            if (agent.Human)
                            {
                                isHumanApproved = true;
                                break;
                            }
                        }
                    }
                    if (hasAnnotation || isHumanApproved)
                    {
                        continue;
                    }
                    anals.Add(anal);
                }
                if (anals.Count > 0)
                {
                    Console.WriteLine("Deleting {0} analyses from wordform: '{1}'.", anals.Count.ToString(), wf.Form.VernacularDefaultWritingSystem);
                    foreach (WfiAnalysis anal in anals)
                    {
                        ++count;
                        //m_cache.DatabaseAccessor.BeginTrans();
                        Debug.WriteLine(string.Format("Deleting analysis: {0}.", anal.Hvo));
                        anal.DeleteUnderlyingObject();
                        //m_cache.DatabaseAccessor.CommitTrans();
                    }
                }
            }
            Console.WriteLine("Deleted " + count.ToString() + " analyses.");
        }
Exemplo n.º 2
0
		/// <summary>
		/// Create a new ICmAgent instance with the given parameters.
		/// The owner will the the language project (AnalyzingAgents property)
		/// </summary>
		/// <param name="guid">Globally defined guid.</param>
		/// <param name="hvo">Some session unique HVO id.</param>
		/// <param name="isHuman"></param>
		/// <param name="version">Optional bersion information. (May be null.)</param>
		/// <returns></returns>
		ICmAgent ICmAgentFactoryInternal.Create(Guid guid, int hvo, bool isHuman, string version)
		{
			var newAgent = new CmAgent(
				m_cache,
				hvo,
				guid) {Human = isHuman, Version = version};
			return newAgent;
		}