public static void ExtractEntities(int tweetId, string text, Repository tycheRepo) { AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI(); alchemyObj.SetAPIKey(ConfigurationManager.AppSettings["AlchemyAPIKey"]); string xml; XDocument xdoc; try { xml = alchemyObj.TextGetRankedNamedEntities(text); } catch { xml = ""; } if (xml != "") { xdoc = XDocument.Load(new StringReader(xml)); foreach (XElement e in xdoc.Descendants("entity")) { interaction_entity entity = new interaction_entity(); entity.interaction_id = tweetId; 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.UpdateLastInteractionProcessed(tweetId, InteractionProcessedAction.Entity); tycheRepo.Save(); Thread.Sleep(12); } }
partial void Deleteinteraction_entity(interaction_entity instance);
partial void Insertinteraction_entity(interaction_entity instance);
partial void Updateinteraction_entity(interaction_entity instance);
private void detach_interaction_entities(interaction_entity entity) { this.SendPropertyChanging(); entity.interaction = null; }