private ILexSense MakeSense(ILexEntry owningEntry, string gloss)
        {
            var sense = m_senseFactory.Create();

            owningEntry.SensesOS.Add(sense);
            sense.Gloss.AnalysisDefaultWritingSystem = AnalysisTss(gloss);
            return(sense);
        }
예제 #2
0
        protected ILexSense AddSenseToEntry(List <ICmObject> addList, ILexEntry le, string gloss,
                                            IPartOfSpeech catPoss)
        {
            var msa = new SandboxGenericMSA();

            msa.MainPOS = catPoss;
            var sense = m_senseFact.Create(le, msa, gloss);

            addList.Add(sense);
            return(sense);
        }
        private ILexEntry MakeEntry(string form, string gloss)
        {
            var result = MakeEntryWithForm(form);
            var sense  = m_senseFactory.Create();

            result.SensesOS.Add(sense);
            sense.Gloss.AnalysisDefaultWritingSystem = TsStringUtils.MakeString(
                gloss, Cache.DefaultAnalWs);
            return(result);
        }
예제 #4
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");
            }
        }