public WebSearchClassifyResult(ClassifyResult classifyResult, WebSearchResult searchResult) { SearchResult = searchResult; if (!string.IsNullOrEmpty(classifyResult.Result)) this.Result = classifyResult.Result; if (classifyResult.Propability != null) this.Propability = classifyResult.Propability; if (classifyResult.ShouldBeSaved != null) this.ShouldBeSaved = classifyResult.ShouldBeSaved; }
public void ClassifyWebSearchQueryUnitTests_WithEmptySnippetInputResultShouldBeNull() { WebSearchResult webSearchRes = new WebSearchResult() { SearchEngine = "Google", Snippet = "", Source = "www.test-source.com" }; RestaurantQueryPattern query = new RestaurantQueryPattern() { Name = "פלאפל", Description = "פלאפל אכי טעים" }; var response = Classifier.uClassify.ClassifyUtility.ClassifyWebSearchQueryUnit(query, "CuisinesSupervised1", webSearchRes); Assert.IsNull(response); }
public void ClassifyWebSearchQueryUnitTests_ResponseShouldNotBeNull() { WebSearchResult webSearchRes = new WebSearchResult() { SearchEngine = "Google", Snippet = "מנות פלאפל בפיתה, בלפה, בצלחת, הזמנת משלוחים.", Source = "www.test-source.com" }; RestaurantQueryPattern query = new RestaurantQueryPattern() { Name = "פלאפל", Description = "פלאפל אכי טעים" }; var response = Classifier.uClassify.ClassifyUtility.ClassifyWebSearchQueryUnit(query, "CuisinesSupervised1", webSearchRes); Assert.IsNotNull(response); }
public void ClassifyWebSearchQueryUnitTests_SearchResultInClassifierResultShouldBeSaved() { WebSearchResult webSearchRes = new WebSearchResult() { SearchEngine = "Google", Snippet = "מנות פלאפל בפיתה, בלפה, בצלחת, הזמנת משלוחים.", Source = "www.test-source.com" }; RestaurantQueryPattern query = new RestaurantQueryPattern() { Name = "פלאפל", Description = "פלאפל אכי טעים" }; var response = Classifier.uClassify.ClassifyUtility.ClassifyWebSearchQueryUnit(query, "CuisinesSupervised1", webSearchRes); Assert.IsFalse(response.Any(r => r.SearchResult == null)); Assert.IsFalse(response.Any(r => r.SearchResult.SearchEngine != webSearchRes.SearchEngine)); Assert.IsFalse(response.Any(r => r.SearchResult.Source != webSearchRes.Source)); Assert.IsFalse(response.Any(r => r.SearchResult.Snippet != webSearchRes.Snippet)); Assert.IsFalse(response.Any(r => r.SearchResult.IsTrained != webSearchRes.IsTrained)); }
public static List<WebSearchClassifyResult> ClassifyWebSearchQueryUnit(RestaurantQueryPattern queryUnit, string classifierName, WebSearchResult searchResult) { if (!string.IsNullOrEmpty(searchResult.Snippet)) { queryUnit.Description = searchResult.Snippet; log.DebugFormat("[ClassifyWebSearchQueryUnit] classifierName={0}, queryUnit={1}.", classifierName, queryUnit.ToString()); var classifierResults = ClassifyQueryUnit(queryUnit, classifierName); if (classifierResults != null || classifierResults.Count > 0) { List<WebSearchClassifyResult> returnList = new List<WebSearchClassifyResult>(); foreach (var result in classifierResults) { WebSearchClassifyResult tempResult = new WebSearchClassifyResult(result, searchResult); returnList.Add(tempResult); } return returnList; } else { log.WarnFormat("[ClassifyWebSearchQueryUnit] Classifier results is null or empty. queryUnit.Name={0}, queryUnit.Description={1}.", queryUnit.Name, queryUnit.Description); } } else { log.ErrorFormat("[ClassifyWebSearchQueryUnit] WebSearchResult Snippet can't be null or empty."); } return null; }
private List<WebSearchResult> GoogleResultToWebSearchResult(Search googleResults) { if (googleResults != null && googleResults.Items != null && googleResults.Items.Count > 0 ) { List<WebSearchResult> returnValue = new List<WebSearchResult>(); foreach (var googleRes in googleResults.Items) { WebSearchResult tempResult = new WebSearchResult() { SearchEngine = "Google", Source = googleRes.DisplayLink, Snippet = googleRes.Snippet }; returnValue.Add(tempResult); } return returnValue; } else { log.Error("[GoogleResultToWebSearchResult] googleResults is null or Empty."); return null; } }