Пример #1
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");
		}
Пример #2
0
		public void InflectionClassIsRelevant()
		{
			CheckDisposed();

			LexEntry entry = new LexEntry ();
			Cache.LangProject.LexDbOA.EntriesOC.Add(entry);
			MoAffixAllomorph allomorph = new MoAffixAllomorph();
			entry.AlternateFormsOS.Append(allomorph);
			Assert.IsFalse(allomorph.IsFieldRelevant((int)MoAffixForm.MoAffixFormTags.kflidInflectionClasses),
				"InflectionClass should not be relevant until an inflectional affix MSA with a category has been added.");
			MoInflAffMsa orange = new MoInflAffMsa();
			entry.MorphoSyntaxAnalysesOC.Add(orange);
			Assert.IsFalse(allomorph.IsFieldRelevant((int)MoAffixForm.MoAffixFormTags.kflidInflectionClasses),
				"InflectionClass should not be relevant until an inflectional affix MSA with a category has been added.");
			PartOfSpeech pos = new PartOfSpeech();
			Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Append(pos);
			orange.PartOfSpeechRA = pos;
			Assert.IsTrue(allomorph.IsFieldRelevant((int)MoAffixForm.MoAffixFormTags.kflidInflectionClasses),
				"InflectionClass should now be relevant since an inflectional affix MSA with a category has been added.");

		}
Пример #3
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");
		}
Пример #4
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");
		}
Пример #5
0
		private void DoTestLexemeFormAffixAllomorphIsRelevant()
		{
			LexEntry affixEntry = new LexEntry ();
			Cache.LangProject.LexDbOA.EntriesOC.Add(affixEntry);
			MoAffixAllomorph affixAllomorph = new MoAffixAllomorph();
			affixEntry.LexemeFormOA = affixAllomorph;
			Assert.IsFalse(affixAllomorph.IsFieldRelevant((int)MoAffixAllomorph.MoAffixAllomorphTags.kflidPosition),
				"Affix allomorph position should not be relevant in an underlying form.");
			Assert.IsFalse(affixAllomorph.IsFieldRelevant((int)MoAffixAllomorph.MoAffixAllomorphTags.kflidPhoneEnv),
				"Affix allomorph environment should not be relevant in an underlying form.");
			MoInflAffMsa iamsa = new MoInflAffMsa();
			affixEntry.MorphoSyntaxAnalysesOC.Add(iamsa);
			Assert.IsFalse(affixAllomorph.IsFieldRelevant((int)MoAffixAllomorph.MoAffixFormTags.kflidInflectionClasses),
				"Affix inflection class(es) should not be relevant in an underlying form.");
		}
Пример #6
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(MoInflAffMsa srcMsa)
		{
			// inflection features
			if (srcMsa.InflFeatsOAHvo == 0)
			{
				InflFeatsOA = null;
			}
			else
			{
				if (InflFeatsOAHvo != srcMsa.InflFeatsOAHvo)
					m_cache.CopyObject(srcMsa.InflFeatsOAHvo, m_hvo, (int)MoInflAffMsaTags.kflidInflFeats);
				RemoveInvalidFeatureSpecs(PartOfSpeechRA, InflFeatsOA);
				if (InflFeatsOA.IsEmpty)
					InflFeatsOA = null;
			}
		}
Пример #7
0
		public void ParserDataChanges()
		{
			XmlNode node;
#if !ShowDumpResult
			m_fxtResult.Save(Path.Combine(System.IO.Path.GetTempPath(), "TestFxtUpdateBefore.xml"));
#endif
			// -------------
			// Make data changes
			// -------------
			// Make a change to stem allomorph
			ILangProject lp = Cache.LangProject;
			ILexDb lexdb = lp.LexDbOA;
			int[] aiLexEntries = lexdb.EntriesOC.HvoArray;
			int hvoLexEntry = aiLexEntries[0];
			ILexEntry lexEntry = CmObject.CreateFromDBObject(Cache, hvoLexEntry) as ILexEntry;
			Assert.IsNotNull(lexEntry);
			IMoStemAllomorph stemAllomorph = lexEntry.LexemeFormOA as IMoStemAllomorph;
			Assert.IsNotNull(stemAllomorph);
			stemAllomorph.Form.SetAlternative("bili-changed", Cache.DefaultVernWs);
			int hvoStemAllomorph = stemAllomorph.Hvo;
			stemAllomorph.IsAbstract = true;

			// Delete an affix allomorph
			hvoLexEntry = aiLexEntries[3];
			lexEntry = CmObject.CreateFromDBObject(Cache, hvoLexEntry) as ILexEntry;
			Assert.IsNotNull(lexEntry);
			IMoAffixAllomorph affixAllomorph = lexEntry.AlternateFormsOS[1] as IMoAffixAllomorph;
			Assert.IsNotNull(affixAllomorph);
			int hvoAffixAllomorph = affixAllomorph.Hvo;
			lexEntry.AlternateFormsOS.RemoveAt(1);
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoLexEntry, (int)LexEntry.LexEntryTags.kflidAlternateForms, 1, 0, 1);

			// Add a new affix allomorph
			IMoAffixAllomorph newAffixAllomorph = new MoAffixAllomorph();
			lexEntry.AlternateFormsOS.Append(newAffixAllomorph);
			newAffixAllomorph.Form.SetAlternative("him-new", Cache.DefaultVernWs);
			int hvoNewAffixAllomorph = newAffixAllomorph.Hvo;
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoLexEntry, (int)LexEntry.LexEntryTags.kflidAlternateForms, lexEntry.AlternateFormsOS.Count - 1, 1, 0);

			// add a compound rule
			IMoMorphData morphData = lp.MorphologicalDataOA;
			IMoEndoCompound compRuleNew = new MoEndoCompound();
			morphData.CompoundRulesOS.Append(compRuleNew);
			string sCompRuleName = "new compound rule";
			compRuleNew.Name.AnalysisDefaultWritingSystem = sCompRuleName;
			compRuleNew.HeadLast = true;
			int hvoPOS = lp.PartsOfSpeechOA.PossibilitiesOS.FirstItem.Hvo;
			compRuleNew.LeftMsaOA.PartOfSpeechRAHvo = hvoPOS;
			compRuleNew.RightMsaOA.PartOfSpeechRAHvo = hvoPOS;
			compRuleNew.OverridingMsaOA.PartOfSpeechRAHvo = hvoPOS;
			// Change compound rule description
			const string ksCompRuleDescription = "new description";
			compRuleNew.Description.AnalysisDefaultWritingSystem.Text = ksCompRuleDescription;
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, morphData.Hvo, (int)MoMorphData.MoMorphDataTags.kflidCompoundRules, morphData.CompoundRulesOS.Count - 1, 1, 0);

			// delete a compound rule
			IMoExoCompound compRuleDeleted = morphData.CompoundRulesOS.FirstItem as IMoExoCompound;
			int hvoCompRuleDeletedLeftMsa = compRuleDeleted.LeftMsaOAHvo;
			int hvoCompRuleDeletedRightMsa = compRuleDeleted.RightMsaOAHvo;
			int hvoCompRuleDeletedToMsa = compRuleDeleted.ToMsaOAHvo;
			morphData.CompoundRulesOS.RemoveAt(0);

			// add an ad hoc co-prohibition
			IMoAlloAdhocProhib alloAdHoc = new MoAlloAdhocProhib();
			morphData.AdhocCoProhibitionsOC.Add(alloAdHoc);
			alloAdHoc.Adjacency = 2;
			alloAdHoc.FirstAllomorphRAHvo = hvoNewAffixAllomorph;
			alloAdHoc.RestOfAllosRS.Append(hvoNewAffixAllomorph);

			// change a "rest of allos" in extant ad hoc co-prohibition
			int[] hvosAdHocProhibs = morphData.AdhocCoProhibitionsOC.HvoArray;
			IMoAlloAdhocProhib alloAdHocOld =
				CmObject.CreateFromDBObject(Cache, hvosAdHocProhibs[9]) as IMoAlloAdhocProhib;
			IMoAffixAllomorph alloAdHicOldFirstRestOfAllos = alloAdHocOld.RestOfAllosRS.FirstItem as IMoAffixAllomorph;
			IMoAffixAllomorph affixAllomorph2 = lexEntry.AlternateFormsOS[0] as IMoAffixAllomorph;
			alloAdHocOld.RestOfAllosRS.Append(affixAllomorph2);
			alloAdHocOld.RestOfAllosRS.RemoveAt(0);
			alloAdHocOld.Adjacency = 2;

			//Add a new productivity restriction
			ICmPossibilityList prodRestricts = morphData.ProdRestrictOA;
			ICmPossibility prodRestriction = new CmPossibility();
			prodRestricts.PossibilitiesOS.Append(prodRestriction);
			string sNewProdRestrictName = "new exception feature";
			prodRestriction.Name.AnalysisDefaultWritingSystem = sNewProdRestrictName;
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, prodRestricts.Hvo, (int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities, prodRestricts.PossibilitiesOS.Count - 1, 1, 0);

			// Change a phonological enviroment string representation
			IPhPhonData phonData = lp.PhonologicalDataOA;
			IPhEnvironment env = phonData.EnvironmentsOS.FirstItem;
			const string ksEnvStringRep = "/ _ [C] [V] a e i o u";
			env.StringRepresentation.Text = ksEnvStringRep;

			// Add a new phonological enviroment string representation
			IPhEnvironment envNew = new PhEnvironment();
			phonData.EnvironmentsOS.Append(envNew);
			envNew.StringRepresentation.Text = "/ _ m";
			int hvoPhonData = phonData.Hvo;
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoPhonData, (int)PhPhonData.PhPhonDataTags.kflidEnvironments, phonData.EnvironmentsOS.Count - 1, 1, 0);

			// Change parser parameters (to test Unicode string field type)
			string sParserParameters = morphData.ParserParameters.Trim();
			int i = sParserParameters.IndexOf("</ParserParameters>");
			string sNewParserParameters = sParserParameters.Substring(0, i) + "<HermitCrab><stuff>1</stuff></HermitCrab>" + "</ParserParameters>";
			morphData.ParserParameters = sNewParserParameters;

			// Delete a lex entry
			int[] hvosEntries = lexdb.EntriesOC.HvoArray;
			int hvoEntryDeleted = hvosEntries[hvosEntries.Length - 4];
			ILexEntry entryDeleted = CmObject.CreateFromDBObject(Cache, hvoEntryDeleted) as ILexEntry;
			int hvoEntryDeletedLexemeForm = entryDeleted.LexemeFormOAHvo;
			int[] hvosEntryDeletedAlternateForms = entryDeleted.AlternateFormsOS.HvoArray;
			int[] hvosEntryDeletedMSAs = entryDeleted.MorphoSyntaxAnalysesOC.HvoArray;
			int[] hvosEntryDeletedSenses = entryDeleted.SensesOS.HvoArray;
			//entryDeleted.LexemeFormOA.DeleteUnderlyingObject();
			lexdb.EntriesOC.Remove(hvosEntries[hvosEntries.Length - 4]);
			//Cache.PropChanged(null, PropChangeType.kpctNotifyAll, morphData.Hvo, (int)MoMorphData.MoMorphDataTags.kflidParserParameters, 0, 0, 0);

			// Create a new lex entry
			ILexEntry entryNew = new LexEntry();
			lexdb.EntriesOC.Add(entryNew);

			IMoAffixAllomorph alloNew = new MoAffixAllomorph();
			entryNew.LexemeFormOA = alloNew;
			string sNewAlloForm = "dem";
			alloNew.Form.VernacularDefaultWritingSystem = sNewAlloForm;
			alloNew.MorphTypeRA = (IMoMorphType)lexdb.MorphTypesOA.LookupPossibilityByGuid(new Guid(MoMorphType.kguidMorphPrefix));

			IMoAffixAllomorph alloNew2 = new MoAffixAllomorph();
			entryNew.AlternateFormsOS.Append(alloNew2);
			string sNewAlloForm2 = "den";
			alloNew2.Form.VernacularDefaultWritingSystem = sNewAlloForm2;
			alloNew2.MorphTypeRA = (IMoMorphType)lexdb.MorphTypesOA.LookupPossibilityByGuid(new Guid(MoMorphType.kguidMorphPrefix));
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, entryNew.Hvo, (int)LexEntry.LexEntryTags.kflidAlternateForms, entryNew.AlternateFormsOS.Count - 1, 1, 0);

			ILexSense sense = new LexSense();
			entryNew.SensesOS.Append(sense);
			string sGloss = "MeToo";
			sense.Gloss.AnalysisDefaultWritingSystem = sGloss;

			IMoInflAffMsa inflAffixMsa = new MoInflAffMsa();
			entryNew.MorphoSyntaxAnalysesOC.Add(inflAffixMsa);
			sense.MorphoSyntaxAnalysisRA = inflAffixMsa;
			int[] hvosPOSes = lp.PartsOfSpeechOA.PossibilitiesOS.HvoArray;
			int hvoVerb = hvosPOSes[12];
			inflAffixMsa.PartOfSpeechRAHvo = hvoVerb;
			IPartOfSpeech pos = CmObject.CreateFromDBObject(Cache, hvoVerb) as IPartOfSpeech;
			int hvoSlot = pos.AffixSlotsOC.HvoArray[2];
			inflAffixMsa.SlotsRC.Add(hvoSlot);
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, entryNew.Hvo, (int)LexEntry.LexEntryTags.kflidSenses, entryNew.SensesOS.Count - 1, 1, 0);

			// Add an inflectional template
			int[] hvoVerbSubCats = pos.SubPossibilitiesOS.HvoArray;
			int hvoIntransVerb = hvoVerbSubCats[2];
			IPartOfSpeech posVI = CmObject.CreateFromDBObject(Cache, hvoIntransVerb) as IPartOfSpeech;
			IMoInflAffixTemplate affixTemplate = new MoInflAffixTemplate();
			posVI.AffixTemplatesOS.Append(affixTemplate);
			affixTemplate.Name.AnalysisDefaultWritingSystem = "derived verb";
			affixTemplate.Final = false;
			affixTemplate.SuffixSlotsRS.Append(hvoSlot);
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, posVI.Hvo, (int)PartOfSpeech.PartOfSpeechTags.kflidAffixTemplates, posVI.AffixTemplatesOS.Count - 1, 1, 0);

			// add a phonological feature
			IFsClosedFeature consFeat = new FsClosedFeature();
			Cache.LangProject.PhFeatureSystemOA.FeaturesOC.Add(consFeat);
			consFeat.Name.AnalysisDefaultWritingSystem = "consonantal";
			consFeat.Abbreviation.AnalysisDefaultWritingSystem = "cons";
			IFsSymFeatVal consPlus = new FsSymFeatVal();
			consFeat.ValuesOC.Add(consPlus);
			consPlus.SimpleInit("+", "positive");
			IFsSymFeatVal consMinus = new FsSymFeatVal();
			consFeat.ValuesOC.Add(consMinus);
			consMinus.SimpleInit("-", "negative");
			IFsFeatStrucType fsType = null;
			if (Cache.LangProject.PhFeatureSystemOA.TypesOC.Count == 0)
			{
				fsType = new FsFeatStrucType();
				Cache.LangProject.PhFeatureSystemOA.TypesOC.Add(fsType);
				fsType.Abbreviation.AnalysisDefaultWritingSystem = "Phon";
			}
			else
			{
				foreach (IFsFeatStrucType type in Cache.LangProject.PhFeatureSystemOA.TypesOC)
				{
					fsType = type;
					break;
				}
			}
			fsType.FeaturesRS.Append(consFeat);

			// add a feature-based NC
			IPhNCFeatures featNC = new PhNCFeatures();
			Cache.LangProject.PhonologicalDataOA.NaturalClassesOS.Append(featNC);
			featNC.Name.AnalysisDefaultWritingSystem = "Consonants (Features)";
			featNC.Abbreviation.AnalysisDefaultWritingSystem = "CF";
			IFsFeatStruc fs = new FsFeatStruc();
			featNC.FeaturesOA = fs;
			IFsClosedValue val = fs.FindOrCreateClosedValue(consFeat.Hvo);
			val.FeatureRA = consFeat;
			val.ValueRA = consPlus;
			featNC.NotifyNew();

			// add phonological rule
			IPhRegularRule regRule = new PhRegularRule();
			Cache.LangProject.PhonologicalDataOA.PhonRulesOS.Append(regRule);
			regRule.NotifyNew();
			regRule.Name.AnalysisDefaultWritingSystem = "regular rule";
			IPhSimpleContextSeg segCtxt = new PhSimpleContextSeg();
			regRule.RightHandSidesOS[0].StrucChangeOS.Append(segCtxt);
			IPhPhoneme phoneme = null;
			foreach (IPhPhoneme phon in Cache.LangProject.PhonologicalDataOA.PhonemeSetsOS[0].PhonemesOC)
			{
				phoneme = phon;
				break;
			}
			segCtxt.FeatureStructureRA = phoneme;
			segCtxt.NotifyNew();

			IPhSimpleContextNC ncCtxt = new PhSimpleContextNC();
			regRule.RightHandSidesOS[0].LeftContextOA = ncCtxt;
			ncCtxt.FeatureStructureRA = featNC;
			ncCtxt.NotifyNew();

			// add a morphological rule
			IMoAffixProcess affRule = new MoAffixProcess();
			entryNew.AlternateFormsOS.Append(affRule);
			affRule.NotifyNew();
			ncCtxt = new PhSimpleContextNC();
			affRule.InputOS.Append(ncCtxt);
			ncCtxt.FeatureStructureRA = featNC;
			ncCtxt.NotifyNew();
			IMoCopyFromInput copy = new MoCopyFromInput();
			affRule.OutputOS.Append(copy);
			copy.ContentRA = ncCtxt;
			copy.NotifyNew();

			// -----------
			// Update the FXT result
			// -----------
			XmlDocument updatedFxtResult = UpdateFXT();

			// -----------
			// Test the updated results
			// -----------

			// Test changed stem allomorph: checks on MultiUnicode and boolean
			node = updatedFxtResult.SelectSingleNode("//MoStemAllomorph[@Id='" + hvoStemAllomorph + "']");
			Assert.IsNotNull(node);
			Assert.AreEqual(stemAllomorph.Form.VernacularDefaultWritingSystem, node.InnerText, "stem allomorph form change failed");
			XmlNode contentNode = node.SelectSingleNode("@IsAbstract");
			Assert.AreEqual("1", contentNode.InnerText, "stem allomorph is abstract should be true (=1)");

			// Test deleted affix allomorph: checks on owning sequence
			node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + hvoAffixAllomorph + "']");
			Assert.IsNull(node, "Deleted affix allomorph should be null");
			node =
				updatedFxtResult.SelectSingleNode("//LexEntry[@id='" + hvoLexEntry + "']/AlternateForms[@dst='" +
												  hvoAffixAllomorph + "']");
			Assert.IsNull(node, "LexEntry should no longer have deleted alternate form");

			// Test added new affix allomorph: checks on owning sequence owned by an item with an @Id; also checks on addition of MoAffixAllomorph via AllAllomorphs
			string sXPath = "//LexEntry[@Id='" + hvoLexEntry + "']/AlternateForms[@dst='" +
							hvoNewAffixAllomorph + "']";
			node = updatedFxtResult.SelectSingleNode(sXPath);
			Assert.IsNotNull(node, "LexEntry should have added alternate form");
			node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + hvoNewAffixAllomorph + "']");
			Assert.IsNotNull(node, "Added affix allomorph should be present");
			sXPath = "//LexEntry[@Id='" + hvoLexEntry + "']";
			node = updatedFxtResult.SelectSingleNode(sXPath);
			XmlNodeList nodes = node.SelectNodes("AlternateForms");
			Assert.AreEqual(3, nodes.Count, "Expected three Alternate forms in lex entry.");

			//Test newly added compound rule: checks on owning sequence owned by an Id-less element; also on multistring
			node = updatedFxtResult.SelectSingleNode("//MoEndoCompound[@Id='" + compRuleNew.Hvo + "']");
			Assert.IsNotNull(node, "did not find newly added compound rule");
			contentNode = node.SelectSingleNode("@HeadLast");
			Assert.IsNotNull(contentNode, "missing headlast attribute for coompound rule");
			Assert.AreEqual("1", contentNode.InnerText, "compound rule headlast value differs");
			contentNode = node.SelectSingleNode("Name");
			Assert.IsNotNull(contentNode, "missing Name for compound rule");
			Assert.AreEqual(sCompRuleName, contentNode.InnerText, "compound rule name differs");
			// check on MultiString
			contentNode = node.SelectSingleNode("Description");
			Assert.AreEqual(ksCompRuleDescription, contentNode.InnerText, "compound rule description differs");
			// check on count
			node = updatedFxtResult.SelectSingleNode("//CompoundRules");
			nodes = node.SelectNodes("MoExoCompound | MoEndoCompound");
			Assert.AreEqual(6, nodes.Count, "Expected seven compound rules.");
			// check on owningAtom
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + compRuleNew.LeftMsaOAHvo + "']");
			Assert.IsNotNull(node, "missing real MoStemMsa for LeftMsa of newly added compound rule");
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + compRuleNew.RightMsaOAHvo + "']");
			Assert.IsNotNull(node, "missing real MoStemMsa for RightMsa of newly added compound rule");
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + compRuleNew.OverridingMsaOAHvo + "']");
			Assert.IsNotNull(node, "missing real MoStemMsa for OverridingMsa of newly added compound rule");

			// Test deleted compound rule
			node = updatedFxtResult.SelectSingleNode("//MoExoCompound[@Id='" + compRuleDeleted.Hvo + "']");
			Assert.IsNull(node, "compound rule should be deleted");
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvoCompRuleDeletedLeftMsa + "']");
			Assert.IsNull(node, "compound rule left MSA should be deleted");
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvoCompRuleDeletedRightMsa + "']");
			Assert.IsNull(node, "compound rule right MSA should be deleted");
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvoCompRuleDeletedToMsa + "']");
			Assert.IsNull(node, "compound rule to MSA should be deleted");

			//Test newly added allomorph ad hoc rule: checks on owning collection
			node = updatedFxtResult.SelectSingleNode("//MoAlloAdhocProhib[@Id='" + alloAdHoc.Hvo + "']");
			Assert.IsNotNull(node, "did not find newly added allo ad hoc rule");
			contentNode = node.SelectSingleNode("@Adjacency");
			Assert.IsNotNull(contentNode, "missing adjacency attribute for allo ad hoc rule");
			Assert.AreEqual("2",contentNode.InnerText, "allo ad hoc rule adjacency value differs");
			contentNode = node.SelectSingleNode("FirstAllomorph");
			Assert.IsNotNull(contentNode, "missing FirstAllomorph for allo ad hoc rule");
			contentNode = contentNode.SelectSingleNode("@dst");
			Assert.IsNotNull(contentNode, "missing dst attribute of FirstAllomorph for allo ad hoc rule");
			Assert.AreEqual(hvoNewAffixAllomorph.ToString(), contentNode.InnerText, "FirstAllomorph of allo ad hoc rule differs");
			contentNode = node.SelectSingleNode("RestOfAllos");
			Assert.IsNotNull(contentNode, "missing RestOfAllos for allo ad hoc rule");
			contentNode = contentNode.SelectSingleNode("@dst");
			Assert.IsNotNull(contentNode, "missing dst attribute of RestOfAllos for allo ad hoc rule");
			Assert.AreEqual(hvoNewAffixAllomorph.ToString(), contentNode.InnerText, "RestOfAllos of allo ad hoc rule differs");

			// test change of a "rest of allos" in extant ad hoc co-prohibition: check on reference sequence
			node = updatedFxtResult.SelectSingleNode("//MoAlloAdhocProhib[@Id='" + alloAdHocOld.Hvo + "']");
			Assert.IsNotNull(node, "did not find old allo ad hoc rule");
			contentNode = node.SelectSingleNode("RestOfAllos");
			Assert.IsNotNull(contentNode, "missing RestOfAllos for old allo ad hoc rule");
			contentNode = contentNode.SelectSingleNode("@dst");
			Assert.IsNotNull(contentNode, "missing dst attribute of RestOfAllos for old allo ad hoc rule");
			Assert.AreEqual(affixAllomorph2.Hvo.ToString(), contentNode.InnerText, "RestOfAllos of old allo ad hoc rule differs");
			nodes = node.SelectNodes("RestOfAllos");
			Assert.AreEqual(1, nodes.Count, "count of RestOfAllos of old allo ad hoc rule differs");
			// check on integer change
			contentNode = node.SelectSingleNode("@Adjacency");
			Assert.AreEqual("2", contentNode.InnerText, "Adjacency differs");
			node =
				updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + alloAdHicOldFirstRestOfAllos.Hvo + "']");
			Assert.IsNotNull(node, "Original RestOfAllos allomorph should still be present");
			nodes = updatedFxtResult.SelectNodes("//MoAffixAllomorph[@Id='" + affixAllomorph2.Hvo + "']");
			Assert.AreEqual(1, nodes.Count, "Should only be one instance of new allomorph in RestOfAllos");


			// Test added productivity restriction: check on CmPossibilityList
			node = updatedFxtResult.SelectSingleNode("//ProdRestrict/CmPossibility");
			Assert.IsNotNull(node, "Did not find newly added productivity restriction");
			node = node.SelectSingleNode("Name");
			Assert.IsNotNull(node, "Expected Name node in productivity restrictioni");
			Assert.AreEqual(sNewProdRestrictName, node.InnerText, "name of productivity restriction differs");

			// Test phonological environment string representation: check on string
			node = updatedFxtResult.SelectSingleNode("//PhEnvironment[@Id='" + env.Hvo + "']/@StringRepresentation");
			Assert.AreEqual(ksEnvStringRep, node.InnerText, "phonological environment string differs");

			// Test adding a phonological environment string representation:
			// check on case where parent of owner has Id and is class name;
			// also check on case where there is a comment/text node within the result nodes
			node = updatedFxtResult.SelectSingleNode("//PhEnvironment[@Id='" + envNew.Hvo + "']");
			Assert.IsNotNull(node, "missing newly added phonological environment");
			nodes = updatedFxtResult.SelectNodes("//PhEnvironment");
			Assert.AreEqual(11, nodes.Count, "number of PhEnvironments differs");

			// Test Parser Parameters: check on unicode string
			node = updatedFxtResult.SelectSingleNode("//ParserParameters");
			string sResultParseParameters = node.OuterXml.Trim();
			Assert.AreEqual(sNewParserParameters, sResultParseParameters, "Parser Parameters content differs");

			// Test deletion of a lex entry: check on finding LexDb when there is no class LexDb in FXT file
			nodes = updatedFxtResult.SelectNodes("//LexEntry");
			Assert.AreEqual(61, nodes.Count, "number of LexEntries differs");
			node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + hvoEntryDeleted + "']");
			Assert.IsNull(node, "Deleted lex entry should be missing");
			foreach (int hvo in hvosEntryDeletedAlternateForms)
			{
				node = updatedFxtResult.SelectSingleNode("//MoStemAllomorph[@Id='" + hvo + "'] | //MoAffixAllomorph[@Id='" + hvo + "']");
				Assert.IsNull(node, "deleted entry's alternate form should also be gone");
			}
			foreach (int hvo in hvosEntryDeletedMSAs)
			{
				node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvo + "']");
				Assert.IsNull(node, "deleted entry's msa should also be gone");
			}
			foreach (int hvo in hvosEntryDeletedSenses)
			{
				node = updatedFxtResult.SelectSingleNode("//LexSense[@Id='" + hvo + "']");
				Assert.IsNull(node, "deleted entry's lexsense should also be gone");
			}
			node = updatedFxtResult.SelectSingleNode("//MoStemAllomorph[@Id='" + hvoEntryDeletedLexemeForm + "']");
			Assert.IsNull(node, "deleted entry's lexeme form should also be gone");

			// Test adding new entry
			node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + entryNew.Hvo + "']");
			Assert.IsNotNull(node, "new lex entry is missing");
			contentNode = node.SelectSingleNode("LexemeForm[@dst='" + alloNew.Hvo + "']");
			Assert.IsNotNull(contentNode, "missing lexeme form for new entry");
			contentNode = node.SelectSingleNode("AlternateForms[@dst='" + alloNew2.Hvo + "']");
			Assert.IsNotNull(contentNode, "missing alternate form in new lex entry");
			contentNode = node.SelectSingleNode("Sense[@dst='" + sense.Hvo + "']");
			Assert.IsNotNull(contentNode, "missing sense in new lex entry");
			contentNode = node.SelectSingleNode("MorphoSyntaxAnalysis[@dst='" + inflAffixMsa.Hvo + "']");
			Assert.IsNotNull(contentNode, "missing msa in new lex entry");
			contentNode = node.SelectSingleNode("AlternateForms[@dst='" + affRule.Hvo + "']");
			Assert.IsNotNull(contentNode, "missing affix process rule in new lex entry");

			node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + alloNew.Hvo + "']");
			Assert.IsNotNull(node, "new lexeme form affix allomorph for new lex entry is missing");
			contentNode = node.SelectSingleNode("@MorphType");
			Assert.IsNotNull(contentNode, "@MorphType missing for new MoAffixAllomorph in lexeme form of new lex entry");
			IMoMorphType typeNew = MoMorphType.CreateFromDBObject(Cache, Convert.ToInt32(contentNode.InnerText));
			string sGuidNew = typeNew.Guid.ToString();
			Assert.AreEqual(MoMorphType.kguidMorphPrefix, sGuidNew, "morph type wrong for new MoAffixAllomorph in lexeme form of new lex entry");
			contentNode = node.SelectSingleNode("Form");
			Assert.IsNotNull(contentNode, "Form missing for new MoAffixAllomorph in lexeme form new lex entry");
			Assert.AreEqual(sNewAlloForm, contentNode.InnerText, "form wrong for new MoAffixAllomorph in lexeme form of new lex entry");

			node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + alloNew2.Hvo + "']");
			Assert.IsNotNull(node, "new alternate form affix allomorph for new lex entry is missing");
			contentNode = node.SelectSingleNode("@MorphType");
			Assert.IsNotNull(contentNode, "@MorphType missing for new MoAffixAllomorph in alternate form of new lex entry");
			typeNew = MoMorphType.CreateFromDBObject(Cache, Convert.ToInt32(contentNode.InnerText));
			sGuidNew = typeNew.Guid.ToString();
			Assert.AreEqual(MoMorphType.kguidMorphPrefix, sGuidNew, "morph type wrong for new MoAffixAllomorph in lexeme form of new lex entry");
			contentNode = node.SelectSingleNode("Form");
			Assert.IsNotNull(contentNode, "Form missing for new MoAffixAllomorph in alternate form new lex entry");
			Assert.AreEqual(sNewAlloForm2, contentNode.InnerText, "form wrong for new MoAffixAllomorph in alternate form of new lex entry");

			node = updatedFxtResult.SelectSingleNode("//LexSense[@Id='" + sense.Hvo + "']");
			Assert.IsNotNull(node, "new sense for new lex entry is missing");
			contentNode = node.SelectSingleNode("Gloss");
			Assert.IsNotNull(contentNode, "Gloss missing for new LexSense in new lex entry");
			Assert.AreEqual(sGloss, contentNode.InnerText, "Gloss wrong for new LexSense in new lex entry");

			node = updatedFxtResult.SelectSingleNode("//MoInflAffMsa[@Id='" + inflAffixMsa.Hvo + "']");
			Assert.IsNotNull(node, "new infl affix msa for new lex entry is missing");
			contentNode = node.SelectSingleNode("@PartOfSpeech");
			Assert.IsNotNull(contentNode, "@PartOfSpeech missing for new MoInflAffMsa in new lex entry");
			Assert.AreEqual(hvoVerb.ToString(), contentNode.InnerText, "part of speech wrong for new MoInflAffMsa in new lex entry");
			contentNode = node.SelectSingleNode("Slots/@dst");
			Assert.IsNotNull(contentNode, "Slots missing for new MoInflAffMsa in new lex entry");
			Assert.AreEqual(hvoSlot.ToString(), contentNode.InnerText, "slot wrong for new MoInflAffMsa in new lex entry");

			// Test adding new template
			node = updatedFxtResult.SelectSingleNode("//MoInflAffixTemplate[@Id='" + affixTemplate.Hvo + "']");
			Assert.IsNotNull(node, "new affix template missing");
			node =
				updatedFxtResult.SelectSingleNode("//PartOfSpeech[@Id='" + hvoIntransVerb +
												  "']/AffixTemplates/MoInflAffixTemplate[@Id='" + affixTemplate.Hvo +
												  "']");
			Assert.IsNotNull(node, "new affix template is in intransitive verb");

			// Test adding new phonological feature
			node = updatedFxtResult.SelectSingleNode("//PhFeatureSystem/Features/FsClosedFeature[@Id='" + consFeat.Hvo + "']");
			Assert.IsNotNull(node, "new phonological feature is missing");
			contentNode = node.SelectSingleNode("Abbreviation");
			Assert.IsNotNull(contentNode, "Abbreviation missing from new phonological feature");
			Assert.AreEqual(contentNode.InnerText, consFeat.Abbreviation.AnalysisDefaultWritingSystem, "Abbreviation wrong for new phonological feature");
			nodes = node.SelectNodes("Values/FsSymFeatVal");
			Assert.IsNotNull(nodes, "values missing from new phonological feature");
			Assert.AreEqual(nodes.Count, 2, "incorrect number of values in new phonological feature");
			node = updatedFxtResult.SelectSingleNode("//PhFeatureSystem/Types/FsFeatStrucType/Features/Feature[@dst='" + consFeat.Hvo + "']");
			Assert.IsNotNull(node, "reference to new phonological feature is missing from phonological feature system");

			// Test adding new feature-based NC
			node = updatedFxtResult.SelectSingleNode("//PhNCFeatures[@Id='" + featNC.Hvo + "']");
			Assert.IsNotNull(node, "new feature-based NC is missing");
			contentNode = node.SelectSingleNode("Abbreviation");
			Assert.IsNotNull(contentNode, "Abbreviation missing from new feature-based NC");
			Assert.AreEqual(contentNode.InnerText, featNC.Abbreviation.AnalysisDefaultWritingSystem, "Abbreviation wrong for new feature-based NC");
			contentNode = node.SelectSingleNode("FsFeatStruc/FsClosedValue[@Id='" + val.Hvo + "']");
			Assert.IsNotNull(contentNode, "value missing from new feature-based NC");
			Assert.AreEqual((contentNode as XmlElement).GetAttribute("Feature"), consFeat.Hvo.ToString(), "closed value feature is wrong in new feature-based NC");
			Assert.AreEqual((contentNode as XmlElement).GetAttribute("Value"), consPlus.Hvo.ToString(), "closed value is wrong in new feature-based NC");

			// Test adding new phonological rule
			node = updatedFxtResult.SelectSingleNode("//PhRegularRule[@Id='" + regRule.Hvo + "']");
			Assert.IsNotNull(node, "new phonological rule is missing");
			nodes = node.SelectNodes("StrucDesc/*");
			Assert.AreEqual(nodes.Count, 0);
			contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/StrucChange/PhSimpleContextSeg[@dst='" + phoneme.Hvo + "']");
			Assert.IsNotNull(contentNode, "phoneme simple context missing in new phonological rule");
			contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/LeftContext/PhSimpleContextNC[@dst='" + featNC.Hvo + "']");
			Assert.IsNotNull(contentNode, "NC simple context missing in new phonological rule");

			// Test adding new morphological rule
			node = updatedFxtResult.SelectSingleNode("//Lexicon/Allomorphs/MoAffixProcess[@Id='" + affRule.Hvo + "']");
			Assert.IsNotNull(node, "new morphological rule is missing");
			contentNode = node.SelectSingleNode("Input/PhSimpleContextNC[@dst='" + featNC.Hvo + "']");
			Assert.IsNotNull(contentNode, "NC simple context missing in new morphological rule");
			contentNode = node.SelectSingleNode("Output/MoCopyFromInput/Content[@dst='" + ncCtxt.Hvo + "']");
			Assert.IsNotNull(contentNode, "copy from input missing in new morphological rule");

			// Modify a phonological rule
			segCtxt = new PhSimpleContextSeg();
			regRule.StrucDescOS.Append(segCtxt);
			segCtxt.FeatureStructureRA = phoneme;
			segCtxt.NotifyNew();
			regRule.RightHandSidesOS[0].StrucChangeOS[0].DeleteUnderlyingObject();
			IPhPhonContext oldCtxt = regRule.RightHandSidesOS[0].LeftContextOA;
			Cache.LangProject.PhonologicalDataOA.ContextsOS.Append(oldCtxt);
			IPhSequenceContext seqCtxt = new PhSequenceContext();
			regRule.RightHandSidesOS[0].LeftContextOA = seqCtxt;
			seqCtxt.MembersRS.Append(oldCtxt);
			seqCtxt.NotifyNew();
			IPhSimpleContextBdry bdryCtxt = new PhSimpleContextBdry();
			Cache.LangProject.PhonologicalDataOA.ContextsOS.Append(bdryCtxt);
			bdryCtxt.FeatureStructureRAHvo = Cache.GetIdFromGuid(LangProject.kguidPhRuleWordBdry);
			bdryCtxt.NotifyNew();
			seqCtxt.MembersRS.Append(bdryCtxt);

			// Modify a morphological rule
			entryNew.LexemeFormOA = affRule;
			IMoInsertPhones insertPhones = new MoInsertPhones();
			affRule.OutputOS.InsertAt(insertPhones, 0);
			insertPhones.ContentRS.Append(phoneme);
			insertPhones.NotifyNew();
			affRule.InputOS[1].DeleteUnderlyingObject();

			// change order of a sequence vector
			lexEntry.AlternateFormsOS.InsertAt(newAffixAllomorph, 0);

			updatedFxtResult = UpdateFXT();

			// Test modifying a phonological rule
			node = updatedFxtResult.SelectSingleNode("//PhRegularRule[@Id='" + regRule.Hvo + "']");
			contentNode = node.SelectSingleNode("StrucDesc/PhSimpleContextSeg[@dst='" + phoneme.Hvo + "']");
			Assert.IsNotNull(contentNode, "phoneme simple context missing from StrucDesc in modified phonological rule");
			contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/StrucChange/PhSimpleContextSeg[@dst='" + phoneme.Hvo + "']");
			Assert.IsNull(contentNode, "phoneme simple context is not missing from StrucChange in modified phonological rule");
			contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/LeftContext/PhSequenceContext[@Id='" + seqCtxt.Hvo + "']");
			Assert.IsNotNull(contentNode, "sequence context missing from modified phonological rule");
			contentNode = contentNode.SelectSingleNode("Members[@dst='" + bdryCtxt.Hvo + "']");
			Assert.IsNotNull(contentNode, "boundary context missing from sequence context in modified phonological rule");
			node = updatedFxtResult.SelectSingleNode("//PhPhonData/Contexts/PhSimpleContextBdry[@Id='" + bdryCtxt.Hvo + "']");
			Assert.IsNotNull(node, "boundary context missing from contexts in phonological data");

			// Test modifying a morphological rule
			node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + entryNew.Hvo + "']");
			contentNode = node.SelectSingleNode("LexemeForm[@dst='" + affRule.Hvo + "']");
			Assert.IsNotNull(contentNode, "affix process rule is not the lexeme form for the lex entry");
			node = updatedFxtResult.SelectSingleNode("//Lexicon/Allomorphs/MoAffixProcess[@Id='" + affRule.Hvo + "']");
			contentNode = node.SelectSingleNode("Input/PhSimpleContextNC[@dst='" + featNC.Hvo + "']");
			Assert.IsNull(contentNode, "NC simple context was not removed from morphological rule");
			nodes = node.SelectNodes("Output/*");
			Assert.AreEqual(nodes.Count, 2, "incorrect number of mappings in morphological rule");
			contentNode = node.SelectSingleNode("Output/*[position() = 1 and @Id='" + insertPhones.Hvo + "']");
			Assert.IsNotNull(contentNode, "insert phones missing from morphological rule");

			// Test changing order of a sequence vector
			node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + lexEntry.Hvo + "']");
			contentNode = node.SelectSingleNode("AlternateForms[@dst='" + lexEntry.AlternateFormsOS[0].Hvo + "']/@ord");
			Assert.AreEqual("0", contentNode.InnerText);
			contentNode = node.SelectSingleNode("AlternateForms[@dst='" + lexEntry.AlternateFormsOS[1].Hvo + "']/@ord");
			Assert.AreEqual("1", contentNode.InnerText);
			contentNode = node.SelectSingleNode("AlternateForms[@dst='" + lexEntry.AlternateFormsOS[2].Hvo + "']/@ord");
			Assert.AreEqual("2", contentNode.InnerText);
		}
Пример #8
0
		private void AddInflAffixMsaToSlot(int hvo, int slotHvo)
		{
			ICmObject obj = CmObject.CreateFromDBObject(Cache, hvo);
			IMoInflAffMsa inflMsa = obj as IMoInflAffMsa;
			if (inflMsa == null)
				return;
			ILexEntry lex = LexEntry.CreateFromDBObject(Cache, inflMsa.OwnerHVO);
			if (lex == null)
				return; // play it safe
			bool fMiamSet = false;  // assume we won't find an existing infl affix msa
			foreach (IMoMorphSynAnalysis msa in lex.MorphoSyntaxAnalysesOC)
			{
				if (msa.ClassID == MoInflAffMsa.kclsidMoInflAffMsa)
				{ // is an inflectional affix msa
					IMoInflAffMsa miam = (IMoInflAffMsa)msa;
					IPartOfSpeech pos = miam.PartOfSpeechRA;
					if (pos == null)
					{ // use the first unspecified one
						IMoInflAffixSlot slot = MoInflAffixSlot.CreateFromDBObject(Cache, slotHvo);
						miam.PartOfSpeechRAHvo = slot.OwnerHVO;
						miam.ClearAllSlots();  // just in case...
						miam.SlotsRC.Add(slotHvo);
						fMiamSet = true;
						break;
					}
					else if (pos.AllAffixSlotIDs.Contains(slotHvo))
					{ // if the slot is in this POS
						if (miam.SlotsRC.Count == 0)
						{ // use the first available
							miam.SlotsRC.Add(slotHvo);
							fMiamSet = true;
							break;
						}
						else if (miam.SlotsRC.Contains(slotHvo))
						{ // it is already set (probably done by the CreateEntry dialog process)
							fMiamSet = true;
							break;
						}
						else if (lex.IsCircumfix())
						{ // only circumfixes can more than one slot
							miam.SlotsRC.Add(slotHvo);
							fMiamSet = true;
							break;
						}
					}
				}
			}
			if (!fMiamSet)
			{  // need to create a new infl affix msa
				IMoInflAffMsa newMsa = new MoInflAffMsa();
				lex.MorphoSyntaxAnalysesOC.Add(newMsa);
				EnsureNewMsaHasSense(lex, newMsa);
				newMsa.SlotsRC.Add(slotHvo);
				IMoInflAffixSlot slot = MoInflAffixSlot.CreateFromDBObject(Cache, slotHvo);
				newMsa.PartOfSpeechRAHvo = slot.OwnerHVO;
			}
		}
Пример #9
0
		private ITsString DetermineMsaContextMenuItemLabel(string sLabel)
		{
			IMoInflAffMsa msa = new MoInflAffMsa(Cache, m_hvo);
			ITsString tss = DoYYYReplace(sLabel, msa.ShortNameTSS);
			ITsString tssSlotName = TsSlotNameOfMsa(msa);
			return DoXXXReplace(tss, tssSlotName);
		}