示例#1
0
        public void LiteTaggingDbTest()
        {
            var db = new LiteDbAutoTaggerStorage("taggerTest.ldb");

            db.InsertOrUpdate("iA", new[] { "mA", "mB", "mC" }, new[] { "hA", "hB" });
            db.InsertOrUpdate("iB", new[] { "mA", "mB", "mD" }, new[] { "hA", "hC" });
            db.InsertOrUpdate("iC", new[] { "mA", "mD", "mE" }, new[] { "hC", "hD" });
            db.InsertOrUpdate("iD", new[] { "mX", "mY", "mZ" }, new[] { "hX", "hY" });
            db.InsertOrUpdate("iE", new[] { "mA", "mG", "mU" }, new[] { "hA", "hF" });

            var(debug, tags) = db.FindHumanoidTags(
                new List <IMachineTag>
            {
                new MachineTag {
                    Name = "mA"
                },
                new MachineTag {
                    Name = "mB"
                },
                new MachineTag {
                    Name = "mC"
                }
            });

            Assert.Contains("hC", tags);
            Assert.DoesNotContain("hX", tags);

            db.Drop();
        }
示例#2
0
        public void CrawlerRoundtrip()
        {
            var crawler = new InstagramCrawler();
            var images  = crawler.CrawlImages(10);

            var tagger = new ClarifaiImageTagger();
            var db     = new LiteDbAutoTaggerStorage("fullImportedImages.ldb");

            IEnumerable <string> lastMTags = null;
            IEnumerable <string> lastHTags = null;

            foreach (var crawlerImage in images)
            {
                this.TestConsole.WriteLine(
                    crawlerImage.ImageId + ">L" + crawlerImage.Likes + ">C" + crawlerImage.Comments + " >>> "
                    + string.Join(", ", crawlerImage.HumanoidTags));

                var tags = tagger.GetTagsForImageUrl(crawlerImage.ImageUrl).ToList();

                lastMTags = tags;
                lastHTags = crawlerImage.HumanoidTags;

                Console.WriteLine("Tags: " + string.Join(", ", tags));
                db.InsertOrUpdate(crawlerImage.ImageId, tags, crawlerImage.HumanoidTags);
            }

            Assert.NotNull(lastMTags);
            var foundHTags = db.FindHumanoidTags(lastMTags).ToList();

            this.TestConsole.WriteLine(string.Join(", ", lastMTags) + " >>> " + string.Join(", ", foundHTags));

            // var similar    = lastHTags.Count(lastHTag => foundHTags.Contains(lastHTag));

            // Assert.True(similar > 2, "not enough similar tags");
        }