private double AnalyseUsingTestData(string testBrainJSON, List <Review> foldBeingTested) { SentimentModel testBrain = new SentimentModel(testBrainJSON); //SentimentModel testBrain = new SentimentModel(File.ReadAllText("brain.json")); List <Review> originalFold = new List <Review>(); foreach (Review review in foldBeingTested) { originalFold.Add((Review)review.Clone()); } for (int i = 0; i < foldBeingTested.Count; i++) { foldBeingTested[i].sentiment = Review.Sentiment.blank; } for (int i = 0; i < foldBeingTested.Count; i++) { foldBeingTested[i] = testBrain.AnalyseReview(foldBeingTested[i]); } int accuracy = 0; for (int i = 0; i < foldBeingTested.Count; i++) { if (foldBeingTested[i].sentiment == originalFold[i].sentiment) { accuracy++; } else { } } return((accuracy / (double)foldBeingTested.Count) * 100); }
public SentimentPredictions() { sc = new SpectralClustering(); List <List <int> > rawCommunities = sc.FindCommunities(); SentimentModel model = new SentimentModel(File.ReadAllText("brain.json")); reviews = ReadFriendshipReviewData.readFileAsReview("friendships.reviews.txt");//.Where(r => r != null).ToList(); for (int i = 0; i < reviews.Count; i++) { reviews[i] = model.AnalyseReview(reviews[i]); } int communityIndex = 0; foreach (List <int> community in rawCommunities) { foreach (int user in community) { reviews[user].community = communityIndex; } communityIndex++; } foreach (Review user in reviews.Where(u => u.sentiment == Review.Sentiment.blank)) { PredictSentiment(user); } }
private static void Analyse() { SentimentModel model = new SentimentModel(File.ReadAllText("brain.json")); List <Review> reviews = ReadFriendshipReviewData.readFileAsReview("friendships.reviews.txt").Where(r => r != null).ToList(); for (int i = 0; i < reviews.Count; i++) { reviews[i] = model.AnalyseReview(reviews[i]); } reviews = reviews.Where(r => r.sentiment != Review.Sentiment.blank).ToList(); }