void Start() { webSearch = GetComponent <WebSearch>(); m_DictationRecognizer = new DictationRecognizer(); m_DictationRecognizer.DictationResult += (text, confidence) => { Debug.LogFormat("Dictation result: {0}", text); m_Recognitions.text += text + "\n"; webSearch.SearchForKeyword(text); }; m_DictationRecognizer.DictationHypothesis += (text) => { Debug.LogFormat("Dictation hypothesis: {0}", text); m_Hypotheses.text += text; }; m_DictationRecognizer.DictationComplete += (completionCause) => { if (completionCause != DictationCompletionCause.Complete) { Debug.LogErrorFormat("Dictation completed unsuccessfully: {0}", completionCause); } }; m_DictationRecognizer.DictationError += (error, hresult) => { Debug.LogErrorFormat("Dictation error: {0}; HResult = {1}.", error, hresult); }; m_DictationRecognizer.Start(); }
protected override List <Result> QueryInternal(Query query) { List <Result> results = new List <Result>(); if (string.IsNullOrEmpty(query.ActionName)) { return(results); } WebSearch webSearch = CommonStorage.Instance.UserSetting.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName && o.Enabled); if (webSearch != null) { string keyword = query.ActionParameters.Count > 0 ? query.RawQuery.Substring(query.RawQuery.IndexOf(' ') + 1) : ""; results.Add(new Result() { Title = string.Format("Search {0} for \"{1}\"", webSearch.Title, keyword), Score = 6, IcoPath = webSearch.IconPath, Action = (c) => { Process.Start(webSearch.Url.Replace("{q}", keyword)); return(true); } }); } return(results); }
public void Search7Zip() { WebSearch webSearch = new WebSearch(new PackageSource("Google", "http://google.com")); var results = webSearch.Search("7zip", 30); Assert.IsTrue(results.FuzzyContains("http://www.7-zip.org/download.html")); }
public PlacesForm(User i_LoggedInUser, ListBox i_CurrentFriends) { InitializeComponent(); m_LoggedInUser = i_LoggedInUser; m_CurrentFriends = i_CurrentFriends; m_Web = new WebSearch(); getFriends(); }
static void Main(string[] args) { var client = new GoogleSearchDomain(); var extractor = new NlpFrequencyExtractor(); string ws = new WebSearch(client, extractor) .Invoke("who is bob ross?") .SelectHigestScoredSentence(); Console.WriteLine(ws); Console.Read(); }
public void SearchNotepadPlusPlus() { WebSearch webSearch = new WebSearch(new PackageSource("Google", "http://google.com")); var results = webSearch.Search("notepad++", 30); Assert.IsTrue(results.FuzzyContains("https://notepad-plus-plus.org/download/")); // we need more google results to get this: //Assert.IsTrue(results.FuzzyContains("http://notepad-plus.en.softonic.com/download")); Assert.IsTrue(results.FuzzyContains("http://filehippo.com/download_notepad/")); }
public void GetSearchResult(WebSearch searchObj) { try { log.Debug("Entering " + MethodBase.GetCurrentMethod().Name, MethodBase.GetCurrentMethod().Name); nENTITIES.WebSearch _searchObj = searchObj.Instance; nENTITIES.SearchResults results = helper.GetSearchResult(_searchObj); log.Debug("Exiting " + MethodBase.GetCurrentMethod().Name, MethodBase.GetCurrentMethod().Name); } catch (Exception ex) { log.Error(ex.Message, MethodBase.GetCurrentMethod().Name); } }
public void Execute(CelebFinderContext context) { const string appId = "AnAkWUfV34G9T5uEFFZ6ffBa6wWhoaFdyVFGOWnBVA9L4zW4OsR1aSJVPm8pCDZQEk5774aOmuTz5V53owQ-"; var query = string.Format("{0} site:http://www.wikipedia.org", context.Name); var result = new WebSearch(appId).Query(query).Get(); if(result.Count > 1) throw new Exception("Dunno which result to choose, there are " + result.TotalHits); if(result.Count == 0) throw new Exception("Could not find anyone with that name"); context.WikipediaUrl = result.First().Url; }
private void btnEditWebSearch_OnClick(object sender, RoutedEventArgs e) { WebSearch seletedWebSearch = webSearchView.SelectedItem as WebSearch; if (seletedWebSearch != null) { WebSearchSetting webSearch = new WebSearchSetting(this); webSearch.UpdateItem(seletedWebSearch); webSearch.ShowDialog(); } else { MessageBox.Show("Please select a web search"); } }
private void btnDeleteWebSearch_OnClick(object sender, RoutedEventArgs e) { WebSearch seletedWebSearch = webSearchView.SelectedItem as WebSearch; if (seletedWebSearch != null && MessageBox.Show("Are your sure to delete " + seletedWebSearch.Title, "Delete WebSearch", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { UserSettingStorage.Instance.WebSearches.Remove(seletedWebSearch); webSearchView.Items.Refresh(); } else { MessageBox.Show("Please select a web search"); } }
public void UpdateItem(WebSearch webSearch) { updateWebSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch); if (updateWebSearch == null || string.IsNullOrEmpty(updateWebSearch.Url)) { MessageBox.Show("Invalid web search"); Close(); return; } update = true; lblAdd.Text = "Update"; tbIconPath.Text = webSearch.IconPath; ShowIcon(webSearch.IconPath); cbEnable.IsChecked = webSearch.Enabled; tbTitle.Text = webSearch.Title; tbUrl.Text = webSearch.Url; tbActionword.Text = webSearch.ActionWord; }
/// <summary> /// Realiza la búsqueda de una palabra o frase sobre todas las páginas. /// Si el usuario e sprovisto, incluye las páginas con permisos /// </summary> /// <param name="toFind"></param> /// <param name="user"></param> public List <WebSearch> PerformSearch(string toFind, User user = null) { //1. recorrer el directorio de aspx //2. utilizar la función search y detectar una coincidencia //3. guardar las coincidencias //4. excluir según los permisos del usuario WebSearch result = null; RoleManager roleManager = new RoleManager(); List <Permission> permissions = roleManager.GetAllPermission(); string[] fileArray = Directory.GetFiles(HttpContext.Current.Server.MapPath(""), "*.aspx"); List <WebSearch> searchResult = new List <WebSearch>(); foreach (string file in fileArray) { TextReader textReader = new StreamReader(file); string fileContent = textReader.ReadToEnd(); //Con la regex se pretende excluir los tags de html //fileContent = Regex.Replace(fileContent, @"<[^>]+?\/?>", m => {return String.Empty;}); int index = fileContent.IndexOf(toFind); if (index > -1) { string fileName = Path.GetFileName(file); bool isPublic = !permissions.Exists(x => x.UrlAccess == fileName); bool hasPermission = SessionHelper.IsSessionAlive() && SecurityHelper.HasPermission(user, fileName); if (isPublic || hasPermission) { result = new WebSearch(); result.Url = fileName; result.Description = fileName.Substring(0, fileName.Length - 5); searchResult.Add(result); } } } return(searchResult); }
public WebSearchViewModel(string subscriptionKey, string endpoint, Image searchImage, TextBlock searchImageText) { this.searchImage = searchImage; this.searchImageText = searchImageText; this.webSearch = new WebSearch(subscriptionKey, endpoint); }
protected override List <Result> QueryInternal(Query query) { List <Result> results = new List <Result>(); if (string.IsNullOrEmpty(query.ActionName)) { return(results); } WebSearch webSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName && o.Enabled); if (webSearch != null) { string keyword = query.ActionParameters.Count > 0 ? query.GetAllRemainingParameter() : ""; string title = keyword; string subtitle = "Search " + webSearch.Title; if (string.IsNullOrEmpty(keyword)) { title = subtitle; subtitle = null; } context.PushResults(query, new List <Result>() { new Result() { Title = title, SubTitle = subtitle, Score = 6, IcoPath = webSearch.IconPath, Action = (c) => { Process.Start(webSearch.Url.Replace("{q}", keyword)); return(true); } } }); if (!string.IsNullOrEmpty(keyword)) { ISuggestionSource sugg = new Google(); var result = sugg.GetSuggestions(keyword); if (result != null) { context.PushResults(query, result.Select(o => new Result() { Title = o, SubTitle = subtitle, Score = 5, IcoPath = webSearch.IconPath, Action = (c) => { Process.Start(webSearch.Url.Replace("{q}", o)); return(true); } }).ToList()); } } } return(results); }
static void Main(string[] args) { while (true) { Console.WriteLine("MSPハッカソンのテストプログラムです"); Console.WriteLine("試したいプログラムの数字を入力してください"); Console.WriteLine("形態素解析: 1"); Console.WriteLine("ひらがな変換: 2"); Console.WriteLine("要素抽出: 3"); Console.WriteLine("文章類似度計算: 4"); Console.WriteLine("顔検出: 5"); Console.WriteLine("感情検出: 6"); Console.WriteLine("対話: 7"); Console.WriteLine("画像分析: 8"); Console.WriteLine("Bing検索: 9"); Console.WriteLine("終了: 999"); Console.Write(":"); var command = Console.ReadLine(); if (command == "999") { break; } switch (command) { case "1": Console.WriteLine("形態素解析(MorphAnalysisAsync) 開始"); var results = MorphAnalysisAsync(_docomoApiKey).Result; foreach (var r in results) { var line = string.Join(" ", r.Select(q => q.Form + "[" + q.Pos + "]")); Console.WriteLine(line); } break; case "2": Console.WriteLine("ひがらな変換(HiraganaConvertAsync) 開始"); var result = HiraganaConvertAsync(_docomoApiKey).Result; Console.WriteLine(result); break; case "3": Console.WriteLine("要素抽出(EntityExtractAsync) 開始"); var resultsEntity = EntityExtractAsync(_docomoApiKey).Result; var resultEntity = string.Join(" ", resultsEntity.Select(q => q.Entity + "[" + q.Type + "]")); Console.WriteLine(resultEntity); break; case "4": Console.WriteLine("文章類似度計算(SimilarityCalc) 開始"); var resultSimilarity = SimirarityCalcAsync(_docomoApiKey).Result; Console.WriteLine(resultSimilarity); break; case "5": Console.WriteLine("顔検出 開始"); var resultFaceDetect = FaceDetectAsync(_faceApiKey).Result; Console.WriteLine("年齢: " + resultFaceDetect.First().FaceAttributes.Age + "歳"); Console.WriteLine("性別: " + resultFaceDetect.First().FaceAttributes.Gender); Console.WriteLine("メガネ: " + resultFaceDetect.First().FaceAttributes.Glasses); break; case "6": Console.WriteLine("感情検出 開始"); var resultEmotionDetect = EmotionDetectAync(_emotionKey).Result; Console.WriteLine("怒り: " + resultEmotionDetect.First().Scores.Anger); Console.WriteLine("軽蔑: " + resultEmotionDetect.First().Scores.Contempt); Console.WriteLine("嫌悪: " + resultEmotionDetect.First().Scores.Disgust); Console.WriteLine("恐怖: " + resultEmotionDetect.First().Scores.Fear); Console.WriteLine("中立: " + resultEmotionDetect.First().Scores.Neutral); Console.WriteLine("悲しみ: " + resultEmotionDetect.First().Scores.Sadness); Console.WriteLine("驚き: " + resultEmotionDetect.First().Scores.Surprise); Console.WriteLine("幸福: " + resultEmotionDetect.First().Scores.Happiness); break; case "7": Console.WriteLine("対話API 対話モード(DialogueAsync) 開始"); var resultDialogue1 = DialogueAsync(_docomoApiKey).Result.Result; Console.WriteLine(resultDialogue1); Console.WriteLine("対話API しりとりモード-連続的な対話を行うケース(DialogueModeSrtrAsync) 開始"); var resultDialogue2 = DialogueModeSrtrAsync(_docomoApiKey).Result; Console.WriteLine(string.Join(">", resultDialogue2)); Console.WriteLine("対話API 対話モード-ユーザーの情報を追加したケース-赤ちゃん風(DialogueUserAsync) 開始"); var resultDialogue3 = DialogueUserAsync(_docomoApiKey).Result.Result; Console.WriteLine(resultDialogue3); break; case "8": Console.WriteLine("画像分析 開始"); var resultComputerVision = ComputerVisionDetectAync(_computervisionkey).Result; foreach (var tag in resultComputerVision.Tags) { Console.WriteLine(tag.Name); } break; case "9": var client = new WebSearch(ApiKey.BING_SEARCH_APIKEY); var webResult = client.ExecuteAsync("アンパン", 20).Result; break; default: Console.WriteLine("そのようなコマンドはありません"); break; } Console.WriteLine(); Console.WriteLine("****** コマンド実行完了しました *********"); Console.WriteLine(); } }