Пример #1
0
        public override SearchResult GetResult(string url)
        {
            SearchResult r;
            //var r = base.GetResult(url);

            var tm = GetApiResults(url, out var code, out var res, out var msg);

            if (tm?.docs != null)
            {
                // Most similar to least similar
                var results = ConvertResults(tm);
                var best    = results[0];

                r         = new SearchResult(this, best.Url, best.Similarity);
                r.Caption = best.Caption;

                r.AddExtendedInfo(results);
            }
            else
            {
                r = base.GetResult(url);
                r.ExtendedInfo.Add(string.Format("API: Returned null (possible timeout) [{0} {1} {2}]", code, res, msg));
            }


            return(r);
        }
        public override SearchResult GetResult(string url)
        {
            SearchResult result = base.GetResult(url);

            try {
                var sn = GetResults(url)
                         .OrderByDescending(r => r.Similarity)
                         .ToArray();

                var extended = ConvertResults(sn);
                var best     = extended
                               .Where(e => e.Url != null)
                               .OrderByDescending(e => e.Similarity)
                               .First();

                result.Url        = best.Url;
                result.Similarity = best.Similarity;
                result.Caption    = best.Caption;


                result.AddExtendedInfo(extended);
            }
            catch (Exception e) {
                result.ExtendedInfo.Add(e.StackTrace);
            }


            return(result);
        }