public List <SheetSoulbreaks> GetSoulbreaksByCharacterName(string tier, string name, int?index = null)
        {
            var charNames = dbContext.Characters.Select(x => x.Name.ToLower());

            name = aliases.ResolveAlias(name);

            if (!charNames.Contains(name.ToLower()))
            {
                name = charNames.OrderByDescending(x => Fuzz.PartialRatio(x, name.ToLower())).FirstOrDefault();
            }

            List <SheetSoulbreaks> soulbreaks = new List <SheetSoulbreaks>();

            if (tier == "g")
            {
                soulbreaks = dbContext.Soulbreaks.Where(x => (x.Character.ToLower() == name.ToLower() || x.SoulbreakId == name) && (x.Tier == "Glint" || x.Tier == "Glint+")).ToList();
            }
            else if (tier == "brave")
            {
                soulbreaks = dbContext.Soulbreaks.Where(x => (x.Character.ToLower() == name.ToLower() || x.SoulbreakId == name) && x.Effects.Contains("[Brave Mode]")).ToList();
            }
            else
            {
                soulbreaks = dbContext.Soulbreaks.Where(x => (x.Character.ToLower() == name.ToLower() || x.SoulbreakId == name) && x.Tier == tier).ToList();
            }

            if (index != null)
            {
                return(soulbreaks.Where(x => x.SoulbreakVersion.EndsWith(index.ToString())).ToList());
            }

            return(soulbreaks);
        }
        public double GetSimilarPoints(Trip source, Trip other)
        {
            double points = 0;

            // Same tour type
            if (source.Tour.Type == other.Tour.Type)
            {
                points += 75;
            }

            // Same start place and/or destination
            if (Fuzz.PartialRatio(source.Tour.StartPlace, other.Tour.StartPlace) >= 85)
            {
                points += 50;
            }
            if (Fuzz.PartialRatio(source.Tour.Destination, other.Tour.Destination) >= 85)
            {
                points += 50;
            }

            // Similar Price
            points -= Convert.ToDouble(Math.Abs(source.GetSalePrice() - other.GetSalePrice()));

            // Similar Start Time and End Time
            points += 25 - (source.StartTime - other.StartTime).TotalDays;
            points += 25 - (source.EndTime - other.EndTime).TotalDays;

            // Similar Description
            points += Fuzz.TokenSetRatio(source.Tour.Description, other.Tour.Description) * .25;

            return(points);
        }
        public List <SheetLegendMaterias> GetLegendMateriasByCharName(string name)
        {
            var charNames   = dbContext.Characters.Select(x => x.Name.ToLower());
            var materiaName = dbContext.LegendMaterias.Select(x => x.Name.ToLower()).FirstOrDefault(x => x == name.ToLower());
            var jpName      = dbContext.LegendMaterias.FirstOrDefault(x => x.JPName == name);

            if (materiaName == null && jpName == null)
            {
                name = aliases.ResolveAlias(name);

                if (!charNames.Contains(name.ToLower()))
                {
                    name = charNames.OrderByDescending(x => Fuzz.PartialRatio(x, name.ToLower())).FirstOrDefault();
                }
            }

            if (jpName != null)
            {
                return(new List <SheetLegendMaterias>()
                {
                    jpName
                });
            }

            var legendMaterias = dbContext.LegendMaterias.Where(x => x.Character.ToLower() == name.ToLower() || x.Name.ToLower() == name.ToLower() || name == x.JPName).ToList();

            return(legendMaterias);
        }
        public UniqueEquipment GetUniqueEquipmentByCharacterName(string name)
        {
            name = aliases.ResolveAlias(name);

            var character = dbContext.Characters.FirstOrDefault(x => x.Name.ToLower() == name.ToLower());

            if (character == null)
            {
                character = dbContext.Characters.OrderByDescending(x => Fuzz.PartialRatio(x.Name.ToLower(), name.ToLower())).FirstOrDefault();
            }

            var sheetUniques   = dbContext.UniqueEquipment.Where(x => x.Character == character.Name);
            var sheetUniqueSet = dbContext.UniqueEquipmentSets.FirstOrDefault(x => x.Character == character.Name);
            var uniqueEquip    = new UniqueEquipment
            {
                UniqueEquipments = sheetUniques.Select(x => new UniqueEquip {
                    Info = x
                }).ToList(),
                UniqueEquipmentSets = new UniqueEquipmentSet {
                    Info = sheetUniqueSet
                },
                CharacterUrl = character.CharacterImage
            };

            return(uniqueEquip);
        }
Exemple #5
0
 public void TestEmptyStringsScore0()
 {
     Assert.That(Fuzz.Ratio("test_string", ""), Is.EqualTo(0));
     Assert.That(Fuzz.PartialRatio("test_string", ""), Is.EqualTo(0));
     Assert.That(Fuzz.Ratio("", ""), Is.EqualTo(0));
     Assert.That(Fuzz.PartialRatio("", ""), Is.EqualTo(0));
 }
Exemple #6
0
        public void TestPartialRatioUnicodeString()
        {
            _s1 = "\u00C1";
            _s2 = "ABCD";
            var score = Fuzz.PartialRatio(_s1, _s2);

            Assert.AreEqual(0, score);
        }
        public void Evaluate()
        {
            var a1 = Fuzz.Ratio("mysmilarstring", "myawfullysimilarstirng");
            var a2 = Fuzz.Ratio("mysmilarstring", "mysimilarstring");

            var b1 = Fuzz.PartialRatio("similar", "somewhresimlrbetweenthisstring");

            var c1 = Fuzz.TokenSortRatio("order words out of", "  words out of order");
            var c2 = Fuzz.PartialTokenSortRatio("order words out of", "  words out of order");

            var d1 = Fuzz.TokenSetRatio("fuzzy was a bear", "fuzzy fuzzy fuzzy bear");
            var d2 = Fuzz.PartialTokenSetRatio("fuzzy was a bear", "fuzzy fuzzy fuzzy bear");

            var e1 = Fuzz.WeightedRatio("The quick brown fox jimps ofver the small lazy dog", "the quick brown fox jumps over the small lazy dog");

            var f1 = Fuzz.TokenInitialismRatio("NASA", "National Aeronautics and Space Administration");
            var f2 = Fuzz.TokenInitialismRatio("NASA", "National Aeronautics Space Administration");

            var f3 = Fuzz.TokenInitialismRatio("NASA", "National Aeronautics Space Administration, Kennedy Space Center, Cape Canaveral, Florida 32899");
            var f4 = Fuzz.PartialTokenInitialismRatio("NASA", "National Aeronautics Space Administration, Kennedy Space Center, Cape Canaveral, Florida 32899");

            var g1 = Fuzz.TokenAbbreviationRatio("bl 420", "Baseline section 420", PreprocessMode.Full);
            var g2 = Fuzz.PartialTokenAbbreviationRatio("bl 420", "Baseline section 420", PreprocessMode.Full);



            var h1 = Process.ExtractOne("cowboys", new[] { "Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys" });
            var h2 = string.Join(", ", Process.ExtractTop("goolge", new[] { "google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl" }, limit: 3));
            var h3 = string.Join(", ", Process.ExtractAll("goolge", new [] { "google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl" }));
            var h4 = string.Join(", ", Process.ExtractAll("goolge", new[] { "google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl" }, cutoff: 40));
            var h5 = string.Join(", ", Process.ExtractSorted("goolge", new [] { "google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl" }));

            var i1 = Process.ExtractOne("cowboys", new[] { "Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys" }, s => s, ScorerCache.Get <DefaultRatioScorer>());

            var events = new[]
            {
                new[] { "chicago cubs vs new york mets", "CitiField", "2011-05-11", "8pm" },
                new[] { "new york yankees vs boston red sox", "Fenway Park", "2011-05-11", "8pm" },
                new[] { "atlanta braves vs pittsburgh pirates", "PNC Park", "2011-05-11", "8pm" },
            };
            var query = new[] { "new york mets vs chicago cubs", "CitiField", "2017-03-19", "8pm" };

            var best = Process.ExtractOne(query, events, strings => strings[0]);

            var ratio                    = ScorerCache.Get <DefaultRatioScorer>();
            var partial                  = ScorerCache.Get <PartialRatioScorer>();
            var tokenSet                 = ScorerCache.Get <TokenSetScorer>();
            var partialTokenSet          = ScorerCache.Get <PartialTokenSetScorer>();
            var tokenSort                = ScorerCache.Get <TokenSortScorer>();
            var partialTokenSort         = ScorerCache.Get <PartialTokenSortScorer>();
            var tokenAbbreviation        = ScorerCache.Get <TokenAbbreviationScorer>();
            var partialTokenAbbreviation = ScorerCache.Get <PartialTokenAbbreviationScorer>();
            var weighted                 = ScorerCache.Get <WeightedRatioScorer>();
        }
Exemple #8
0
        public void TestIssueSeven()
        {
            _s1 = "HSINCHUANG";
            _s2 = "SINJHUAN";
            _s3 = "LSINJHUANG DISTRIC";
            _s4 = "SINJHUANG DISTRICT";

            Assert.IsTrue(Fuzz.PartialRatio(_s1, _s2) > 75);
            Assert.IsTrue(Fuzz.PartialRatio(_s1, _s3) > 75);
            Assert.IsTrue(Fuzz.PartialRatio(_s1, _s4) > 75);
        }
Exemple #9
0
        public void TestIssueEight()
        {
            // https://github.com/JakeBayer/FuzzySharp/issues/8
            Assert.AreEqual(100, Fuzz.PartialRatio("Partnernummer", "Partne\nrnum\nmerASDFPartnernummerASDF")); // was 85
            Assert.AreEqual(100, Fuzz.PartialRatio("Partnernummer", "PartnerrrrnummerASDFPartnernummerASDF"));  // was 77

            // https://github.com/xdrop/fuzzywuzzy/issues/39
            Assert.AreEqual(100, Fuzz.PartialRatio("kaution", "kdeffxxxiban:de1110010060046666666datum:16.11.17zeit:01:12uft0000899999tan076601testd.-20-maisonette-z4-jobas-hagkautionauszug")); // was 57

            // https://github.com/seatgeek/fuzzywuzzy/issues/79
            Assert.AreEqual(100, Fuzz.PartialRatio("this is a test", "is this is a not really thing this is a test!")); // was 92 (actually 93)
        }
        public SheetCharacters GetCharacterByName(string name)
        {
            name = aliases.ResolveAlias(name);

            var character = dbContext.Characters.FirstOrDefault(x => x.Name.ToLower() == name.ToLower());

            if (character == null)
            {
                character = dbContext.Characters.OrderByDescending(x => Fuzz.PartialRatio(x.Name.ToLower(), name.ToLower())).FirstOrDefault();
            }

            return(character);
        }
        public SheetStatus GetStatusByName(string name)
        {
            name = aliases.ResolveAlias(name);

            var status = dbContext.Statuses.FirstOrDefault(x => x.Name.ToLower() == name.ToLower() || x.StatusId == name);

            if (status == null)
            {
                status = dbContext.Statuses.OrderByDescending(x => Fuzz.PartialRatio(x.Name.ToLower(), name.ToLower())).FirstOrDefault();
            }

            return(status);
        }
Exemple #12
0
        public SheetMagicites GetMagiciteByName(string name)
        {
            name = aliases.ResolveAlias(name);

            var magicite = dbContext.Magicites.FirstOrDefault(x => x.Name.ToLower() == name.ToLower() || x.JPName == name);

            if (magicite == null)
            {
                magicite = dbContext.Magicites.OrderByDescending(x => Fuzz.PartialRatio(x.Name.ToLower(), name.ToLower())).FirstOrDefault();
            }

            return(magicite);
        }
        public List <SheetSoulbreaks> GetAllSoulbreaksByCharacterName(string name)
        {
            var charNames = dbContext.Characters.Select(x => x.Name.ToLower());

            name = aliases.ResolveAlias(name);

            if (!charNames.Contains(name.ToLower()))
            {
                name = charNames.OrderByDescending(x => Fuzz.PartialRatio(x, name.ToLower())).FirstOrDefault();
            }

            var soulbreaks = dbContext.Soulbreaks.Where(x => x.Character.ToLower() == name.ToLower() && x.Tier != "RW").ToList();

            return(soulbreaks);
        }
Exemple #14
0
        public SheetAbilities GetAbilityByName(string name)
        {
            if (aliases.AliasList.ContainsKey(name.ToLower()))
            {
                name = aliases.AliasList[name.ToLower()];
            }

            var ability = dbContext.Abilities.FirstOrDefault(x => x.Name.ToLower() == name.ToLower() || x.JPName == name || x.ID == name);

            if (ability == null)
            {
                ability = dbContext.Abilities.OrderByDescending(x => Fuzz.PartialRatio(x.Name.ToLower(), name.ToLower())).FirstOrDefault();
            }

            return(ability);
        }
        public SheetLegendSpheres GetCharacterLegendSpereByName(string name, bool exact = false)
        {
            if (aliases.AliasList.ContainsKey(name.ToLower()))
            {
                name = aliases.AliasList[name.ToLower()];
            }

            var legendSphere = dbContext.LegendSpheres.FirstOrDefault(x => x.Character.ToLower() == name.ToLower());

            if (legendSphere == null && !exact)
            {
                legendSphere = dbContext.LegendSpheres.OrderByDescending(x => Fuzz.PartialRatio(x.Character.ToLower(), name.ToLower())).FirstOrDefault();
            }

            return(legendSphere);
        }
Exemple #16
0
        public List <SheetAbilities> GetHeroAbilityByCharacterName(string name)
        {
            var charNames = dbContext.Characters.Select(x => x.Name.ToLower());

            if (aliases.AliasList.ContainsKey(name.ToLower()))
            {
                name = aliases.AliasList[name.ToLower()];
            }
            else if (!charNames.Contains(name.ToLower()))
            {
                name = charNames.OrderByDescending(x => Fuzz.PartialRatio(x, name.ToLower())).FirstOrDefault();
            }

            var ability = dbContext.Abilities.Where(x => x.Name.ToLower().Contains($"({name.ToLower()} only)")).ToList();

            return(ability);
        }
        public SheetRecordBoards GetRecordBoardByCharacterName(string name)
        {
            var charNames = dbContext.Characters.Select(x => x.Name.ToLower());

            if (aliases.AliasList.ContainsKey(name.ToLower()))
            {
                name = aliases.AliasList[name.ToLower()];
            }
            else if (!charNames.Contains(name.ToLower()))
            {
                name = charNames.OrderByDescending(x => Fuzz.PartialRatio(x, name.ToLower())).FirstOrDefault();
            }

            var recordBoards = dbContext.RecordBoards.FirstOrDefault(x => x.Character.ToLower() == name.ToLower());

            return(recordBoards);
        }
        public SheetLegendSpheres GetLegendDiveByCharacterName(string name)
        {
            var charNames = dbContext.Characters.Select(x => x.Name.ToLower());

            if (aliases.AliasList.ContainsKey(name.ToLower()))
            {
                name = aliases.AliasList[name.ToLower()];
            }
            else if (!charNames.Contains(name.ToLower()))
            {
                name = charNames.OrderByDescending(x => Fuzz.PartialRatio(x, name.ToLower())).FirstOrDefault();
            }

            var legendDive = dbContext.LegendSpheres.FirstOrDefault(x => x.Character.ToLower() == name.ToLower());

            return(legendDive);
        }
        public override double Score(string input1, string input2)
        {
            int len1 = input1.Length;
            int len2 = input2.Length;

            if (len1 == 0 || len2 == 0)
            {
                return(0);
            }

            bool   tryPartials  = TRY_PARTIALS;
            double unbaseScale  = UNBASE_SCALE;
            double partialScale = PARTIAL_SCALE;

            double baseRatio = Fuzz.Ratio(input1, input2);
            double lenRatio  = ((double)Math.Max(len1, len2)) / Math.Min(len1, len2);

            // if strings are similar length don't use partials
            if (lenRatio < 1.5)
            {
                tryPartials = false;
            }

            // if one string is much shorter than the other
            if (lenRatio > 8)
            {
                partialScale = .6;
            }

            if (tryPartials)
            {
                double partial    = Fuzz.PartialRatio(input1, input2) * partialScale;
                double partialSor = Fuzz.TokenSortRatio(input1, input2) * unbaseScale * partialScale;
                double partialSet = Fuzz.TokenSetRatio(input1, input2) * unbaseScale * partialScale;

                return((double)Math.Round(new[] { baseRatio, partial, partialSor, partialSet }.Max()));
            }
            else
            {
                double tokenSort = Fuzz.TokenSortRatio(input1, input2) * unbaseScale;
                double tokenSet  = Fuzz.TokenSetRatio(input1, input2) * unbaseScale;

                return((double)Math.Round(new[] { baseRatio, tokenSort, tokenSet }.Max()));
            }
        }
Exemple #20
0
        public static Tuple <string, int> GetTopMatchedPostCode(string actualInstructionAddress, string expectedAddress)
        {
            var expectedAddressArray = expectedAddress.Split('\n');
            var max   = 0;
            var final = string.Empty;

            foreach (var item in expectedAddressArray)
            {
                var ratio = Fuzz.PartialRatio(actualInstructionAddress, item);

                if (max < ratio)
                {
                    final = item;
                    max   = ratio;
                }
                //Console.WriteLine($"{item} Ratio is  {ratio}.");
            }
            Console.WriteLine(string.Format("Result  {0} - final Ratio is  {1}.", final, max));
            return(new Tuple <string, int>(final, max));
        }
        public List <SheetLimitBreaks> GetLimitBreaksByCharacterNameAndTier(string tier, string name, int?index = null)
        {
            var charNames = dbContext.Characters.Select(x => x.Name.ToLower());

            if (aliases.AliasList.ContainsKey(name.ToLower()))
            {
                name = aliases.AliasList[name.ToLower()];
            }
            else if (!charNames.Contains(name.ToLower()))
            {
                name = charNames.OrderByDescending(x => Fuzz.PartialRatio(x, name.ToLower())).FirstOrDefault();
            }

            List <SheetLimitBreaks> limits = new List <SheetLimitBreaks>();

            if (tier == null)
            {
                limits = dbContext.LimitBreaks.Where(x => (x.Character.ToLower() == name.ToLower() || x.ID == name) && (x.Tier == "LBO" || x.Tier == "LBG" || x.Tier == "LBGS" || x.Tier == "LBC")).ToList();
            }
            else
            {
                limits = dbContext.LimitBreaks.Where(x => (x.Character.ToLower() == name.ToLower() || x.ID == name) && x.Tier == tier).ToList();
            }

            if (index != null)
            {
                if (index.Value < limits.Count() && index > -1)
                {
                    return(new List <SheetLimitBreaks>()
                    {
                        limits[index.Value]
                    });
                }
            }

            return(limits);
        }
Exemple #22
0
        public int ParialRatio(string input1, string input2)
        {
            var f = Fuzz.PartialRatio(input1, input2);

            return(f);
        }
Exemple #23
0
 private static bool GetLogEntryStringMatch(LogEntry logEntry, string str)
 {
     return(Fuzz.PartialRatio(str, logEntry.str) > 80 || Fuzz.PartialRatio(str, logEntry.stackTrace.ToString()) > 90);
 }
Exemple #24
0
 public void TestEmptyStringsScore100()
 {
     Assert.AreEqual(Fuzz.Ratio("", ""), 100);
     Assert.AreEqual(Fuzz.PartialRatio("", ""), 100);
 }
Exemple #25
0
 public void Test_Partial()
 {
     Assert.AreEqual(Fuzz.PartialRatio(_s1, _s3), 100);
 }