Пример #1
0
		/// <summary>
		/// Override the inherited method to check the StringRepresentation property.
		/// </summary>
		/// <param name="flidToCheck">flid to check, or zero, for don't care about the flid.</param>
		/// <param name="failure">an explanation of what constraint failed, if any. Will be null if the method returns true.</param>
		/// <returns>true, if StringRepresentation is valid, otherwise false.</returns>
		public override bool CheckConstraints(int flidToCheck, out ConstraintFailure failure)
		{
			return CheckConstraints(flidToCheck, out failure, /* do not adjust squiggly line */ false);
		}
Пример #2
0
		/// <summary>
		/// Check the validity of the environemtn string, create a problem report, and
		/// if asked, adjust the string itself to show the validity
		/// </summary>
		/// <param name="flidToCheck">flid to check, or zero, for don't care about the flid.</param>
		/// <param name="failure">an explanation of what constraint failed, if any. Will be null if the method returns true.</param>
		/// <param name="fAdjustSquiggly">whether or not to adjust the string squiggly line</param>
		/// <returns>true, if StringRepresentation is valid, otherwise false.</returns>
		public bool CheckConstraints(int flidToCheck, out ConstraintFailure failure, bool fAdjustSquiggly)
		{
			failure = null;
			bool isValid = true;
			if (flidToCheck == 0
				|| flidToCheck == (int)PhEnvironment.PhEnvironmentTags.kflidStringRepresentation)
			{
				CmBaseAnnotation.RemoveErrorAnnotationsForObject(m_cache, Hvo);
				PhonEnvRecognizer rec = new PhonEnvRecognizer(PhPhoneme.PhonemeRepresentations(m_cache), PhNaturalClass.ClassAbbreviations(m_cache));
				TsStringAccessor strAcc = StringRepresentation;
				ITsString tss = strAcc.UnderlyingTsString;
				ITsStrBldr bldr = tss.GetBldr();
				string strRep = tss.Text;
				if (rec.Recognize(strRep))
				{
					if (fAdjustSquiggly)
					{
						// ClearSquigglyLine
						bldr.SetIntPropValues(0, tss.Length, (int)FwTextPropType.ktptUnderline,
							(int)FwTextPropVar.ktpvEnum, (int)FwUnderlineType.kuntNone);
					}
				}
				else
				{
					int pos;
					string sMessage;
					CreateErrorMessageFromXml(strRep, rec.ErrorMessage, out pos, out sMessage);

					failure = new ConstraintFailure(this, (int)PhEnvironment.PhEnvironmentTags.kflidStringRepresentation,
						sMessage);
					failure.XmlDescription = rec.ErrorMessage;
					if (fAdjustSquiggly)
					{
						// MakeSquigglyLine

						Color col = Color.Red;
						int len = tss.Length;
						bldr.SetIntPropValues(pos, len, (int)FwTextPropType.ktptUnderline,
							(int)FwTextPropVar.ktpvEnum, (int)FwUnderlineType.kuntSquiggle);
						bldr.SetIntPropValues(pos, len, (int)FwTextPropType.ktptUnderColor,
							(int)FwTextPropVar.ktpvDefault, col.R + (col.B * 256 + col.G) * 256);
					}
					isValid = false;
				}
				if (fAdjustSquiggly)
					strAcc.UnderlyingTsString = bldr.GetString();
			}
			return isValid;
		}
Пример #3
0
		/// <summary>
		/// Override the inherited method to check that there are at least two allomorphs referred to
		/// </summary>
		/// <param name="flidToCheck">flid to check, or zero, for don't care about the flid.</param>
		/// <param name="failure">an explanation of what constraint failed, if any. Will be null if the method returns true.</param>
		/// <returns>true, if there are at least two morphemes, otherwise false.</returns>
		public override bool CheckConstraints(int flidToCheck, out ConstraintFailure failure)
		{
			CmBaseAnnotation.RemoveErrorAnnotationsForObject(m_cache, Hvo);
			failure = null;
			bool isValid = (FirstMorphemeRA != null) && (RestOfMorphsRS.Count >= 1);
			if (!isValid)
			{
				failure = new ConstraintFailure(this,
					(int)MoMorphAdhocProhib.MoMorphAdhocProhibTags.kflidMorphemes,
					Strings.ksMorphConstraintFailure);
				return false;

				//				CmBaseAnnotation ann = (CmBaseAnnotation)m_cache.LangProject.AnnotationsOC.Add(new CmBaseAnnotation());
				//				ann.CompDetails = "Need to have at least two morphemes chosen";
				//				ann.InstanceOfRAHvo = Hvo;
				//				ann.BeginObjectRA = this;
				//				ann.Flid = (int)BaseMoMorphAdhocProhib.MoMorphAdhocProhibTags.kflidMorphemes;
				// REVIEW JohnH(AndyB): Does this need an agent or type?
				// ann.SourceRAHvo = m_agentId;
			}
			return isValid;
		}
Пример #4
0
		/// <summary>
		/// Override the inherited method to check that there are at least two allomorphs referred to
		/// </summary>
		/// <param name="flidToCheck">flid to check, or zero, for don't care about the flid.</param>
		/// <param name="failure">an explanation of what constraint failed, if any. Will be null if the method returns true.</param>
		/// <returns>true, if there are at least two allomorphs, otherwise false.</returns>
		public override bool CheckConstraints(int flidToCheck, out ConstraintFailure failure)
		{
			CmBaseAnnotation.RemoveErrorAnnotationsForObject(m_cache, Hvo);

			bool isValid = (FirstAllomorphRA != null) && (RestOfAllosRS.Count >= 1);
			if (!isValid)
			{
				failure = new ConstraintFailure(this, (int)MoAlloAdhocProhib.MoAlloAdhocProhibTags.kflidAllomorphs,
					Strings.ksAlloConstraintFailure);
				//
				//				CmBaseAnnotation ann = (CmBaseAnnotation)m_cache.LangProject.AnnotationsOC.Add(new CmBaseAnnotation());
				//				ann.CompDetails = "Need to have at least two allomorphs selected";
				//				ann.InstanceOfRAHvo = Hvo;
				//				ann.BeginObjectRA = this;
				//				ann.Flid = (int)BaseMoAlloAdhocProhib.MoAlloAdhocProhibTags.kflidAllomorphs;
				//				obj = ann;
				// REVIEW JohnH(AndyB): Does this need an agent or type?
				// ann.SourceRAHvo = m_agentId;

				return false;
			}
			else
			{
				failure = null;
				return true;
			}
		}
Пример #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine if the object satisfies constraints imposed by the class
		/// </summary>
		/// <param name="flidToCheck">flid to check, or zero, for don't care about the flid.</param>
		/// <param name="failure">an explanation of what constraint failed, if any. Will be null if the method returns true.</param>
		/// <returns>true if the object is all right</returns>
		/// ------------------------------------------------------------------------------------
		public virtual bool CheckConstraints(int flidToCheck, out ConstraintFailure failure)
		{
			failure = null;
			return true;
		}