示例#1
0
        private ILexEntryRef AddComponentEntryRef(ILexEntry mainEntry, ILexEntry secondaryEntry)
        {
            Assert.IsNotNull(secondaryEntry.EntryRefsOS,
                             "Entry is not set up correctly.");
            if (secondaryEntry.EntryRefsOS.Count > 0)
            {
                var existingLer = secondaryEntry.EntryRefsOS[0];
                if (mainEntry != null)
                {
                    existingLer.ComponentLexemesRS.Add(mainEntry);
                }
                return(existingLer);
            }
            var newLer = m_lerFact.Create();

            secondaryEntry.EntryRefsOS.Add(newLer);
            if (mainEntry != null)
            {
                newLer.ComponentLexemesRS.Add(mainEntry);
            }
            return(newLer);
        }
        //IPartOfSpeech MakePos(string name)
        //{
        //    if (Cache.LangProject.LexDbOA.ReferencesOA == null)
        //        Cache.LangProject.LexDbOA.ReferencesOA = m_possListFactory.Create();
        //    var result = m_lexRefTypeFactory.Create();
        //    Cache.LangProject.LexDbOA.ReferencesOA.PossibilitiesOS.Add(result);
        //    result.Name.AnalysisDefaultWritingSystem = AnalysisTss(name);
        //    if (reverseName != null)
        //        result.ReverseName.AnalysisDefaultWritingSystem = AnalysisTss(reverseName);
        //    result.MappingType = mapType;
        //    return result;
        //}


        private ILexEntryRef MakeEntryRef(ILexEntry owner, ICmObject[] components, ICmObject[] primaryComponents, int type)
        {
            var result = m_lexEntryRefFactory.Create();

            owner.EntryRefsOS.Add(result);
            result.RefType = type;
            foreach (var obj in components)
            {
                result.ComponentLexemesRS.Add(obj);
            }
            foreach (var obj in primaryComponents)
            {
                result.PrimaryLexemesRS.Add(obj);
            }
            return(result);
        }
示例#3
0
        public void LexEntryInflTypeTwoAnalyses()
        {
            IWfiWordform creb = CheckAnalysisSize("crebTEST", 0, true);
            ILexDb       ldb  = Cache.LanguageProject.LexDbOA;

            ParseResult result = null;

            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler, () =>
            {
                // Verb creb which is a past tense, plural irregularly inflected form of 'believe' and also 'seek'
                // with automatically generated null Tense slot and an automatically generated null Number slot filler
                // (This is not supposed to be English, in case you're wondering....)

                ILexEntryInflType pastTenseLexEntryInflType   = m_lexEntryInflTypeFactory.Create();
                ILexEntryInflType pluralTenseLexEntryInflType = m_lexEntryInflTypeFactory.Create();
                Cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Add(pastTenseLexEntryInflType);
                Cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Add(pluralTenseLexEntryInflType);

                ILexEntry believeV            = m_entryFactory.Create();
                IMoStemAllomorph believeVForm = m_stemAlloFactory.Create();
                believeV.AlternateFormsOS.Add(believeVForm);
                believeVForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("believeVTEST", m_vernacularWS.Handle);
                IMoStemMsa believeVMsa = m_stemMsaFactory.Create();
                believeV.MorphoSyntaxAnalysesOC.Add(believeVMsa);
                ILexSense believeVSense = m_senseFactory.Create();
                believeV.SensesOS.Add(believeVSense);
                believeVSense.MorphoSyntaxAnalysisRA = believeVMsa;

                ILexEntry seekV            = m_entryFactory.Create();
                IMoStemAllomorph seekVForm = m_stemAlloFactory.Create();
                believeV.AlternateFormsOS.Add(seekVForm);
                seekVForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("seekVTEST", m_vernacularWS.Handle);
                IMoStemMsa seekVMsa = m_stemMsaFactory.Create();
                seekV.MorphoSyntaxAnalysesOC.Add(seekVMsa);
                ILexSense seekVSense = m_senseFactory.Create();
                seekV.SensesOS.Add(seekVSense);
                seekVSense.MorphoSyntaxAnalysisRA = seekVMsa;

                ILexEntry crebV            = m_entryFactory.Create();
                IMoStemAllomorph crebVForm = m_stemAlloFactory.Create();
                crebV.AlternateFormsOS.Add(crebVForm);
                crebVForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("crebVTEST", m_vernacularWS.Handle);
                ILexEntryRef lexEntryref = m_lexEntryRefFactory.Create();
                crebV.EntryRefsOS.Add(lexEntryref);
                lexEntryref.ComponentLexemesRS.Add(believeV);
                lexEntryref.VariantEntryTypesRS.Add(pastTenseLexEntryInflType);
                lexEntryref.VariantEntryTypesRS.Add(pluralTenseLexEntryInflType);
                lexEntryref = m_lexEntryRefFactory.Create();
                crebV.EntryRefsOS.Add(lexEntryref);
                lexEntryref.ComponentLexemesRS.Add(seekV);
                lexEntryref.VariantEntryTypesRS.Add(pastTenseLexEntryInflType);
                lexEntryref.VariantEntryTypesRS.Add(pluralTenseLexEntryInflType);

                ILexEntry nullPast             = m_entryFactory.Create();
                IMoAffixAllomorph nullPastForm = m_afxAlloFactory.Create();
                nullPast.AlternateFormsOS.Add(nullPastForm);
                nullPastForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("nullPASTTEST", m_vernacularWS.Handle);
                IMoInflAffMsa nullPastMsa = m_inflAffMsaFactory.Create();
                nullPast.MorphoSyntaxAnalysesOC.Add(nullPastMsa);

                ILexEntry nullPlural             = m_entryFactory.Create();
                IMoAffixAllomorph nullPluralForm = m_afxAlloFactory.Create();
                nullPlural.AlternateFormsOS.Add(nullPluralForm);
                nullPluralForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("nullPLURALTEST", m_vernacularWS.Handle);
                IMoInflAffMsa nullPluralMsa = m_inflAffMsaFactory.Create();
                nullPlural.MorphoSyntaxAnalysesOC.Add(nullPluralMsa);

                result = new ParseResult(new[]
                {
                    new ParseAnalysis(new[]
                    {
                        new ParseMorph(crebVForm, MorphServices.GetMainOrFirstSenseOfVariant(crebV.EntryRefsOS[1]).MorphoSyntaxAnalysisRA,
                                       (ILexEntryInflType)crebV.EntryRefsOS[1].VariantEntryTypesRS[0])
                    }),
                    new ParseAnalysis(new[]
                    {
                        new ParseMorph(crebVForm, MorphServices.GetMainOrFirstSenseOfVariant(crebV.EntryRefsOS[0]).MorphoSyntaxAnalysisRA,
                                       (ILexEntryInflType)crebV.EntryRefsOS[0].VariantEntryTypesRS[0])
                    })
                });
            });

            m_filer.ProcessParse(creb, ParserPriority.Low, result);
            ExecuteIdleQueue();
            CheckAnalysisSize("crebTEST", 2, false);
            foreach (var analysis in creb.AnalysesOC)
            {
                Assert.AreEqual(1, analysis.MorphBundlesOS.Count, "Expected only 1 morph in the analysis");
                var morphBundle = analysis.MorphBundlesOS.ElementAt(0);
                Assert.IsNotNull(morphBundle.Form, "First bundle: form is not null");
                Assert.IsNotNull(morphBundle.MsaRA, "First bundle: msa is not null");
                Assert.IsNotNull(morphBundle.InflTypeRA, "First bundle: infl type is not null");
            }
        }
        public void LexEntryInflTypeTwoAnalyses()
        {
            var crebTEST = CheckAnalysisSize("crebTEST", 0, true);
            var ldb      = Cache.LanguageProject.LexDbOA;

            string xmlFragment = null;

            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler, () =>
            {
                // Verb creb which is a past tense, plural irregularly inflected form of 'believe' and also 'seek'
                // with automatically generated null Tense slot and an automatically generated null Number slot filler
                // (This is not supposed to be English, in case you're wondering....)

                var pastTenseLexEntryInflType   = m_lexEntryInflTypeFactory.Create();
                var pluralTenseLexEntryInflType = m_lexEntryInflTypeFactory.Create();
                Cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Add(pastTenseLexEntryInflType);
                Cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Add(pluralTenseLexEntryInflType);

                var believeV     = m_entryFactory.Create();
                var believeVForm = m_stemAlloFactory.Create();
                believeV.AlternateFormsOS.Add(believeVForm);
                believeVForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("believeVTEST", m_vernacularWS.Handle);
                var believeVMSA = m_stemMsaFactory.Create();
                believeV.MorphoSyntaxAnalysesOC.Add(believeVMSA);
                var believeVSense = m_senseFactory.Create();
                believeV.SensesOS.Add(believeVSense);
                believeVSense.MorphoSyntaxAnalysisRA = believeVMSA;

                var seekV     = m_entryFactory.Create();
                var seekVForm = m_stemAlloFactory.Create();
                believeV.AlternateFormsOS.Add(seekVForm);
                seekVForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("seekVTEST", m_vernacularWS.Handle);
                var seekVMSA = m_stemMsaFactory.Create();
                seekV.MorphoSyntaxAnalysesOC.Add(seekVMSA);
                var seekVSense = m_senseFactory.Create();
                seekV.SensesOS.Add(seekVSense);
                seekVSense.MorphoSyntaxAnalysisRA = seekVMSA;

                var crebV     = m_entryFactory.Create();
                var crebVForm = m_stemAlloFactory.Create();
                crebV.AlternateFormsOS.Add(crebVForm);
                crebVForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("crebVTEST", m_vernacularWS.Handle);
                var lexEntryref = m_lexEntryRefFactory.Create();
                crebV.EntryRefsOS.Add(lexEntryref);
                lexEntryref.ComponentLexemesRS.Add(believeV);
                lexEntryref.VariantEntryTypesRS.Add(pastTenseLexEntryInflType);
                lexEntryref.VariantEntryTypesRS.Add(pluralTenseLexEntryInflType);
                lexEntryref = m_lexEntryRefFactory.Create();
                crebV.EntryRefsOS.Add(lexEntryref);
                lexEntryref.ComponentLexemesRS.Add(seekV);
                lexEntryref.VariantEntryTypesRS.Add(pastTenseLexEntryInflType);
                lexEntryref.VariantEntryTypesRS.Add(pluralTenseLexEntryInflType);

                var nullPAST     = m_entryFactory.Create();
                var nullPASTForm = m_afxAlloFactory.Create();
                nullPAST.AlternateFormsOS.Add(nullPASTForm);
                nullPASTForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("nullPASTTEST", m_vernacularWS.Handle);
                var nullPASTMSA = m_inflAffMsaFactory.Create();
                nullPAST.MorphoSyntaxAnalysesOC.Add(nullPASTMSA);

                var nullPLURAL     = m_entryFactory.Create();
                var nullPLURALForm = m_afxAlloFactory.Create();
                nullPLURAL.AlternateFormsOS.Add(nullPLURALForm);
                nullPLURALForm.Form.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("nullPLURALTEST", m_vernacularWS.Handle);
                var nullPluralMSA = m_inflAffMsaFactory.Create();
                nullPLURAL.MorphoSyntaxAnalysesOC.Add(nullPluralMSA);

                xmlFragment = "<Wordform DbRef='" + crebTEST.Hvo + "' Form='crebTEST'>" + Environment.NewLine
                              + "<WfiAnalysis>" + Environment.NewLine
                              + "<Morphs>" + Environment.NewLine
                              + "<Morph>" + Environment.NewLine
                              + "<MoForm DbRef='" + crebVForm.Hvo + "' Label='crebVTEST'/>" + Environment.NewLine
                              + "<MSI DbRef='" + crebV.Hvo + ".1'/>" + Environment.NewLine
                              + "</Morph>" + Environment.NewLine
                              + "<Morph>" + Environment.NewLine
                              + "<MoForm DbRef='" + pastTenseLexEntryInflType.Hvo + "' Label='TEST'/>" + Environment.NewLine
                              + "<MSI DbRef='" + pastTenseLexEntryInflType.Hvo + "'/>" + Environment.NewLine
                              + "</Morph>" + Environment.NewLine
                              + "<Morph>" + Environment.NewLine
                              + "<MoForm DbRef='" + pluralTenseLexEntryInflType.Hvo + "' Label='TEST'/>" + Environment.NewLine
                              + "<MSI DbRef='" + pluralTenseLexEntryInflType.Hvo + "'/>" + Environment.NewLine
                              + "</Morph>" + Environment.NewLine
                              + "</Morphs>" + Environment.NewLine
                              + "</WfiAnalysis>" + Environment.NewLine
                              + "<WfiAnalysis>" + Environment.NewLine
                              + "<Morphs>" + Environment.NewLine
                              + "<Morph>" + Environment.NewLine
                              + "<MoForm DbRef='" + crebVForm.Hvo + "' Label='crebVTEST'/>" + Environment.NewLine
                              + "<MSI DbRef='" + crebV.Hvo + "'/>" + Environment.NewLine
                              + "</Morph>" + Environment.NewLine
                              + "<Morph>" + Environment.NewLine
                              + "<MoForm DbRef='" + pastTenseLexEntryInflType.Hvo + "' Label='TEST'/>" + Environment.NewLine
                              + "<MSI DbRef='" + pastTenseLexEntryInflType.Hvo + "'/>" + Environment.NewLine
                              + "</Morph>" + Environment.NewLine
                              + "<Morph>" + Environment.NewLine
                              + "<MoForm DbRef='" + pluralTenseLexEntryInflType.Hvo + "' Label='TEST'/>" + Environment.NewLine
                              + "<MSI DbRef='" + pluralTenseLexEntryInflType.Hvo + "'/>" + Environment.NewLine
                              + "</Morph>" + Environment.NewLine
                              + "</Morphs>" + Environment.NewLine
                              + "</WfiAnalysis>" + Environment.NewLine + "</Wordform>" + Environment.NewLine;
            });

            m_filer.ProcessParse(ParserPriority.Low, xmlFragment, 0);
            ExecuteIdleQueue();
            CheckAnalysisSize("crebTEST", 2, false);
            foreach (var analysis in crebTEST.AnalysesOC)
            {
                Assert.AreEqual(1, analysis.MorphBundlesOS.Count, "Expected only 1 morph in the analysis");
                var morphBundle = analysis.MorphBundlesOS.ElementAt(0);
                Assert.IsNotNull(morphBundle.Form, "First bundle: form is not null");
                Assert.IsNotNull(morphBundle.MsaRA, "First bundle: msa is not null");
                Assert.IsNotNull(morphBundle.InflTypeRA, "First bundle: infl type is not null");
            }
        }