public virtual IImageDescription GetImageDescription(MediaItem m, string language)
        {
            ICognitiveSearchResult csr = Searcher.GetAnalysis(m.ID.ToString(), language, m.Database.Name);

            Description d = csr
                            ?.VisionAnalysis
                            ?.Description
                            ?? new Description();

            return(ImageDescriptionFactory.Create(d, m.Alt, m.ID.ToString(), m.Database.Name, language));
        }
        public virtual ICognitiveTextAnalysis Create(ICognitiveSearchResult result)
        {
            var analysis = Create();

            analysis.LinkAnalysis       = result.LinkAnalysis;
            analysis.SentimentAnalysis  = result.SentimentAnalysis;
            analysis.KeyPhraseAnalysis  = result.KeyPhraseAnalysis;
            analysis.LinguisticAnalysis = result.LinguisticAnalysis;

            return(analysis);
        }
        public virtual ICognitiveImageAnalysis Create(ICognitiveSearchResult result)
        {
            var analysis = Create();

            analysis.EmotionAnalysis = result.EmotionAnalysis;
            analysis.FacialAnalysis  = result.FacialAnalysis;
            analysis.TextAnalysis    = result.TextAnalysis;
            analysis.VisionAnalysis  = result.VisionAnalysis;

            Item i = DataService.GetItemByUri(result?.UniqueId ?? string.Empty);

            if (i == null)
            {
                return(analysis);
            }

            analysis.ImageHeight = GetNumber(i, "height", 0);
            analysis.ImageWidth  = GetNumber(i, "width", 0);
            analysis.ImageUrl    = $"/sitecore/shell/Applications/-/media/{i.ID.Guid:N}.ashx";

            return(analysis);
        }
Пример #4
0
        public virtual ICognitiveMediaSearchJsonResult CreateMediaSearchJsonResult(ISitecoreDataService dataService, ICognitiveSearchResult searchResult)
        {
            var obj = Provider.GetService <ICognitiveMediaSearchJsonResult>();

            MediaItem m = dataService.GetItemByUri(searchResult.UniqueId);

            try
            {
                obj.Url = $"/sitecore/shell/-/media/{m.ID.Guid:N}.ashx";
            }
            catch (Exception ex)
            {
                obj.Url = string.Empty;
            }
            try
            {
                obj.Alt = m.Alt;
            }
            catch (Exception ex)
            {
                obj.Alt = string.Empty;
            }

            return(obj);
        }
        public ActionResult TextAnalysis(string id, string language, string db)
        {
            ICognitiveSearchResult csr = SearchService.GetCognitiveSearchResult(id, language, db);

            return(View("TextAnalysis", TextAnalysisFactory.Create(csr)));
        }
        public virtual ICognitiveTextAnalysis GetTextAnalysis(string id, string language, string db)
        {
            ICognitiveSearchResult csr = GetCognitiveSearchResult(id, language, db);

            return(TextAnalysisFactory.Create(csr));
        }