public void Should_Fail_With_Wrong_Geo() { const double latitude = 307.786971; const double longitude = 200.399677; Assert.Throws <ApiException>(() => WikiApi.Geosearch(latitude, longitude)); }
public void Verbose_With_Levenstein() { const double latitude = 37.786971; const double longitude = -122.399677; IStringMetric metric = new Levenstein(); ITokenizer tokenizer = new Tokenizer(); var geopages = WikiApi.Geosearch(latitude, longitude); foreach (var geopage in geopages) { output.WriteLine($"[{geopage.Pageid}] {geopage.Title}"); var images = WikiApi.Images(geopage.Pageid); var imagesWithMetrics = images .Select(image => new { Image = image, Similarity = image.CalcMetric(geopage.Title, tokenizer, metric) }) .ToList(); var title = imagesWithMetrics.Aggregate((image, next) => next.Similarity > image.Similarity ? next : image); output.WriteLine($"\t*[{title.Image.Ns}] {title.Image.Title} {title.Similarity}"); foreach (var image in imagesWithMetrics) { output.WriteLine($"\t[{image.Image.Ns}] {image.Image.Title} {image.Similarity}"); } } }
public void Should_Work() { const double latitude = 37.786971; const double longitude = -122.399677; var geopages = WikiApi.Geosearch(latitude, longitude); Assert.NotNull(geopages); Assert.NotEmpty(geopages); }