public void AddItem(IWordItem item) { if (item == null) { return; } if (!item.IsSimple) { throw new ProcessingException("Can add only simple word item type"); } if (item.IsSimpleConjunction()) { return; } if (items.Count > 0) { var previous = items[items.Count - 1]; item.Relationship.Previous = previous; previous.Relationship.Next = item; } items.Add(item); if (item.Parent != null) { item.Parent.Relationship.Part = this; } item.Relationship.Part = this; AddRelationship(item); windowItems.Add(item, item); windowItems.Increment(); }
public void Add(IWordItem word) { if (word == null) { throw new System.ArgumentNullException(nameof(word)); } if (occurrences.Contains(word) || word.IsSimpleConjunction()) { return; } occurrences.Add(word); if (!word.IsStopWord) { nonStop.Add(word); } word.Parent = this; Relationship.Part = word.Relationship.Part; if (Relationship.Previous != null) { Relationship.Previous = word.Relationship.Previous; } Relationship.Next = word.Relationship.Next; Stemmed = nonStop .Select(item => item.Stemmed) .AccumulateItems(" "); Text = occurrences .Select(item => item.Text) .AccumulateItems(" "); if (string.IsNullOrEmpty(Stemmed)) { Stemmed = Text; } }