// Use this for initialization void Start() { this._availableResponses = GetComponents <TailoredResponse>(); _conceptNet = new ConceptNetWrapper("http://api.conceptnet.io/"); }
// Use this for initialization async void Start() { TailoredRepository = GetComponentInChildren <TailoredRepository>(); dF = new Dictionary <string, int>(); _conceptNet = new ConceptNetWrapper("http://api.conceptnet.io/"); //TODO: should have a variety of catgs: business entertainment general health science sports technology // init with your API key (get this from newsapi.org) newsApiClient = new NewsApiClient("4235111de41841c2a22049677d24ccb7"); using (var reader = new StreamReader(WORD_FREQUENCY_CSV_PATH)) using (var csvReader = new CsvReader(reader)) { csvReader.Read(); csvReader.ReadHeader(); while (csvReader.Read()) { string word = csvReader.GetField("word"); int count = int.Parse(csvReader.GetField("count")); dF[word] = count; } } Debug.Log(String.Format("Words loaded: {0}", dF.Count())); Debug.Log(String.Format("Trump mentioned {0} times.", dF["trump"])); // var client = LanguageServiceClient.Create(); // var response = client.AnalyzeSentiment(new Document() // { // Content = text, // Type = Document.Types.Type.PlainText // }); // var sentiment = response.DocumentSentiment; var articlesResult = await newsApiClient.GetTopHeadlinesAsync(new TopHeadlinesRequest { Language = Languages.EN, Country = Countries.US, //TODO: blend countries, but weight current country PageSize = 50 }); if (articlesResult.Status == Statuses.Ok) { // total results found Debug.Log(articlesResult.TotalResults); foreach (var article in articlesResult.Articles) { // title Debug.Log(article.Title); // description Debug.Log(article.Description + "\n " + article.Source.Id); // // url // Debug.Log(article.Url); // // image // Debug.Log(article.UrlToImage); // // published at Debug.Log(article.PublishedAt); } } else { Debug.Log(articlesResult.Error.Message); } _gcNaturalLanguage = GCNaturalLanguage.Instance; _gcNaturalLanguage.AnnotateTextSuccessEvent += _gcNaturalLanguage_AnnotateTextSuccessEvent; _gcNaturalLanguage.AnnotateTextFailedEvent += _gcNaturalLanguage_Failure; }