// This is specific for when we know we want to recognize one of us
        public static ProbableStrength DescribesOneOfUs(PhraseSense sense)
        {
            PhraseAttribute attr = sense.FindAttribute(typeof(GenderAttribute));

            if (attr != null && ((GenderAttribute)attr).gender == GenderOptions.OneOfUs)
            {
                return(ProbableStrength.Full);
            }
            return(ProbableStrength.Zero);
        }
Exemplo n.º 2
0
        public override ProbableStrength IsMatch(PhraseAttribute attribute)
        {
            if (attribute is PartOSAttribute)
            {
                PartOSAttribute partosAttribute = (PartOSAttribute)attribute;
                return(partosAttribute.part.SeemsA(part, false));
            }

            return(ProbableStrength.None);
        }
        // Add (returns true) or update (returns false) an attribute
        public bool AddOrUpdateAttribute(PhraseAttribute attr)
        {
            for (int ii = 0; ii < attributes.Count; ii++)
            {
                if (attributes[ii].GetType() == attr.GetType())
                {
                    attributes[ii] = attr;
                    return(false);
                }
            }

            attributes.Add(attr);
            return(true);
        }
        public override ProbableStrength IsMatch(PhraseAttribute attribute)
        {
            if (attribute is NumberAttribute)
            {
                NumberAttribute numberAttribute = (NumberAttribute)attribute;
                if (numberAttribute.number == number)
                    return ProbableStrength.Full;
                else if (numberAttribute.number == NumberOptions.Zero || number == NumberOptions.Zero)
                    return ProbableStrength.Half;
                else
                    return ProbableStrength.Zero;
            }

            return ProbableStrength.None;
        }
        public static List <PhraseAttribute> OverrideAttributes(PhraseSense sense, List <PhraseAttribute> attrs)
        {
            if (sense == null)
            {
                return(attrs);
            }

            foreach (PhraseAttribute attr in attrs)
            {
                PhraseAttribute already = sense.FindAttribute(attr.GetType());
                sense.Attributes.Remove(already);
                sense.Attributes.Add(attr);
            }

            return(sense.Attributes);
        }
        // Does this attribute conform to ours?
        public override ProbableStrength IsMatch(PhraseAttribute attribute)
        {
            if (attribute is GenderAttribute)
            {
                // It's a gender attribute-- it might!
                GenderAttribute genderAttribute = (GenderAttribute)attribute;
                if (genderAttribute.gender == gender)
                {
                    return(ProbableStrength.Full);   // perfect match
                }
                else if (gender == GenderOptions.OneOfUs || genderAttribute.gender == GenderOptions.OneOfUs)
                {
                    return(ProbableStrength.Zero);   // nothing matches us! (for now)
                }
                else if ((genderAttribute.gender == GenderOptions.Male && gender == GenderOptions.Female) ||
                         (genderAttribute.gender == GenderOptions.Female && gender == GenderOptions.Male))
                {
                    return(ProbableStrength.Zero);   // male != female
                }
                else if ((genderAttribute.gender == GenderOptions.Human && (gender == GenderOptions.Male || gender == GenderOptions.Female)) ||
                         (gender == GenderOptions.Human && (genderAttribute.gender == GenderOptions.Male || genderAttribute.gender == GenderOptions.Female)))
                {
                    return(ProbableStrength.Full);   // human matches male or female
                }
                else if ((genderAttribute.gender == GenderOptions.Human && gender == GenderOptions.Neuter) ||
                         (gender == GenderOptions.Human && genderAttribute.gender == GenderOptions.Neuter))
                {
                    return(ProbableStrength.Zero);   // human doesn't match neuter
                }
                else
                {
                    // one or the other is neuter
                    return(ProbableStrength.Half);   // neuter attribute is applied only as a suggestion
                }
            }

            return(ProbableStrength.None);
        }
 // Wrapper on IsMatch to apply the weighting
 public ProbableStrength Match(PhraseAttribute attribute)
 {
     ProbableStrength match = IsMatch(attribute);
     return new ProbableStrength(match.strength, match.weight * (strength.weight + attribute.strength.weight) / 2.0);
 }
 // Does this attribute match the other?  Override this!
 public virtual ProbableStrength IsMatch(PhraseAttribute attribute)
 {
     return ProbableStrength.None;
 }
        public override ProbableStrength IsMatch(PhraseAttribute attribute)
        {
            if (attribute is NumberAttribute)
            {
                NumberAttribute numberAttribute = (NumberAttribute)attribute;
                if (numberAttribute.number == number)
                    return ProbableStrength.Full;
                else if (numberAttribute.number == NumberOptions.Zero || number == NumberOptions.Zero)
                    return ProbableStrength.Half;
                else
                    return ProbableStrength.Zero;
            }

            return ProbableStrength.None;
        }
Exemplo n.º 10
0
        // Add (returns true) or update (returns false) an attribute
        public bool AddOrUpdateAttribute(PhraseAttribute attr)
        {
            for (int ii = 0; ii < attributes.Count; ii++)
                if (attributes[ii].GetType() == attr.GetType()) {
                    attributes[ii] = attr;
                    return false;
                }

            attributes.Add(attr);
            return true;
        }
 // Does this attribute match the other?  Override this!
 public virtual ProbableStrength IsMatch(PhraseAttribute attribute)
 {
     return(ProbableStrength.None);
 }
        // Wrapper on IsMatch to apply the weighting
        public ProbableStrength Match(PhraseAttribute attribute)
        {
            ProbableStrength match = IsMatch(attribute);

            return(new ProbableStrength(match.strength, match.weight * (strength.weight + attribute.strength.weight) / 2.0));
        }
Exemplo n.º 13
0
        // Does this attribute conform to ours?
        public override ProbableStrength IsMatch(PhraseAttribute attribute)
        {
            if (attribute is GenderAttribute)
            {
                // It's a gender attribute-- it might!
                GenderAttribute genderAttribute = (GenderAttribute)attribute;
                if (genderAttribute.gender == gender)
                    return ProbableStrength.Full;   // perfect match
                else if (gender == GenderOptions.OneOfUs || genderAttribute.gender == GenderOptions.OneOfUs)
                    return ProbableStrength.Zero;   // nothing matches us! (for now)
                else if ((genderAttribute.gender == GenderOptions.Male && gender == GenderOptions.Female) ||
                         (genderAttribute.gender == GenderOptions.Female && gender == GenderOptions.Male))
                    return ProbableStrength.Zero;   // male != female
                else if ((genderAttribute.gender == GenderOptions.Human && (gender == GenderOptions.Male || gender == GenderOptions.Female)) ||
                         (gender == GenderOptions.Human && (genderAttribute.gender == GenderOptions.Male || genderAttribute.gender == GenderOptions.Female)))
                    return ProbableStrength.Full;   // human matches male or female
                else if ((genderAttribute.gender == GenderOptions.Human && gender == GenderOptions.Neuter) ||
                         (gender == GenderOptions.Human && genderAttribute.gender == GenderOptions.Neuter))
                    return ProbableStrength.Zero;   // human doesn't match neuter
                else
                    // one or the other is neuter
                    return ProbableStrength.Half;   // neuter attribute is applied only as a suggestion
            }

            return ProbableStrength.None;
        }
Exemplo n.º 14
0
        public override ProbableStrength IsMatch(PhraseAttribute attribute)
        {
            if (attribute is PartOSAttribute)
            {
                PartOSAttribute partosAttribute = (PartOSAttribute)attribute;
                return partosAttribute.part.SeemsA(part, false);
            }

            return ProbableStrength.None;
        }