예제 #1
0
        public static void ExtractKeywordsFromUrl(interaction_url interaction_url, string url, Repository tycheRepo)
        {
            AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();
            alchemyObj.SetAPIKey(ConfigurationManager.AppSettings["AlchemyAPIKey"]);

            string xml;
            XDocument xdoc;

            try
            {
                xml = alchemyObj.URLGetRankedKeywords(url);
            }
            catch
            {
                xml = "";
            }

            if (xml != "")
            {
                xdoc = XDocument.Load(new StringReader(xml));
                foreach (XElement e in xdoc.Descendants("keyword"))
                {
                    interaction_url_keyword keyword = new interaction_url_keyword();
                    keyword.interaction_url_id = interaction_url.id;
                    keyword.keyword = e.Element("text").Value;
                    keyword.keyword_count = 1;
                    keyword.keyword_relevance = decimal.Parse(e.Element("relevance").Value);
                    keyword.keyword_sentiment = e.Element("sentiment").Element("type").Value;
                    if (e.Element("sentiment").Element("score") != null)
                        keyword.keyword_sentiment_score = decimal.Parse(e.Element("sentiment").Element("score").Value);
                    else
                        keyword.keyword_sentiment_score = 0;
                    tycheRepo.Add(keyword);
                }

                tycheRepo.Save();

                Thread.Sleep(12);
            }
        }
		private void detach_interaction_url_keywords(interaction_url_keyword entity)
		{
			this.SendPropertyChanging();
			entity.interaction_url = null;
		}
 partial void Updateinteraction_url_keyword(interaction_url_keyword instance);
 partial void Deleteinteraction_url_keyword(interaction_url_keyword instance);
 partial void Insertinteraction_url_keyword(interaction_url_keyword instance);