国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

css網(wǎng)站開發(fā)實錄新聞稿發(fā)布軟文平臺

css網(wǎng)站開發(fā)實錄,新聞稿發(fā)布軟文平臺,畢業(yè)設(shè)計難度適中的網(wǎng)站開發(fā)項目題目,wordpress 多用戶 b2bMiddlewareService文件夾 在這個文件夾中,我們需要添加以下文件: 名人服務(wù).cs 名人服務(wù).cs 名人結(jié)果.cs ILandmarkService.cs 地標(biāo)服務(wù) .cs 地標(biāo)結(jié)果 .cs ICelebrityService.cs – 包裝多個串行的認(rèn)知服務(wù)來實現(xiàn)名人識別的中間服務(wù)層的接口定義&…

MiddlewareService文件夾

在這個文件夾中,我們需要添加以下文件:

  • 名人服務(wù).cs

  • 名人服務(wù).cs

  • 名人結(jié)果.cs

  • ILandmarkService.cs

  • 地標(biāo)服務(wù) .cs

  • 地標(biāo)結(jié)果 .cs

ICelebrityService.cs – 包裝多個串行的認(rèn)知服務(wù)來實現(xiàn)名人識別的中間服務(wù)層的接口定義,需要依賴注入

using System.Threading.Tasks;namespace CognitiveMiddlewareService.MiddlewareService
{public interface ICelebrityService{Task<CelebrityResult> Do(byte[] imgData);}
}

CelebrityService.cs – 包裝多個串行的認(rèn)知服務(wù)來實現(xiàn)名人識別中間服務(wù)層的邏輯代碼

using CognitiveMiddlewareService.CognitiveServices;
using Newtonsoft.Json;
using System.Threading.Tasks;namespace CognitiveMiddlewareService.MiddlewareService
{public class CelebrityService : ICelebrityService{private readonly IVisionService visionService;private readonly IEntitySearchService entityService;public CelebrityService(IVisionService vs, IEntitySearchService ess){this.visionService = vs;this.entityService = ess;}public async Task<CelebrityResult> Do(byte[] imgData){// get original recognized resultvar stream = Helper.GetStream(imgData);Celebrity celebrity = await this.visionService.RecognizeCelebrityAsync(stream);if (celebrity != null){// get entity search resultstring entityName = celebrity.name;string jsonResult = await this.entityService.SearchEntityAsync(entityName);EntityResult er = JsonConvert.DeserializeObject<EntityResult>(jsonResult);if (er?.entities?.value.Length > 0){// isolation layer: decouple data structure then return abstract resultCelebrityResult cr = new CelebrityResult(){Name = er.entities.value[0].name,Description = er.entities.value[0].description,Url = er.entities.value[0].url,ThumbnailUrl = er.entities.value[0].image.thumbnailUrl,Confidence = celebrity.confidence};return cr;}}return null;}}
}

小提示:上面的代碼中,用CelebrityResult接管了實體搜索結(jié)果和名人識別結(jié)果的部分有效字段,以達(dá)到解耦/隔離的作用,后面的代碼只關(guān)心CelebrityResult如何定義的即可。

CelebrityResult.cs – 抽象出來的名人識別服務(wù)的返回結(jié)果

namespace CognitiveMiddlewareService.MiddlewareService
{public class CelebrityResult{public string Name { get; set; }public double Confidence { get; set; }public string Url { get; set; }public string Description { get; set; }public string ThumbnailUrl { get; set; }}
}

ILandmarkService.cs – 包裝多個串行的認(rèn)知服務(wù)來實現(xiàn)地標(biāo)識別的中間服務(wù)層的接口定義,需要依賴注入

using CognitiveMiddlewareService.CognitiveServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;namespace CognitiveMiddlewareService.MiddlewareService
{public interface ILandmarkService{Task<LandmarkResult> Do(byte[] imgData);}
}

LandmarkService.cs – 包裝多個串行的認(rèn)知服務(wù)來實現(xiàn)地標(biāo)識別的中間服務(wù)層的邏輯代碼

using CognitiveMiddlewareService.CognitiveServices;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;namespace CognitiveMiddlewareService.MiddlewareService
{public class LandmarkService : ILandmarkService{private readonly IVisionService visionService;private readonly IEntitySearchService entityService;public LandmarkService(IVisionService vs, IEntitySearchService ess){this.visionService = vs;this.entityService = ess;}public async Task<LandmarkResult> Do(byte[] imgData){// get original recognized resultvar streamLandmark = Helper.GetStream(imgData);Landmark landmark = await this.visionService.RecognizeLandmarkAsync(streamLandmark);if (landmark != null){// get entity search resultstring entityName = landmark.name;string jsonResult = await this.entityService.SearchEntityAsync(entityName);EntityResult er = JsonConvert.DeserializeObject<EntityResult>(jsonResult);// isolation layer: decouple data structure then return abstract resultLandmarkResult lr = new LandmarkResult(){Name = er.entities.value[0].name,Description = er.entities.value[0].description,Url = er.entities.value[0].url,ThumbnailUrl = er.entities.value[0].image.thumbnailUrl,Confidence = landmark.confidence};return lr;}return null;}}
}

小提示:上面的代碼中,用LandmarkResult接管了實體搜索結(jié)果和地標(biāo)識別結(jié)果的部分有效字段,以達(dá)到解耦/隔離的作用,后面的代碼只關(guān)心LandmarkResult如何定義的即可。

LandmarkResult.cs – 抽象出來的地標(biāo)識別服務(wù)的返回結(jié)果

namespace CognitiveMiddlewareService.MiddlewareService
{public class LandmarkResult{public string Name { get; set; }public double Confidence { get; set; }public string Url { get; set; }public string Description { get; set; }public string ThumbnailUrl { get; set; }}
}

Processors文件夾

在這個文件夾中,我們需要添加以下文件:

  • IProcessService.cs

  • 進(jìn)程服務(wù) .cs

  • 聚合結(jié)果.cs

IProcessService.cs – 任務(wù)調(diào)度層服務(wù)的接口定義,需要依賴注入

using System.Threading.Tasks;namespace CognitiveMiddlewareService.Processors
{public interface IProcessService{Task<AggregatedResult> Process(byte[] imgData);}
}

ProcessService.cs – 任務(wù)調(diào)度層服務(wù)的邏輯代碼

using CognitiveMiddlewareService.MiddlewareService;
using System.Collections.Generic;
using System.Threading.Tasks;namespace CognitiveMiddlewareService.Processors
{public class ProcessService : IProcessService{private readonly ILandmarkService landmarkService;private readonly ICelebrityService celebrityService;public ProcessService(ILandmarkService ls, ICelebrityService cs){this.landmarkService = ls;this.celebrityService = cs;}public async Task<AggregatedResult> Process(byte[] imgData){// preprocess// todo: create screening image classifier to get a rough category, then decide call which service// task dispatcher: parallelized run 'Do'// todo: put this logic into Dispatcher serviceList<Task> listTask = new List<Task>();var taskLandmark = this.landmarkService.Do(imgData);listTask.Add(taskLandmark);var taskCelebrity = this.celebrityService.Do(imgData);listTask.Add(taskCelebrity);await Task.WhenAll(listTask);LandmarkResult lmResult = taskLandmark.Result;CelebrityResult cbResult = taskCelebrity.Result;// aggregator// todo: put this logic into Aggregator serviceAggregatedResult ar = new AggregatedResult(){Landmark = lmResult,Celebrity = cbResult};return ar;// ranker// todo: if there have more than one result in AgregatedResult, need give them a ranking// output generator// todo: generate specified JSON data, such as Adptive Card}}
}

小提示:大家可以看到上面這個文件中有很多綠色的注釋,帶有todo文字的,對于一個更復(fù)雜的系統(tǒng),可以用這些todo中的描述來設(shè)計獨(dú)立的模塊。

AggregatedResult.cs – 任務(wù)調(diào)度層服務(wù)的最終聚合結(jié)果定義

using CognitiveMiddlewareService.MiddlewareService;namespace CognitiveMiddlewareService.Processors
{public class AggregatedResult{public LandmarkResult Landmark { get; set; }public CelebrityResult Celebrity { get; set; }}
}

http://m.aloenet.com.cn/news/40024.html

相關(guān)文章:

  • 貴陽專業(yè)做網(wǎng)站公司高端網(wǎng)站設(shè)計公司
  • 商城網(wǎng)站制作方案100個免費(fèi)推廣網(wǎng)站
  • 網(wǎng)站建設(shè) 天津國內(nèi)軍事新聞最新消息
  • 能免費(fèi)做網(wǎng)站嗎信息流廣告模板
  • 成都定制企業(yè)網(wǎng)站制作免費(fèi)學(xué)生網(wǎng)頁制作成品代碼
  • 專業(yè)手機(jī)網(wǎng)站制作公司網(wǎng)站快速排名服務(wù)商
  • 做網(wǎng)站開發(fā)人員架構(gòu)市場營銷
  • win7如何做網(wǎng)站建立自己的網(wǎng)站平臺
  • 鋼管網(wǎng)站模板國外搜索引擎大全不屏蔽
  • 學(xué)做川菜的網(wǎng)站站長工具whois查詢
  • 山西電力建設(shè)三公司網(wǎng)站免費(fèi)的行情網(wǎng)站app
  • 網(wǎng)站建設(shè) 公司 常見問題seo綜合查詢是什么
  • 湘潭網(wǎng)站建站公司武漢seo結(jié)算
  • 淄博的大型網(wǎng)站建設(shè)怎樣做網(wǎng)站
  • 網(wǎng)站建設(shè)費(fèi)用能否計入開辦費(fèi)百度論壇發(fā)帖
  • 新鄉(xiāng)市建設(shè)工程信息網(wǎng)seo工作內(nèi)容有哪些
  • 深圳網(wǎng)站制作工作室百度推廣介紹
  • 工業(yè)設(shè)計相關(guān)網(wǎng)站公司官網(wǎng)搭建
  • 站長網(wǎng)站的優(yōu)勢百度網(wǎng)絡(luò)營銷中心
  • 西安做網(wǎng)站電話百度一下你就知道網(wǎng)頁
  • 佛山新網(wǎng)站制作平臺鄭州seo優(yōu)化公司
  • 門戶網(wǎng)站解決方案蘇州seo建站
  • 臨淄網(wǎng)站建設(shè)公司網(wǎng)站推廣搜索
  • 麗江網(wǎng)站建設(shè)怎么自己創(chuàng)建一個網(wǎng)站
  • ppt做視頻 模板下載網(wǎng)站營銷方式和渠道
  • 重慶網(wǎng)站建設(shè)合肥公司網(wǎng)站怎么宣傳
  • 做界面網(wǎng)站用什么語言seo教程
  • 青海住房與建設(shè)廳網(wǎng)站廣東網(wǎng)約車漲價
  • 用dw做淘客網(wǎng)站的步驟南京百度推廣開戶
  • 工控做網(wǎng)站網(wǎng)站免費(fèi)軟件