Пример #1
0
        public void IsPluralShouldCheckNormalWords()
        {
            var plurally = new Pluralizer();

            Assert.Equal(true, plurally.IsPlural("Tests"));
            Assert.Equal(false, plurally.IsPlural("Test"));
        }
Пример #2
0
        public void IsPluralShouldCheckSpecialWords()
        {
            var plurally = new Pluralizer();

            Assert.Equal(true, plurally.IsPlural("brothers"));
            Assert.Equal(true, plurally.IsPlural("brethren"));
            Assert.Equal(false, plurally.IsPlural("brother"));
        }
Пример #3
0
        public void IsPlural_ReturnsValidResponse()
        {
            var input = Resources.InputData.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var line in input)
            {
                var plural = line.Split(',')[1];

                Assert.IsTrue(_pluralizer.IsPlural(plural), "Expected {0} to be plural", plural);
            }
        }
Пример #4
0
        public void MyPluralizer()
        {
            List <Item> items = _context.Item.ToList();

            foreach (Item item in items)
            {
                if (pluralizationService.IsPlural(item.ItemName))
                {
                    item.ItemName = pluralizationService.Singularize(item.ItemName);
                    _context.Item.Update(item);
                    _context.SaveChanges();
                }
            }
        }
Пример #5
0
        public void CaseChangeTests()
        {
            var EzDbConfig = AppSettings.Instance.ConfigurationFileName;

            if (File.Exists(EzDbConfig))
            {
                var ezDbConfig = Core.Config.Configuration.FromFile(EzDbConfig);
                foreach (var item in ezDbConfig.PluralizerCrossReference)
                {
                    Pluralizer.Instance.AddWord(item.SingleWord, item.PluralWord);
                }
            }

            CaseTestPluralize("ProductCurve", "ProductCurves");
            CaseTestSingularize("ProductCurves", "ProductCurve");
            var str       = "PrioritizationCriterion".ToSingular();
            var strPlural = "PrioritizationCriterion".ToPlural();

            CaseTestSingularize("ConstructionStatus", "ConstructionStatus");

            var pl = new Pluralizer();

            Assert.True(pl.IsPlural("constructionStatuses"), "constructionStatuses should be Plural");
            Assert.True(pl.IsPlural("OpStatuses"), "OpStatuses should be Plural");
            Assert.True(pl.IsPlural("ScenarioCases"), "ScenarioCases should be Plural");
            Assert.True(pl.IsPlural("IncreaseDecreases"), "IncreaseDecreases should be Plural");
            Assert.False(pl.IsPlural("Virii"), "Virii should not be Plural");
            Assert.False(pl.IsPlural("Car"), "Car should not be Plural");
            Assert.True(pl.IsSingular("IncreaseDecrease"), "IncreaseDecrease should be Singular");
            Assert.True(pl.IsSingular("lease"), "lease should be Singular");
            Assert.True(pl.IsSingular("ScenarioCase"), "ScenarioCase should be Singular");
            Assert.True(pl.IsSingular("OpStatus"), "OpStatus should be Singular");
            Assert.True(pl.IsSingular("ConstructionStatus"), "ConstructionStatus should be Singular");
            Assert.True(pl.IsSingular("Virus"), "Virus should be Singular");
            Assert.False(pl.IsSingular("ScenarioCases"), "Virus should be not Singular");

            Assert.True(!pl.Pluralize("Virus").Equals("Viruses"), "Virus plural should not be Viruses");
            Assert.True(pl.Singularize("Viruses").Equals("Virus"), "Viruses singular should be Virus");
            Assert.True("ThisIsWCFLand".ToSentenceCase().Equals("This Is WCF Land"), "ThisIsWCFLand should be 'This Is WCF Land'");
            Assert.True("BOSSIsDACost".ToSentenceCase().Equals("BOSS Is DA Cost"), "BOSSIsDACost should be 'BOSS Is DA Cost'");
        }
Пример #6
0
        public async Task <IActionResult> Create(FlyerReaderViewModel model)
        {
            if (ModelState.IsValid)
            {
                List <FlyerOffer> flyerOffers = new List <FlyerOffer>();
                FlyerReader       flyerReader = new FlyerReader
                {
                    Img       = new List <ByteWraper>(),
                    DueDate   = model.DueDate,
                    StartDate = model.StartDate,
                    StoreID   = model.StoreID,
                    Data      = new String(String.Empty)
                };

                if (model.photos.Count > 0)
                {
                    var data      = String.Empty;
                    var flyerText = String.Empty;
                    foreach (IFormFile photo in model.photos)
                    {
                        var Stream = new MemoryStream();
                        await photo.CopyToAsync(Stream);

                        ByteWraper byteWraper = new ByteWraper();
                        byteWraper.photo = Stream.ToArray();
                        flyerReader.Img.Add(byteWraper);

                        var Googleimage = Image.FromBytes(byteWraper.photo);
                        var client      = ImageAnnotatorClient.Create();
                        var response    = client.DetectText(Googleimage);
                        foreach (var annotation in response)
                        {
                            if (annotation.Description != null)
                            {
                                flyerText += " " + annotation.Description;
                            }
                        }
                        String text = String.Empty;
                        text = flyerText.Replace("\n", " ");

                        string   str = text.ToLower();
                        string[] arr = str.Split(" ");
                        var      a   =
                            from k in arr
                            orderby k
                            select k;
                        String Description          = String.Empty;
                        String ItemName             = String.Empty;
                        List <DoubleWraper> numbers = new List <DoubleWraper>();
                        foreach (string res in a.Distinct())
                        {
                            Description += " " + res.ToLower();
                            if (res != "")
                            {
                                Item x;
                                if (pluralizationService.IsPlural(res))
                                {
                                    x = _context.Item.FirstOrDefault(i => i.ItemName.ToLower() == pluralizationService.Singularize(res));
                                }
                                else
                                {
                                    x = _context.Item.FirstOrDefault(i => i.ItemName.ToLower() == res);
                                }

                                if (x != null)
                                {
                                    ItemName = x.ItemName;
                                }
                                if (res.IsInt() || res.IsDecimal())
                                {
                                    numbers.Add(new DoubleWraper {
                                        num = Double.Parse(res)
                                    });
                                }
                            }
                        }

                        if (numbers.Count > 0 && ItemName != "")
                        {
                            flyerOffers.Add(new FlyerOffer
                            {
                                ItemName    = ItemName,
                                Description = Description,
                                Numbers     = numbers,
                                flyerphoto  = byteWraper.photo,
                                StoreID     = flyerReader.StoreID,
                                DueDate     = flyerReader.DueDate,
                                StartDate   = flyerReader.StartDate,
                                flyerReader = flyerReader,
                                recognized  = true
                            });
                        }
                        else if (ItemName == null || ItemName == "")
                        {
                            flyerOffers.Add(new FlyerOffer
                            {
                                Description = Description,
                                Numbers     = numbers,
                                flyerphoto  = byteWraper.photo,
                                StoreID     = flyerReader.StoreID,
                                DueDate     = flyerReader.DueDate,
                                StartDate   = flyerReader.StartDate,
                                flyerReader = flyerReader,
                                recognized  = false
                            });
                        }
                        flyerText = String.Empty;
                    }
                }
                flyerReader.flyerOffers = flyerOffers;
                _context.FlyerReader.Add(flyerReader);
                _context.SaveChanges();
                return(RedirectToAction("FlyersOffers"));
            }
            ViewData["StoreID"] = new SelectList(_context.Store, "StoreID", "StoreName", model.StoreID);
            return(View(model));
        }
        public static string Pluralize(this string word)
        {
            var pluralizer = new Pluralizer();

            return(pluralizer.IsPlural(word) ? word : pluralizer.Pluralize(word));
        }
Пример #8
0
        public void IsPluralShouldCheckUnusualWords()
        {
            var plurally = new Pluralizer();

            Assert.Equal(true, plurally.IsPlural("homework"));
        }
Пример #9
0
        public void IsPluralShouldCheckSpecialSuffix()
        {
            var plurally = new Pluralizer();

            Assert.Equal(true, plurally.IsPlural("elves"));
        }
 public bool CanOnlyBePlural(string noun) =>
 !_pluralizer.IsSingular(noun) && _pluralizer.IsPlural(noun);