Exemplo n.º 1
0
        // TODO: This can now check sub-formation names
        /// <summary>
        /// There is a potential match based on the various formation names.
        /// </summary>
        /// <param name="location">The location.</param>
        /// <returns><c>true</c> if is a potential match based on the various formation names, <c>false</c> otherwise.</returns>
        private bool potentialMatchByName(Location location)
        {
            if (SubFormationName.Contains("Ericsson Crag #3") &&
                (location.Name.Contains("Ericsson Crag #3") || location.OtherName.Contains("Ericsson Crag #3")))
            {
                System.Console.WriteLine("FooBar");
            }

            // First check if any combination of one name contains the other
            if (eitherContainsOther(FormationName, location.Name) ||
                eitherContainsOther(FormationName, location.OtherName) ||
                eitherContainsOther(SubFormationName, location.Name) ||
                eitherContainsOther(SubFormationName, location.OtherName))
            {
                return(true);
            }

            // Next, redo the check with the names singular and made non-possessive
            string formationNameNormalized              = FormationName.ApplyToIndividualWords(singularNonPossessiveWord);
            string subFormationNameNormalized           = SubFormationName.ApplyToIndividualWords(singularNonPossessiveWord);
            string potentialLocationNameNormalized      = location.Name.ApplyToIndividualWords(singularNonPossessiveWord);
            string potentialLocationOtherNameNormalized = location.OtherName.ApplyToIndividualWords(singularNonPossessiveWord);

            return(eitherContainsOther(formationNameNormalized, potentialLocationNameNormalized) ||
                   eitherContainsOther(formationNameNormalized, potentialLocationOtherNameNormalized) ||
                   eitherContainsOther(subFormationNameNormalized, potentialLocationNameNormalized) ||
                   eitherContainsOther(subFormationNameNormalized, potentialLocationOtherNameNormalized));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check with the names singular and made non-possessive, with other tweaks for geographical name irregularities.
        /// </summary>
        /// <param name="formation">The formation.</param>
        /// <returns><c>true</c> if there is a match among any of the name combinations, <c>false</c> otherwise.</returns>
        private bool potentialMatchByNameNormalized(Formation formation)
        {
            string formationNameNormalized                  = FormationName.ApplyToIndividualWords(NormalizeGeographicName);
            string subFormationNameNormalized               = SubFormationName.ApplyToIndividualWords(NormalizeGeographicName);
            string potentialFormationNameNormalized         = formation.Name.ApplyToIndividualWords(NormalizeGeographicName);
            string potentialFormationOtherNameNormalized    = formation.OtherName.ApplyToIndividualWords(NormalizeGeographicName);
            string potentialSubFormationOtherNameNormalized = formation.SubFormationName.ApplyToIndividualWords(NormalizeGeographicName);

            return(eitherContainsOther(formationNameNormalized, potentialFormationNameNormalized) ||
                   eitherContainsOther(formationNameNormalized, potentialFormationOtherNameNormalized) ||
                   eitherContainsOther(formationNameNormalized, potentialSubFormationOtherNameNormalized) ||
                   eitherContainsOther(subFormationNameNormalized, potentialFormationNameNormalized) ||
                   eitherContainsOther(subFormationNameNormalized, potentialFormationOtherNameNormalized) ||
                   eitherContainsOther(subFormationNameNormalized, potentialSubFormationOtherNameNormalized));
        }