Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        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>();
        }