コード例 #1
0
        public static void ExtractEntitiesFromUrl(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.URLGetRankedNamedEntities(url);
            }
            catch
            {
                xml = "";
            }

            if (xml != "")
            {
                xdoc = XDocument.Load(new StringReader(xml));
                foreach (XElement e in xdoc.Descendants("entity"))
                {
                    interaction_url_entity entity = new interaction_url_entity();
                    entity.interaction_url_id = interaction_url.id;
                    entity.entity = e.Element("text").Value;
                    entity.entity_count = int.Parse(e.Element("count").Value);
                    entity.entity_relevance = decimal.Parse(e.Element("relevance").Value);
                    entity.entity_sentiment = e.Element("sentiment").Element("type").Value;
                    if (e.Element("sentiment").Element("score") != null)
                        entity.entity_sentiment_score = decimal.Parse(e.Element("sentiment").Element("score").Value);
                    else
                        entity.entity_sentiment_score = 0;
                    tycheRepo.Add(entity);
                }

                tycheRepo.Save();

                Thread.Sleep(12);
            }
        }
コード例 #2
0
        public void ParseLinks(List<interaction> tweets)
        {
            for (int i = 0; i < tweets.Count; i++)
            {
                string tweet = tweets[i].content_id;

                if (tweet.Length == 0)
                {
                    continue;
                }
                MatchCollection mc = Regex.Matches(tweet, @"(www[^ \s]+|http[^ \s]+)([\s]|$)", RegexOptions.IgnoreCase);
                for (int j = 0; j < mc.Count; j++)
                {
                    string url = mc[j].Value;

                    interaction_url interactionUrl = new interaction_url();
                    interactionUrl.interaction_id = tweets[i].id;
                    interactionUrl.url = url;
                    TycheRepository.Add(interactionUrl);

                    TycheRepository.Save();

                    #region Keyword extraction
                    Common.ExtractKeywordsFromUrl(interactionUrl, url, TycheRepository);
                    #endregion

                    #region Entity extraction
                    Common.ExtractEntitiesFromUrl(interactionUrl, url, TycheRepository);
                    #endregion

                    TycheRepository.UpdateLastInteractionProcessed(tweets[i].id, InteractionProcessedAction.Url);

                    TycheRepository.Save();
                }
            }
        }
コード例 #3
0
 partial void Deleteinteraction_url(interaction_url instance);
コード例 #4
0
 partial void Updateinteraction_url(interaction_url instance);
コード例 #5
0
 partial void Insertinteraction_url(interaction_url instance);
コード例 #6
0
		private void detach_interaction_urls(interaction_url entity)
		{
			this.SendPropertyChanging();
			entity.interaction = null;
		}