public override void PopulateArff(IParsedReview current, PositivityType positivity) { if (current is null) { throw new ArgumentNullException(nameof(current)); } lock (DataSet) { var review = DataSet.AddDocument(); review.Class.Value = positivity; foreach (var word in current.ImportantWords) { var item = review.AddRecord(word.Text); if (item == null) { continue; } var existing = (double?)item.Value; if (existing == null) { existing = 0; } item.Value = (double)1 + existing.Value; } } }
public override void PopulateArff(IParsedReview review, PositivityType positivity) { if (review == null) { throw new ArgumentNullException(nameof(review)); } review.Reset(); review.Vector.GenerateUsingImportantOnly = true; AddData(review.Document.Id, review.Date, review.Vector, positivity); review.Vector.GenerateUsingImportantOnly = false; }
public void PopulateArff(IParsedReview[] processings, PositivityType positivity) { if (processings is null) { throw new ArgumentNullException(nameof(processings)); } if (processings.Length == 0 || processings.Any(x => x is null)) { throw new ArgumentException("Value cannot be an empty collection and not null.", nameof(processings)); } Parallel.ForEach( processings, AsyncSettings.DefaultParallel, review => PopulateArff(review, positivity)); }
private bool CanInclude(string text, PositivityType type) { if (type == PositivityType.Positive) { return(negative.All(word => text.IndexOf(word, StringComparison.OrdinalIgnoreCase) < 0)); } foreach (var word in positive) { if (text.IndexOf(word, StringComparison.OrdinalIgnoreCase) >= 0) { return(false); } } return(true); }
public abstract void PopulateArff(IParsedReview current, PositivityType positivity);
public SentimentDiscovery(PositivityType type, IMessageDiscovery discovery) { Type = type; Discovery = discovery; }
private IArffDataRow AddData(string id, DateTime?date, ExtractTextVectorBase extractTextVector, PositivityType positivity) { var cells = extractTextVector.GetCells(); if (cells.Count == 0) { return(null); } lock (DataSet) { IArffDataRow review = string.IsNullOrEmpty(id) ? DataSet.AddDocument() : DataSet.GetOrCreateDocument(id); review.Class.Value = positivity; review.Date = date ?? DateTime.Today; foreach (var cell in cells) { var name = cell.Name; var data = review.AddRecord(name); if (data != null) { data.Header.Source = cell.Item; data.Value = cell.Value; } } return(review); } }
public SentimentData(PositivityType type) { Type = type; }