示例#1
0
		public void CliticVsStemMsaWithoutCategory()
		{
			CheckDisposed();

			LexEntry entry = new LexEntry();
			Cache.LangProject.LexDbOA.EntriesOC.Add(entry);
			MoStemAllomorph allomorph = new MoStemAllomorph();
			entry.LexemeFormOA = allomorph;
			MoStemMsa msa = new MoStemMsa();
			entry.MorphoSyntaxAnalysesOC.Add(msa);
			SetMorphType(allomorph, MoMorphType.kguidMorphClitic);
			Assert.AreEqual("Clitic of unknown category", msa.LongNameTs.Text);
			MoStemAllomorph allo2 = new MoStemAllomorph();
			entry.AlternateFormsOS.Append(allo2);
			SetMorphType(allomorph, MoMorphType.kguidMorphStem);
			Assert.AreEqual("Stem/root of unknown category; takes any affix", msa.LongNameTs.Text);
		}
示例#2
0
		public void FromPartsOfSpeechIsRelevant()
		{
			CheckDisposed();

			LexEntry entry = new LexEntry();
			Cache.LangProject.LexDbOA.EntriesOC.Add(entry);
			MoStemAllomorph allomorph = new MoStemAllomorph();
			entry.AlternateFormsOS.Append(allomorph);
			MoStemMsa msa = new MoStemMsa();
			entry.MorphoSyntaxAnalysesOC.Add(msa);
			SetMorphType(allomorph, MoMorphType.kguidMorphStem);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphProclitic);
			Assert.IsTrue(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should now be relevant since the entry has a proclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphEnclitic);
			Assert.IsTrue(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should now be relevant since the entry has an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphClitic);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphBoundRoot);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphBoundStem);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphCircumfix);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphDiscontiguousPhrase);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphInfix);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphInfixingInterfix);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphParticle);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphPhrase);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphPrefix);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphPrefixingInterfix);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphRoot);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphSimulfix);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphSuffix);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphSuffixingInterfix);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");
			SetMorphType(allomorph, MoMorphType.kguidMorphSuprafix);
			Assert.IsFalse(msa.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidFromPartsOfSpeech),
				"FromPartsOfSpeech should not be relevant until the entry contains a proclitic or an enclitic.");

		}
示例#3
0
		public void MoDerivAffMsa_EqualMsa()
		{
			CheckDisposed();

			CreateTestData();

			ILangProject lp = Cache.LangProject;
			ILexDb ld = lp.LexDbOA;
			ILexEntry le = MakeLexEntry(ld, "xyzTest1", "xyzDefn1.1", 0);

			MoDerivAffMsa derivAffixMsa1 = new MoDerivAffMsa();
			MoDerivAffMsa derivAffixMsa2 = new MoDerivAffMsa();
			MoStemMsa stemMsa = new MoStemMsa();
			MoInflAffMsa inflAffixMsa = new MoInflAffMsa();
			MoUnclassifiedAffixMsa unclassifiedAffixMsa = new MoUnclassifiedAffixMsa();

			le.MorphoSyntaxAnalysesOC.Add(derivAffixMsa1);
			le.MorphoSyntaxAnalysesOC.Add(derivAffixMsa2);
			le.MorphoSyntaxAnalysesOC.Add(stemMsa);
			le.MorphoSyntaxAnalysesOC.Add(inflAffixMsa);
			le.MorphoSyntaxAnalysesOC.Add(unclassifiedAffixMsa);

			DummyGenericMSA dummyMsa1 = DummyGenericMSA.Create(derivAffixMsa1);
			DummyGenericMSA dummyMsa2 = DummyGenericMSA.Create(derivAffixMsa2);
			DummyGenericMSA dummyMsa3 = DummyGenericMSA.Create(stemMsa);
			DummyGenericMSA dummyMsa4 = DummyGenericMSA.Create(inflAffixMsa);
			DummyGenericMSA dummyMsa5 = DummyGenericMSA.Create(unclassifiedAffixMsa);

			// Verify we fail comparing on different MSA types.
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(stemMsa));
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(inflAffixMsa));
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(unclassifiedAffixMsa));
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(dummyMsa3));
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(dummyMsa4));
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(dummyMsa5));

			// Verify that derivAffixMsa1 equals itself.
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa1), derivAffixMsa1.ToString() + " - should equal itself.");

			// Verify that derivAffixMsa1 equals derivAffixMsa2
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa2), derivAffixMsa1.ToString() + " - should equal - " + derivAffixMsa2.ToString());
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(dummyMsa2), "derivAffixMsa1 should equal dummyMsa2");

			// compare with on different FromPartOfSpeech
			FdoOwningSequence<ICmPossibility> posSeq = lp.PartsOfSpeechOA.PossibilitiesOS;
			IPartOfSpeech pos1 = (IPartOfSpeech)posSeq.Append(new PartOfSpeech());
			IPartOfSpeech pos2 = (IPartOfSpeech)posSeq.Append(new PartOfSpeech());
			derivAffixMsa1.FromPartOfSpeechRA = pos1;
			derivAffixMsa2.FromPartOfSpeechRA = pos2;
			dummyMsa2.MainPOS = pos2.Hvo;
			Assert.IsTrue(derivAffixMsa1.FromPartOfSpeechRA != derivAffixMsa2.FromPartOfSpeechRA, "msa POSes should not be equal.");
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to different FromPartOfSpeech");
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(dummyMsa2), "derivAffixMsa1 should not equal dummyMsa2");

			// reset POS
			derivAffixMsa1.FromPartOfSpeechRAHvo = derivAffixMsa2.FromPartOfSpeechRAHvo;
			dummyMsa2.MainPOS = derivAffixMsa1.FromPartOfSpeechRAHvo;
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 & derivAffixMsa2 should be equal with matching POS");
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(dummyMsa2), "derivAffixMsa1 should equal dummyMsa2");

			// compare with on different ToPartOfSpeech
			PartOfSpeech pos3 = (PartOfSpeech)posSeq.Append(new PartOfSpeech());
			PartOfSpeech pos4 = (PartOfSpeech)posSeq.Append(new PartOfSpeech());
			derivAffixMsa1.ToPartOfSpeechRA = pos3;
			derivAffixMsa2.ToPartOfSpeechRA = pos4;
			dummyMsa2.SecondaryPOS = pos4.Hvo;
			Assert.IsTrue(derivAffixMsa1.ToPartOfSpeechRA != derivAffixMsa2.ToPartOfSpeechRA, "msa POSes should not be equal.");
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to different ToPartOfSpeech");
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(dummyMsa2), "derivAffixMsa1 should not equal dummyMsa2");

			// reset POS
			derivAffixMsa1.ToPartOfSpeechRAHvo = derivAffixMsa2.ToPartOfSpeechRAHvo;
			dummyMsa2.SecondaryPOS = derivAffixMsa1.ToPartOfSpeechRAHvo;
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 & derivAffixMsa2 should be equal with matching POS");
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(dummyMsa2), "derivAffixMsa1 should equal dummyMsa2");

			// compare on different FromInflectionClass
			pos1.InflectionClassesOC.Add(new MoInflClass());
			pos2.InflectionClassesOC.Add(new MoInflClass());
			derivAffixMsa1.FromInflectionClassRAHvo = pos1.InflectionClassesOC.HvoArray[0];
			derivAffixMsa2.FromInflectionClassRAHvo = pos2.InflectionClassesOC.HvoArray[0];
			Assert.IsTrue(derivAffixMsa1.FromInflectionClassRA != derivAffixMsa2.FromInflectionClassRA, "inflection classes should not be equal.");
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to different inflection classes.");

			// reset InflectionClass
			derivAffixMsa1.FromInflectionClassRA = derivAffixMsa2.FromInflectionClassRA;
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 & derivAffixMsa2 should be equal with matching inflection classes");

			// compare on different FromStemName
			pos1.StemNamesOC.Add(new MoStemName());
			pos2.StemNamesOC.Add(new MoStemName());
			derivAffixMsa1.FromStemNameRAHvo = pos1.StemNamesOC.HvoArray[0];
			derivAffixMsa2.FromStemNameRAHvo = pos2.StemNamesOC.HvoArray[0];
			Assert.IsTrue(derivAffixMsa1.FromStemNameRA != derivAffixMsa2.FromStemNameRA, "stem names should not be equal.");
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to different stem names.");

			// reset StemName
			derivAffixMsa1.FromStemNameRA = derivAffixMsa2.FromStemNameRA;
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 & derivAffixMsa2 should be equal with matching stem names");

			// compare on different ToInflectionClass
			pos3.InflectionClassesOC.Add(new MoInflClass());
			pos4.InflectionClassesOC.Add(new MoInflClass());
			derivAffixMsa1.ToInflectionClassRAHvo = pos3.InflectionClassesOC.HvoArray[0];
			derivAffixMsa2.ToInflectionClassRAHvo = pos4.InflectionClassesOC.HvoArray[0];
			Assert.IsTrue(derivAffixMsa1.ToInflectionClassRA != derivAffixMsa2.ToInflectionClassRA, "inflection classes should not be equal.");
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to different inflection classes.");

			// reset InflectionClass
			derivAffixMsa1.ToInflectionClassRA = derivAffixMsa2.ToInflectionClassRA;
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 & derivAffixMsa2 should be equal with matching inflection classes");

			// compare different FromProdRestrict
			ICmPossibility pr1 = lp.MorphologicalDataOA.ProdRestrictOA.PossibilitiesOS[0];
			ICmPossibility pr2 = lp.MorphologicalDataOA.ProdRestrictOA.PossibilitiesOS[1];

			derivAffixMsa1.FromProdRestrictRC.Add(pr1.Hvo);
			derivAffixMsa2.FromProdRestrictRC.Add(pr2.Hvo);
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to productivity restrictions differences.");

			derivAffixMsa1.FromProdRestrictRC.Add(pr2.Hvo);
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to productivity restrictions count difference.");

			// Match Productivity Restrictions
			derivAffixMsa2.FromProdRestrictRC.Add(pr1.Hvo);
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 & derivAffixMsa2 should be equal with matching productivity restrictions");

			// compare different ToProdRestrict
			CmPossibility pr3 = lp.MorphologicalDataOA.ProdRestrictOA.PossibilitiesOS[2] as CmPossibility;
			CmPossibility pr4 = lp.MorphologicalDataOA.ProdRestrictOA.PossibilitiesOS[3] as CmPossibility;

			derivAffixMsa1.ToProdRestrictRC.Add(pr3.Hvo);
			derivAffixMsa2.ToProdRestrictRC.Add(pr4.Hvo);
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to productivity restrictions differences.");

			derivAffixMsa1.ToProdRestrictRC.Add(pr4.Hvo);
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to productivity restrictions count difference.");

			// Match Productivity Restrictions
			derivAffixMsa2.ToProdRestrictRC.Add(pr3.Hvo);
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 & derivAffixMsa2 should be equal with matching productivity restrictions");

			// compare different FromMsFeatures
			XmlDocument doc = new XmlDocument();
			doc.LoadXml(m_ksFS1);
			XmlNode itemNeut = doc.SelectSingleNode("/item/item[3]");
			XmlNode itemFem = doc.SelectSingleNode("/item/item[2]");
			derivAffixMsa1.FromMsFeaturesOA = new FsFeatStruc();
			derivAffixMsa2.FromMsFeaturesOA = new FsFeatStruc();
			derivAffixMsa1.FromMsFeaturesOA.AddFeatureFromXml(Cache, itemNeut);
			derivAffixMsa2.FromMsFeaturesOA.AddFeatureFromXml(Cache, itemFem);

			Assert.IsFalse(derivAffixMsa1.FromMsFeaturesOA.IsEquivalent(derivAffixMsa2.FromMsFeaturesOA), "FromMsFeaturesOA should not be equal.");
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to different FromMsFeaturesOA.");

			// match feature structures
			derivAffixMsa1.FromMsFeaturesOA.AddFeatureFromXml(Cache, itemFem);
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 & derivAffixMsa2 should be equal with matching feature structure");

			// compare different ToMsFeatures
			derivAffixMsa1.ToMsFeaturesOA = new FsFeatStruc();
			derivAffixMsa2.ToMsFeaturesOA = new FsFeatStruc();
			derivAffixMsa1.ToMsFeaturesOA.AddFeatureFromXml(Cache, itemFem);
			derivAffixMsa2.ToMsFeaturesOA.AddFeatureFromXml(Cache, itemNeut);

			Assert.IsFalse(derivAffixMsa1.ToMsFeaturesOA.IsEquivalent(derivAffixMsa2.ToMsFeaturesOA), "ToMsFeaturesOA should not be equal.");
			Assert.IsFalse(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 should not be equal to derivAffixMsa2 due to different ToMsFeaturesOA.");

			// match feature structures
			derivAffixMsa1.ToMsFeaturesOA.AddFeatureFromXml(Cache, itemNeut);
			Assert.IsTrue(derivAffixMsa1.EqualsMsa(derivAffixMsa2), "derivAffixMsa1 & derivAffixMsa2 should be equal with matching feature structure");
		}
示例#4
0
		public void MoUnclassifiedAffixMsa_EqualMsa()
		{
			CheckDisposed();

			ILangProject lp = Cache.LangProject;
			ILexDb ld = lp.LexDbOA;
			ILexEntry le = MakeLexEntry(ld, "xyzTest1", "xyzDefn1.1", 0);

			MoUnclassifiedAffixMsa unclassifiedAffixMsa1 = new MoUnclassifiedAffixMsa();
			MoUnclassifiedAffixMsa unclassifiedAffixMsa2 = new MoUnclassifiedAffixMsa();
			MoStemMsa stemMsa = new MoStemMsa();
			MoInflAffMsa inflAffixMsa = new MoInflAffMsa();
			MoDerivAffMsa derivAffixMsa = new MoDerivAffMsa();

			le.MorphoSyntaxAnalysesOC.Add(unclassifiedAffixMsa1);
			le.MorphoSyntaxAnalysesOC.Add(unclassifiedAffixMsa2);
			le.MorphoSyntaxAnalysesOC.Add(stemMsa);
			le.MorphoSyntaxAnalysesOC.Add(inflAffixMsa);
			le.MorphoSyntaxAnalysesOC.Add(derivAffixMsa);

			DummyGenericMSA dummyMsa1 = DummyGenericMSA.Create(unclassifiedAffixMsa1);
			DummyGenericMSA dummyMsa2 = DummyGenericMSA.Create(unclassifiedAffixMsa2);
			DummyGenericMSA dummyMsa3 = DummyGenericMSA.Create(stemMsa);
			DummyGenericMSA dummyMsa4 = DummyGenericMSA.Create(inflAffixMsa);
			DummyGenericMSA dummyMsa5 = DummyGenericMSA.Create(derivAffixMsa);

			// Verify we fail comparing on different MSA types.
			Assert.IsFalse(unclassifiedAffixMsa1.EqualsMsa(stemMsa));
			Assert.IsFalse(unclassifiedAffixMsa1.EqualsMsa(inflAffixMsa));
			Assert.IsFalse(unclassifiedAffixMsa1.EqualsMsa(derivAffixMsa));
			Assert.IsFalse(unclassifiedAffixMsa1.EqualsMsa(dummyMsa3));
			Assert.IsFalse(unclassifiedAffixMsa1.EqualsMsa(dummyMsa4));
			Assert.IsFalse(unclassifiedAffixMsa1.EqualsMsa(dummyMsa5));

			// Verify that unclassifiedAffixMsa1 equals itself.
			Assert.IsTrue(unclassifiedAffixMsa1.EqualsMsa(unclassifiedAffixMsa1), unclassifiedAffixMsa1.ToString() + " - should equal itself.");

			// Verify that unclassifiedAffixMsa1 equals unclassifiedAffixMsa2
			Assert.IsTrue(unclassifiedAffixMsa1.EqualsMsa(unclassifiedAffixMsa2), unclassifiedAffixMsa1.ToString() + " - should equal - " + unclassifiedAffixMsa2.ToString());
			Assert.IsTrue(unclassifiedAffixMsa1.EqualsMsa(dummyMsa2), "unclassifiedAffixMsa1 should equal dummyMsa2");

			// compare with on different PartOfSpeech
			FdoOwningSequence<ICmPossibility> posSeq = lp.PartsOfSpeechOA.PossibilitiesOS;
			IPartOfSpeech pos1 = (IPartOfSpeech)posSeq.Append(new PartOfSpeech());
			IPartOfSpeech pos2 = (IPartOfSpeech)posSeq.Append(new PartOfSpeech());

			unclassifiedAffixMsa1.PartOfSpeechRA = pos1;
			unclassifiedAffixMsa2.PartOfSpeechRA = pos2;
			dummyMsa2.MainPOS = pos2.Hvo;
			Assert.IsTrue(unclassifiedAffixMsa1.PartOfSpeechRA != unclassifiedAffixMsa2.PartOfSpeechRA, "msa POSes should not be equal.");
			Assert.IsFalse(unclassifiedAffixMsa1.EqualsMsa(unclassifiedAffixMsa2), "unclassifiedAffixMsa1 should not be equal to unclassifiedAffixMsa2 due to different POS");
			Assert.IsFalse(unclassifiedAffixMsa1.EqualsMsa(dummyMsa2), "unclassifiedAffixMsa1 should not equal dummyMsa2");

			// reset POS
			unclassifiedAffixMsa1.PartOfSpeechRAHvo = unclassifiedAffixMsa2.PartOfSpeechRAHvo;
			dummyMsa2.MainPOS = unclassifiedAffixMsa1.PartOfSpeechRAHvo;
			Assert.IsTrue(unclassifiedAffixMsa1.EqualsMsa(unclassifiedAffixMsa2), "unclassifiedAffixMsa1 & unclassifiedAffixMsa2 should be equal with matching POS");
			Assert.IsTrue(unclassifiedAffixMsa1.EqualsMsa(dummyMsa2), "unclassifiedAffixMsa1 should equal dummyMsa2");
		}
示例#5
0
		// TODO RandyR: Add ShortNameTSS and DeletionTextTSS. (DeleteUnderlyingObject() is not meeded.)

		/// <summary>
		/// Create other required elements.
		/// </summary>
		public override void InitNewInternal()
		{
			base.InitNewInternal();
			LeftMsaOA = new MoStemMsa();
			RightMsaOA = new MoStemMsa();
		}
示例#6
0
		public void MoInflAffMsa_EqualMsa()
		{
			CheckDisposed();

			CreateTestData();

			ILangProject lp = Cache.LangProject;
			ILexDb ld = lp.LexDbOA;
			ILexEntry le = MakeLexEntry(ld, "xyzTest1", "xyzDefn1.1", 0);

			MoInflAffMsa infAffixMsa1 = new MoInflAffMsa();
			MoInflAffMsa infAffixMsa2 = new MoInflAffMsa();
			MoStemMsa stemMsa = new MoStemMsa();
			MoDerivAffMsa derivAffixMsa = new MoDerivAffMsa();
			MoUnclassifiedAffixMsa unclassifiedAffixMsa = new MoUnclassifiedAffixMsa();

			le.MorphoSyntaxAnalysesOC.Add(infAffixMsa1);
			le.MorphoSyntaxAnalysesOC.Add(infAffixMsa2);
			le.MorphoSyntaxAnalysesOC.Add(stemMsa);
			le.MorphoSyntaxAnalysesOC.Add(derivAffixMsa);
			le.MorphoSyntaxAnalysesOC.Add(unclassifiedAffixMsa);

			DummyGenericMSA dummyMsa1 = DummyGenericMSA.Create(infAffixMsa1);
			DummyGenericMSA dummyMsa2 = DummyGenericMSA.Create(infAffixMsa2);
			DummyGenericMSA dummyMsa3 = DummyGenericMSA.Create(stemMsa);
			DummyGenericMSA dummyMsa4 = DummyGenericMSA.Create(derivAffixMsa);
			DummyGenericMSA dummyMsa5 = DummyGenericMSA.Create(unclassifiedAffixMsa);

			// Verify we fail comparing on different MSA types.
			Assert.IsFalse(infAffixMsa1.EqualsMsa(stemMsa));
			Assert.IsFalse(infAffixMsa1.EqualsMsa(derivAffixMsa));
			Assert.IsFalse(infAffixMsa1.EqualsMsa(unclassifiedAffixMsa));
			Assert.IsFalse(infAffixMsa1.EqualsMsa(dummyMsa3));
			Assert.IsFalse(infAffixMsa1.EqualsMsa(dummyMsa4));
			Assert.IsFalse(infAffixMsa1.EqualsMsa(dummyMsa5));

			// Verify that infAffixMsa1 equals itself.
			Assert.IsTrue(infAffixMsa1.EqualsMsa(infAffixMsa1), infAffixMsa1.ToString() + " - should equal itself.");

			// Verify that infAffixMsa1 equals infAffixMsa2
			Assert.IsTrue(infAffixMsa1.EqualsMsa(infAffixMsa2), infAffixMsa1.ToString() + " - should equal - " + infAffixMsa2.ToString());
			Assert.IsTrue(infAffixMsa1.EqualsMsa(dummyMsa2), "infAffixMsa1 should equal dummyMsa2");

			// compare with on different PartOfSpeech
			FdoOwningSequence<ICmPossibility> posSeq = lp.PartsOfSpeechOA.PossibilitiesOS;
			IPartOfSpeech pos1 = (IPartOfSpeech)posSeq.Append(new PartOfSpeech());
			IPartOfSpeech pos2 = (IPartOfSpeech)posSeq.Append(new PartOfSpeech());

			infAffixMsa1.PartOfSpeechRA = pos1;
			infAffixMsa2.PartOfSpeechRA = pos2;
			dummyMsa2.MainPOS = pos2.Hvo;
			Assert.IsTrue(infAffixMsa1.PartOfSpeechRA != infAffixMsa2.PartOfSpeechRA, "msa POSes should not be equal.");
			Assert.IsFalse(infAffixMsa1.EqualsMsa(infAffixMsa2), "infAffixMsa1 should not be equal to infAffixMsa2 due to different POS");
			Assert.IsFalse(infAffixMsa1.EqualsMsa(dummyMsa2), "infAffixMsa1 should not equal dummyMsa2");

			// reset POS
			infAffixMsa1.PartOfSpeechRAHvo = infAffixMsa2.PartOfSpeechRAHvo;
			dummyMsa2.MainPOS = infAffixMsa1.PartOfSpeechRAHvo;
			Assert.IsTrue(infAffixMsa1.EqualsMsa(infAffixMsa2), "infAffixMsa1 & infAffixMsa2 should be equal with matching POS");
			Assert.IsTrue(infAffixMsa1.EqualsMsa(dummyMsa2), "infAffixMsa1 should equal dummyMsa2");

			// skip AffixCategory

			// compare different Slots
			pos1.AffixSlotsOC.Add(new MoInflAffixSlot());
			pos1.AffixSlotsOC.Add(new MoInflAffixSlot());

			infAffixMsa1.SlotsRC.Add(pos1.AffixSlotsOC.HvoArray[0]);
			infAffixMsa2.SlotsRC.Add(pos1.AffixSlotsOC.HvoArray[1]);
			dummyMsa2.Slot = pos1.AffixSlotsOC.HvoArray[1];
			Assert.IsFalse(infAffixMsa1.EqualsMsa(infAffixMsa2), "infAffixMsa1 should not be equal to infAffixMsa2 due to affix slots differences.");
			Assert.IsFalse(infAffixMsa1.EqualsMsa(dummyMsa2), "infAffixMsa1 should not equal dummyMsa2");

			infAffixMsa1.SlotsRC.Add(pos1.AffixSlotsOC.HvoArray[1]);
			Assert.IsTrue(infAffixMsa1.SlotsRC.Count != infAffixMsa2.SlotsRC.Count);
			Assert.IsFalse(infAffixMsa1.EqualsMsa(infAffixMsa2), "infAffixMsa1 should not be equal to infAffixMsa2 due to affix slots Count differences.");
			Assert.IsFalse(infAffixMsa1.EqualsMsa(dummyMsa2), "infAffixMsa1 should not equal dummyMsa2");

			infAffixMsa2.SlotsRC.Add(pos1.AffixSlotsOC.HvoArray[0]);
			Assert.IsTrue(infAffixMsa1.EqualsMsa(infAffixMsa2), "infAffixMsa1 should equal infAffixMsa2 due to affix slots matching.");

			// compare different FromProdRestrict
			ICmPossibility pr1 = lp.MorphologicalDataOA.ProdRestrictOA.PossibilitiesOS[0];
			ICmPossibility pr2 = lp.MorphologicalDataOA.ProdRestrictOA.PossibilitiesOS[1];

			infAffixMsa1.FromProdRestrictRC.Add(pr1.Hvo);
			infAffixMsa2.FromProdRestrictRC.Add(pr2.Hvo);
			Assert.IsFalse(infAffixMsa1.EqualsMsa(infAffixMsa2), "infAffixMsa1 should not be equal to infAffixMsa2 due to productivity restrictions differences.");

			infAffixMsa1.FromProdRestrictRC.Add(pr2.Hvo);
			Assert.IsFalse(infAffixMsa1.EqualsMsa(infAffixMsa2), "infAffixMsa1 should not be equal to infAffixMsa2 due to productivity restrictions count difference.");

			// Match Productivity Restrictions
			infAffixMsa2.FromProdRestrictRC.Add(pr1.Hvo);
			Assert.IsTrue(infAffixMsa1.EqualsMsa(infAffixMsa2), "infAffixMsa1 & infAffixMsa2 should be equal with matching productivity restrictions");

			// compare different InflFeats
			XmlDocument doc = new XmlDocument();
			doc.LoadXml(m_ksFS1);
			XmlNode itemNeut = doc.SelectSingleNode("/item/item[3]");
			XmlNode itemFem = doc.SelectSingleNode("/item/item[2]");
			infAffixMsa1.InflFeatsOA = new FsFeatStruc();
			infAffixMsa2.InflFeatsOA = new FsFeatStruc();
			infAffixMsa1.InflFeatsOA.AddFeatureFromXml(Cache, itemNeut);
			infAffixMsa2.InflFeatsOA.AddFeatureFromXml(Cache, itemFem);

			Assert.IsFalse(infAffixMsa1.InflFeatsOA.IsEquivalent(infAffixMsa2.InflFeatsOA), "InflFeatsOA should not be equal.");
			Assert.IsFalse(infAffixMsa1.EqualsMsa(infAffixMsa2), "infAffixMsa1 should not be equal to infAffixMsa2 due to different InflFeatsOA.");

			// match feature structures
			infAffixMsa1.InflFeatsOA.AddFeatureFromXml(Cache, itemFem);
			Assert.IsTrue(infAffixMsa1.EqualsMsa(infAffixMsa2), "infAffixMsa1 & infAffixMsa2 should be equal with matching feature structure");
		}
示例#7
0
		public void DeleteMoMorphAdhocProhib()
		{
			CheckDisposed();

			ILexDb ld = Cache.LangProject.LexDbOA;
			ILexEntry le = MakeLexEntry(ld, "xyzTest1", "xyzDefn1.1", 0);
			Assert.AreEqual(1, le.SensesOS.Count);
			LexSense ls = le.SensesOS[0] as LexSense;
			Assert.AreEqual(1, le.MorphoSyntaxAnalysesOC.Count);
			int hvoMsa = le.MorphoSyntaxAnalysesOC.HvoArray[0];
			Assert.AreEqual(hvoMsa, ls.MorphoSyntaxAnalysisRAHvo);
			IMoMorphSynAnalysis baseMsa = ls.MorphoSyntaxAnalysisRA;

			MoMorphAdhocProhib mmac = (MoMorphAdhocProhib)
				Cache.LangProject.MorphologicalDataOA.AdhocCoProhibitionsOC.Add(new MoMorphAdhocProhib());
			// Set FirstMorpheme
			mmac.FirstMorphemeRA = baseMsa;
			Assert.AreEqual(baseMsa.Hvo, mmac.FirstMorphemeRAHvo);

			// Build Morphemes (Reference Sequence) for our mmac
			int i = 0;
			for (; i < 2; i++)
			{
				// Add new MSA to our LexEntry
				MoMorphSynAnalysis msa = new MoStemMsa();
				le.MorphoSyntaxAnalysesOC.Add(msa);
				Assert.AreEqual(i + 2, le.MorphoSyntaxAnalysesOC.Count);
				// Add new MSA to Components
				mmac.MorphemesRS.Append(msa.Hvo);
				Assert.AreEqual(i + 1, mmac.MorphemesRS.Count);
				Assert.AreEqual(msa.Hvo, mmac.MorphemesRS[i].Hvo);
			}

			// Build RestOfMorphs (Reference Sequence) for our mmac
			for (int j = 0; j < 2; j++)
			{
				// Add new MSA to our LexEntry
				MoMorphSynAnalysis msa = new MoStemMsa();
				le.MorphoSyntaxAnalysesOC.Add(msa);
				Assert.AreEqual(j + (i + 2), le.MorphoSyntaxAnalysesOC.Count);
				// Add new MSA to Components
				mmac.RestOfMorphsRS.Append(msa.Hvo);
				Assert.AreEqual(j + 1, mmac.RestOfMorphsRS.Count);
				Assert.AreEqual(msa.Hvo, mmac.RestOfMorphsRS[j].Hvo);
			}

			// Delete our LexSense so that when we delete the msa, mmac can delete its FirstMorpheme.
			ls.DeleteUnderlyingObject();
			Assert.AreEqual(0, le.SensesOS.Count);
			Assert.AreEqual(1 + 2 + 2, le.MorphoSyntaxAnalysesOC.Count);
			// Delete our MoMorphAdhocProhib (mmac)
			mmac.DeleteUnderlyingObject();
			Assert.AreEqual(0, le.MorphoSyntaxAnalysesOC.Count);
		}
示例#8
0
		/// <summary>
		/// Go through the senses of this entry, ensuring that each one has an MSA assigned to it.
		/// MergeRedundantMSAs() should be called after this method.
		/// </summary>
		public void EnsureValidMSAsForSenses()
		{
			bool fIsAffix = MoMorphType.IsAffixType(this.MorphType);
			foreach (ILexSense ls in this.AllSenses)
			{
				if (ls.MorphoSyntaxAnalysisRAHvo != 0)
					continue;
				IMoMorphSynAnalysis msa;
				if (fIsAffix)
				{
					msa = FindEmptyAffixMsa();
					if (msa == null)
					{
						msa = new MoUnclassifiedAffixMsa();
						this.MorphoSyntaxAnalysesOC.Add(msa);
					}
				}
				else
				{
					msa = FindEmptyStemMsa();
					if (msa == null)
					{
						msa = new MoStemMsa();
						this.MorphoSyntaxAnalysesOC.Add(msa);
					}
				}
				ls.MorphoSyntaxAnalysisRAHvo = msa.Hvo;
			}
		}
示例#9
0
		public void ChangeMsaOnLexSense()
		{
			CheckDisposed();

			ILexDb ld = Cache.LangProject.LexDbOA;
			ILexEntry le = MakeLexEntry(ld, "xyzTest1", "xyzDefn1.1", 0);
			Assert.AreEqual(1, le.SensesOS.Count);
			LexSense ls = le.SensesOS[0] as LexSense;

			Assert.AreEqual(1, le.MorphoSyntaxAnalysesOC.Count);
			int hvoMsa = le.MorphoSyntaxAnalysesOC.HvoArray[0];
			Assert.AreEqual(hvoMsa, ls.MorphoSyntaxAnalysisRAHvo);

			// Add new MSA to LexEntry
			MoMorphSynAnalysis msa = new MoStemMsa();
			le.MorphoSyntaxAnalysesOC.Add(msa);
			Assert.AreEqual(2, le.MorphoSyntaxAnalysesOC.Count);
			// Change the LexSense MSA
			ls.MorphoSyntaxAnalysisRA = msa;
			Assert.AreEqual(msa.Hvo, ls.MorphoSyntaxAnalysisRAHvo);
			Assert.AreEqual(1, le.MorphoSyntaxAnalysesOC.Count);
			Assert.AreEqual(msa.Hvo, le.MorphoSyntaxAnalysesOC.HvoArray[0]);
		}
示例#10
0
		public void ChangeMsaOnWfiMorphBundle()
		{
			CheckDisposed();

			ILexDb ld = Cache.LangProject.LexDbOA;
			ILexEntry le = MakeLexEntry(ld, "xyzTest1", "xyzDefn1.1", 0);
			Assert.AreEqual(1, le.SensesOS.Count);
			LexSense ls = le.SensesOS[0] as LexSense;
			Assert.AreEqual(1, le.MorphoSyntaxAnalysesOC.Count);
			int hvoMsa = le.MorphoSyntaxAnalysesOC.HvoArray[0];
			Assert.AreEqual(hvoMsa, ls.MorphoSyntaxAnalysisRAHvo);

			// Setup WfiMorphBundle
			IWfiWordform wf = Cache.LangProject.WordformInventoryOA.WordformsOC.Add(new WfiWordform());
			IWfiAnalysis anal = wf.AnalysesOC.Add(new WfiAnalysis());
			IWfiMorphBundle wmb = anal.MorphBundlesOS.Append(new WfiMorphBundle());

			MoStemAllomorph bearNForm = (MoStemAllomorph)le.AlternateFormsOS.Append(new MoStemAllomorph());
			bearNForm.Form.VernacularDefaultWritingSystem = "bearNTEST";
			wmb.MorphRA = bearNForm;
			wmb.MsaRA = ls.MorphoSyntaxAnalysisRA;

			// Add new MSA to LexEntry
			MoMorphSynAnalysis msa = new MoStemMsa();
			le.MorphoSyntaxAnalysesOC.Add(msa);
			Assert.AreEqual(2, le.MorphoSyntaxAnalysesOC.Count);

			// Change LexSense MSA to new MSA
			ls.MorphoSyntaxAnalysisRA = msa;
			Assert.AreEqual(msa.Hvo, ls.MorphoSyntaxAnalysisRAHvo);
			Assert.AreEqual(2, le.MorphoSyntaxAnalysesOC.Count);

			// Change Msa on WfiMorphBundle
			wmb.MsaRA = ls.MorphoSyntaxAnalysisRA;
			Assert.AreEqual(msa.Hvo, wmb.MsaRA.Hvo);
			Assert.AreEqual(1, le.MorphoSyntaxAnalysesOC.Count);
		}
示例#11
0
		public void CheckNumberOfEntries()
		{
			CheckDisposed();

			m_fdoCache.LangProject.LexDbOA.EntriesOC.Add(new LexEntry());
			m_fdoCache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Append(new PartOfSpeech());
			PartOfSpeech pos = (Ling.PartOfSpeech)m_fdoCache.LangProject.PartsOfSpeechOA.PossibilitiesOS.FirstItem;
			int hvoLme = m_fdoCache.LangProject.LexDbOA.EntriesOC.HvoArray[0];
			ILexEntry lme = LexEntry.CreateFromDBObject(m_fdoCache, hvoLme);
			int cRef1 = pos.NumberOfLexEntries;
			MoStemMsa msm = new MoStemMsa();
			lme.MorphoSyntaxAnalysesOC.Add(msm);
			msm.PartOfSpeechRA = pos;
			int cRef2 = pos.NumberOfLexEntries;
			Assert.IsTrue(cRef1 + 1 == cRef2, "NumberOfLexEntries for MoStemMsa was " +
				cRef2 + " but should have been" + (cRef1 + 1));

			MoMorphType mmt = (Ling.MoMorphType)m_fdoCache.LangProject.LexDbOA.MorphTypesOA.PossibilitiesOS.FirstItem;
			cRef1 = mmt.NumberOfLexEntries;
			MoStemAllomorph msa = new MoStemAllomorph();
			lme.AlternateFormsOS.Append(msa);
			msa.MorphTypeRA = mmt;
			cRef2 = mmt.NumberOfLexEntries;
			Assert.IsTrue(cRef1 + 1 == cRef2, "NumberOfLexEntries for MoMorphType was " +
				cRef2 + " but should have been" + (cRef1 + 1));
		}
示例#12
0
		public void InflectionClassInCompoundStemMsasIsRelevant()
		{
			CheckDisposed();

			MoExoCompound compound = new MoExoCompound();
			Cache.LangProject.MorphologicalDataOA.CompoundRulesOS.Append(compound);
			MoStemMsa msaLeft = new MoStemMsa();
			MoStemMsa msaRight = new MoStemMsa();
			MoStemMsa msaTo = new MoStemMsa();
			compound.LeftMsaOA = msaLeft;
			compound.RightMsaOA = msaRight;
			compound.ToMsaOA = msaTo;
			Assert.IsFalse(msaLeft.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidInflectionClass),
				"Inflection Class should not be relevant for LeftMsa.");
			Assert.IsFalse(msaRight.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidInflectionClass),
				"Inflection Class should not be relevant for RightMsa.");
			Assert.IsFalse(msaTo.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidInflectionClass),
				"Inflection Class should not be relevant for ToMsa if it does not have a category.");
			PartOfSpeech pos = new PartOfSpeech();
			Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Append(pos);
			msaTo.PartOfSpeechRA = pos;
			Assert.IsTrue(msaTo.IsFieldRelevant((int)MoStemMsa.MoStemMsaTags.kflidInflectionClass),
				"Inflection Class should be relevant for ToMsa when it has a category.");
		}
示例#13
0
		// TODO RandyR: Add ShortNameTSS and DeletionTextTSS.
		// NOTE: Don't override ShortName here, as the superclass override will do it right.

		///<summary>
		/// Copies attributes associated with the current POS, such as inflection features and classes, that
		/// are valid from the specified MSA to this MSA. If the attribute is not valid, it is removed from
		/// this MSA.
		///</summary>
		///<param name="srcMsa">the source MSA</param>
		public void CopyAttributesIfValid(MoStemMsa srcMsa)
		{
			// inflection classes
			if (IsReferenceAttributeValid(srcMsa.InflectionClassRAHvo, (int)MoStemMsaTags.kflidInflectionClass))
			{
				if (srcMsa.InflectionClassRAHvo != InflectionClassRAHvo)
					InflectionClassRAHvo = srcMsa.InflectionClassRAHvo;
			}
			else if (InflectionClassRAHvo != 0)
			{
				InflectionClassRAHvo = 0;
			}

			// inflection features
			if (srcMsa.MsFeaturesOAHvo == 0)
			{
				MsFeaturesOA = null;
			}
			else
			{
				if (MsFeaturesOAHvo != srcMsa.MsFeaturesOAHvo)
					m_cache.CopyObject(srcMsa.MsFeaturesOAHvo, m_hvo, (int)MoStemMsaTags.kflidMsFeatures);
				RemoveInvalidFeatureSpecs(PartOfSpeechRA, MsFeaturesOA);
				if (MsFeaturesOA.IsEmpty)
					MsFeaturesOA = null;
			}
		}
		/// <summary>
		/// Execute the change requested by the current selection in the combo.
		/// Basically we want a copy of the FsFeatStruc indicated by m_selectedHvo, (even if 0?? not yet possible),
		/// to become the MsFeatures of each record that is appropriate to change.
		/// We do nothing to records where the check box is turned off,
		/// and nothing to ones that currently have an MSA other than an MoStemMsa,
		/// and nothing to ones that currently have an MSA with the wrong POS.
		/// (a) If the owning entry has an MoStemMsa with a matching MsFeatures (and presumably POS),
		/// set the sense to use it.
		/// (b) If all senses using the current MoStemMsa are to be changed, just update
		/// the MsFeatures of that MoStemMsa.
		/// We could add this...but very probably unused MSAs would have been taken over
		/// when setting the POS.
		/// --(c) If the entry has an MoStemMsa which is not being used at all, change it to
		/// --the required POS and inflection class and use it.
		/// (d) Make a new MoStemMsa in the LexEntry with the required POS and features
		/// and point the sense at it.
		/// </summary>
		public void DoIt(Set<int> itemsToChange, ProgressState state)
		{
			CheckDisposed();

			int hvoPos = GetPOS();
			// Make a Set of eligible parts of speech to use in filtering.
			Set<int> possiblePOS = GetPossiblePartsOfSpeech();
			// Make a Dictionary from HVO of entry to list of modified senses.
			Dictionary<int, Set<ILexSense>> sensesByEntry = new Dictionary<int, Set<ILexSense>>();
			int tagOwningEntry = m_cache.VwCacheDaAccessor.GetVirtualHandlerName("LexSense", "OwningEntry").Tag;
			int i = 0;
			// Report progress 50 times or every 100 items, whichever is more (but no more than once per item!)
			int interval = Math.Min(100, Math.Max(itemsToChange.Count / 50, 1));
			foreach(int hvoSense in itemsToChange)
			{
				i++;
				if (i % interval == 0)
				{
					state.PercentDone = i * 20 / itemsToChange.Count;
					state.Breath();
				}
				if (!IsItemEligible(m_cache.MainCacheAccessor, hvoSense, possiblePOS))
					continue;
				ILexSense ls = (ILexSense)CmObject.CreateFromDBObject(m_cache, hvoSense, false);
				IMoMorphSynAnalysis msa = ls.MorphoSyntaxAnalysisRA;
				int hvoEntry = m_cache.MainCacheAccessor.get_ObjectProp(ls.Hvo, tagOwningEntry);
				if (!sensesByEntry.ContainsKey(hvoEntry))
					sensesByEntry[hvoEntry] = new Set<ILexSense>();
				sensesByEntry[hvoEntry].Add(ls);
			}
			//REVIEW: Should these really be the same Undo/Redo strings as for InflectionClassEditor.cs?
			m_cache.BeginUndoTask(FdoUiStrings.ksUndoBEInflClass, FdoUiStrings.ksRedoBEInflClass);
			BulkEditBar.ForceRefreshOnUndoRedo(Cache.MainCacheAccessor);
			i = 0;
			interval = Math.Min(100, Math.Max(sensesByEntry.Count / 50, 1));
			IFsFeatStruc fsTarget = null;
			if (m_selectedHvo != 0)
				fsTarget = FsFeatStruc.CreateFromDBObject(Cache, m_selectedHvo);
			foreach (KeyValuePair<int, Set<ILexSense>> kvp in sensesByEntry)
			{
				i++;
				if (i % interval == 0)
				{
					state.PercentDone = i * 80 / sensesByEntry.Count + 20;
					state.Breath();
				}
				ILexEntry entry = (ILexEntry)CmObject.CreateFromDBObject(m_cache, kvp.Key, false);
				Set<ILexSense> sensesToChange = kvp.Value;
				IMoStemMsa msmTarget = null;
				foreach (IMoMorphSynAnalysis msa in entry.MorphoSyntaxAnalysesOC)
				{
					IMoStemMsa msm = msa as IMoStemMsa;
					if (msm != null && MsaMatchesTarget(msm, fsTarget))
					{
						// Can reuse this one!
						msmTarget = msm;
						break;
					}
				}
				if (msmTarget == null)
				{
					// See if we can reuse an existing MoStemMsa by changing it.
					// This is possible if it is used only by senses in the list, or not used at all.
					Set<ILexSense> otherSenses = new Set<ILexSense>();
					Set<ILexSense> senses = new Set<ILexSense>(entry.AllSenses.ToArray());
					if (senses.Count != sensesToChange.Count)
					{
						foreach (ILexSense ls in senses)
						{
							if (!sensesToChange.Contains(ls))
								otherSenses.Add(ls);
						}
					}
					foreach (IMoMorphSynAnalysis msa in entry.MorphoSyntaxAnalysesOC)
					{
						IMoStemMsa msm = msa as IMoStemMsa;
						if (msm == null)
							continue;
						bool fOk = true;
						foreach (ILexSense ls in otherSenses)
						{
							if (ls.MorphoSyntaxAnalysisRA == msm)
							{
								fOk = false;
								break;
							}
						}
						if (fOk)
						{
							// Can reuse this one! Nothing we don't want to change uses it.
							// Adjust its POS as well as its inflection feature, just to be sure.
							// Ensure that we don't change the POS!  See LT-6835.
							msmTarget = msm;
							InitMsa(msmTarget, msm.PartOfSpeechRAHvo);
							break;
						}
					}
				}
				if (msmTarget == null)
				{
					// Nothing we can reuse...make a new one.
					msmTarget = new MoStemMsa();
					entry.MorphoSyntaxAnalysesOC.Add(msmTarget);
					InitMsa(msmTarget, hvoPos);
				}
				// Finally! Make the senses we want to change use it.
				foreach (ILexSense ls in sensesToChange)
				{
					ls.MorphoSyntaxAnalysisRA = msmTarget;
				}
			}
			m_cache.EndUndoTask();
		}
示例#15
0
		public void DeleteMoMorphSynAnalysis()
		{
			CheckDisposed();

			ILexDb ld = Cache.LangProject.LexDbOA;
			ILexEntry le = MakeLexEntry(ld, "xyzTest1", "xyzDefn1.1", 0);
			Assert.AreEqual(1, le.SensesOS.Count);
			LexSense ls = le.SensesOS[0] as LexSense;
			Assert.AreEqual(1, le.MorphoSyntaxAnalysesOC.Count);
			int hvoMsa = le.MorphoSyntaxAnalysesOC.HvoArray[0];
			Assert.AreEqual(hvoMsa, ls.MorphoSyntaxAnalysisRAHvo);
			IMoMorphSynAnalysis baseMsa = ls.MorphoSyntaxAnalysisRA;

			// Build Components (Reference Sequence) for our baseMSA
			for (int i = 1; i < 4; i++)
			{
				// Add new MSA to our LexEntry
				MoMorphSynAnalysis msa = new MoStemMsa();
				le.MorphoSyntaxAnalysesOC.Add(msa);
				Assert.AreEqual(i + 1, le.MorphoSyntaxAnalysesOC.Count);
				// Add new MSA to Components
				baseMsa.ComponentsRS.Append(msa.Hvo);
				Assert.AreEqual(i, baseMsa.ComponentsRS.Count);
				Assert.AreEqual(msa.Hvo, baseMsa.ComponentsRS[i - 1].Hvo);
			}

			// Delete baseMsa by deleting the only reference to it (LexSense)
			ls.DeleteUnderlyingObject();
			Assert.AreEqual(0, le.SensesOS.Count);
			Assert.AreEqual(0, le.MorphoSyntaxAnalysesOC.Count);
		}
示例#16
0
		/// <summary>
		/// Get the HVO for an appropriate default MoMorphSynAnalysis belonging to this
		/// entry, creating it if necessary.
		/// </summary>
		/// <returns></returns>
		public int FindOrCreateDefaultMsa()
		{
			// Search for an appropriate MSA already existing for the LexEntry.
			foreach (IMoMorphSynAnalysis msa in this.MorphoSyntaxAnalysesOC)
			{
				if (MoMorphType.IsAffixType(this.MorphType))
				{
					if (msa is MoUnclassifiedAffixMsa)
						return msa.Hvo;
				}
				else
				{
					if (msa is MoStemMsa)
						return msa.Hvo;
				}
			}
			// Nothing exists, create the needed MSA.
			MoMorphSynAnalysis msaNew;
			if (MoMorphType.IsAffixType(MorphType))
				msaNew = new MoUnclassifiedAffixMsa();
			else
				msaNew = new MoStemMsa();
			msaNew.InitNew(this.Cache, this.Hvo, this.MorphoSyntaxAnalysesOC.Flid, 0);
			MorphoSyntaxAnalysesOC.Add(msaNew);
			return msaNew.Hvo;
		}
示例#17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="ld"></param>
		/// <param name="cf"></param>
		/// <param name="defn"></param>
		/// <param name="hvoDomain"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected ILexEntry MakeLexEntry(ILexDb ld, string cf, string defn, int hvoDomain)
		{
			ILexEntry le = ld.EntriesOC.Add(new LexEntry());
			le.CitationForm.VernacularDefaultWritingSystem = cf;
			ILexSense ls = le.SensesOS.Append(new LexSense());
			ls.Definition.AnalysisDefaultWritingSystem.Text = defn;
			if (hvoDomain != 0)
				ls.SemanticDomainsRC.Add(hvoDomain);
			MoMorphSynAnalysis msa = new MoStemMsa();
			le.MorphoSyntaxAnalysesOC.Add(msa);
			ls.MorphoSyntaxAnalysisRA = msa;
			return le;
		}
示例#18
0
		private int FindOrCreateMatchingStemMsa(IMoMorphSynAnalysis msa)
		{
			int hvoPOS = 0;
			if (msa is IMoInflAffMsa)
				hvoPOS = (msa as IMoInflAffMsa).PartOfSpeechRAHvo;
			else if (msa is IMoDerivAffMsa)
				hvoPOS = (msa as IMoDerivAffMsa).ToPartOfSpeechRAHvo;
			else if (msa is IMoDerivStepMsa)
				hvoPOS = (msa as IMoDerivStepMsa).PartOfSpeechRAHvo;
			else if (msa is IMoUnclassifiedAffixMsa)
				hvoPOS = (msa as IMoUnclassifiedAffixMsa).PartOfSpeechRAHvo;
			foreach (IMoMorphSynAnalysis msaT in this.MorphoSyntaxAnalysesOC)
			{
				IMoStemMsa msaStem = msaT as IMoStemMsa;
				if (msaStem != null &&
					msaStem.PartOfSpeechRAHvo == hvoPOS &&
					msaStem.FromPartsOfSpeechRC.Count == 0 &&
					msaStem.InflectionClassRAHvo == 0 &&
					msaStem.ProdRestrictRC.Count == 0 &&
					msaStem.StratumRAHvo == 0 &&
					msaStem.MsFeaturesOAHvo == 0)
				{
					return msaStem.Hvo;
				}
			}
			IMoStemMsa msaNew = new MoStemMsa();
			this.MorphoSyntaxAnalysesOC.Add(msaNew);
			msaNew.PartOfSpeechRAHvo = hvoPOS;
			return msaNew.Hvo;
		}
示例#19
0
		// TODO RandyR: Add ShortNameTSS and DeletionTextTSS. (DeleteUnderlyingObject() is not meeded.)

		/// <summary>
		/// Create other required elements.
		/// </summary>
		public override void InitNewInternal()
		{
			base.InitNewInternal();
			ToMsaOA = new MoStemMsa();
		}