/// <summary> /// Adds an item in dictionary with given char and empty node /// </summary> /// <param name="nodeFor">Char to add to dictionary</param> /// <returns>Node for newly added node</returns> internal NodeWithValue <T> AddNode(char nodeFor) { if (NodeExists(nodeFor)) { throw new System.Exception("A node for char: " + nodeFor + " already exists. Cannot add duplicate. Possible loss of data."); } NodeWithValue <T> newNode = new NodeWithValue <T>(); _children.Add(nodeFor, newNode); return(newNode); }
/// <summary> /// List possible indexes for given dictionary /// </summary> private List <SplitPositionWithIdentification> GetPossibleEndIndexesList <T>(NodeWithValue <T> dictionary, char[] term, int startIndex, int endIndex, SplitIdentification splitIdentification) { List <SplitPositionWithIdentification> result = new List <SplitPositionWithIdentification>(); var nextNode = dictionary; for (int position = startIndex; position <= endIndex; position++) { if (nextNode == null) { break; } nextNode = nextNode.GetNode(term[position]); if (nextNode != null && nextNode.IsEnd) { result.Add(new SplitPositionWithIdentification(position, splitIdentification)); } } return(result); }
public TokenDictionary(IDictionary dictionary) { // Dictionary _dictionary = dictionary; _identifiedList = new List <string>(); // Tokens _tokens = new Node(); // Abbreviation _acronymDictionary = new NodeWithValue <List <string> >(); // Merged token _mergedTokenDictionary = new NodeWithValue <SplitWithIdentification>(); // Misspellings _misspelledWordDictionary = new NodeWithValue <string> (); _misspelledTokenDictionary = new NodeWithValue <string>(); // Stemmed _stemmedWordDictionary = new NodeWithValue <string>(); _stemmedTokenDictionary = new NodeWithValue <string>(); }