Example #1
0
        /// ------------------------------------------------------------------------------------
        public void FinalizeParse(string pattern, PhoneticParser phoneticParser)
        {
            // At this point we're assuming the pattern has already been checked to make
            // sure the *, +, and # are not misplaced or coexistent with each other.
            IsZeroOrMore          = (pattern == "*");
            IsOneOrMore           = pattern.Contains('+');
            IsInitialWordBoundary = pattern.StartsWith("#");
            IsFinalWordBoundary   = pattern.EndsWith("#");

            if (_runOfSymbols != string.Empty)
            {
                _groups.Add(_runOfSymbols);
            }

            _groupsLinkedList = new LinkedList <PhoneGroup>();

            for (int i = 0; i < _groups.Count; i++)
            {
                if (!(_groups[i] is string))
                {
                    _groupsLinkedList.AddLast(new PhoneGroup(_groups[i] as IEnumerable <string>));
                }
                else
                {
                    var run = (string)_groups[i];
                    _groups.RemoveAt(i--);

                    foreach (var phone in phoneticParser.Parse(run, true, false))
                    {
                        _groupsLinkedList.AddLast(new PhoneGroup(new List <string> {
                            phone
                        }));
                    }
                }
            }

            _groups = null;
        }