private void PopulateAttributes(SentimentVector vector, WordEx word, IWordItem original) { var record = nrcDictionary.FindRecord(word); vector.ExtractData(record); word.Emotions = record?.GetDefinedCategories().ToArray(); word.Attributes = original.Inquirer.Records.SelectMany(item => item.Description.Attributes).ToArray(); }
public void Save(ProcessingContext context) { var vector = new SentimentVector(); if (ExtractStyle) { foreach (var word in context.Processed.Words) { vector.ExtractData(dictionary.FindRecord(word)); } } lock (csvDataOut) { csvDataOut.WriteField(context.Original.Id); csvDataOut.WriteField(context.Original.DocumentTime); csvDataOut.WriteField(context.Original.Stars); csvDataOut.WriteField(context.Adjustment.Rating.StarsRating); csvDataOut.WriteField(context.Review.GetAllSentiments().Length); if (ExtractStyle) { csvDataOut.WriteField(vector.Anger); csvDataOut.WriteField(vector.Anticipation); csvDataOut.WriteField(vector.Disgust); csvDataOut.WriteField(vector.Fear); csvDataOut.WriteField(vector.Joy); csvDataOut.WriteField(vector.Sadness); csvDataOut.WriteField(vector.Surprise); csvDataOut.WriteField(vector.Trust); csvDataOut.WriteField(vector.Total); } csvDataOut.NextRecord(); csvDataOut.Flush(); } if (Debug) { resultsWriter.WriteObject(context.Processed); } }
public static SentimentVector Extract(this INRCDictionary dictionary, IEnumerable <WordEx> words) { if (dictionary is null) { throw new ArgumentNullException(nameof(dictionary)); } if (words is null) { throw new ArgumentNullException(nameof(words)); } var vector = new SentimentVector(); foreach (var word in words) { vector.ExtractData(dictionary.FindRecord(word)); } return(vector); }
public static void ExtractToVector(this INRCDictionary dictionary, SentimentVector vector, IEnumerable <IWordItem> words) { if (dictionary is null) { throw new ArgumentNullException(nameof(dictionary)); } if (vector is null) { throw new ArgumentNullException(nameof(vector)); } if (words is null) { throw new ArgumentNullException(nameof(words)); } foreach (var word in words) { vector.ExtractData(dictionary.FindRecord(word)); } }