ABB.Swum.UnigramTagger.PreTag C# (CSharp) Метод

PreTag() публичный Метод

Performs various actions that should occur prior to further tagging. This method tags any digits in the name, identifies and removes any preamble, and tags any prepositions remaining in the name.
public PreTag ( ProgramElementNode node ) : void
node ABB.Swum.Nodes.ProgramElementNode The node to be tagged.
Результат void
        public override void PreTag(ProgramElementNode node)
        {
            if (node == null) { return; }

            TagDigits(node.ParsedName);

            if (node.Preamble == null)
            {
                int wordIndex = 0;
                bool checkForMorePreamble = true;
                //identify and tag any preamble words
                while (node.ParsedName.Size() > 1 && checkForMorePreamble)
                {
                    checkForMorePreamble = false;

                    //skip any digits
                    while (wordIndex < node.ParsedName.Size() && node.ParsedName[wordIndex].Tag == PartOfSpeechTag.Digit) { wordIndex++; }

                    //check if word is preamble
                    if (wordIndex < node.ParsedName.Size() - 1)
                    {
                        string word = node.ParsedName[wordIndex].Text;
                        if (word.Length == 1 ||
                            (word.Length == 2 && !pos.IsTwoLetterDictionaryWord(word)) ||
                            (word.Length < 5 && !Regex.IsMatch(word, ".*[gs]et.*") && !pos.IsPotentialVerb(word) &&
                             positionalFrequencies.GetOnlyFrequency(word) == 0 && positionalFrequencies.GetFirstFrequency(word) > 0))
                        {
                            node.ParsedName[wordIndex].Tag = PartOfSpeechTag.Preamble;
                            wordIndex++;
                            checkForMorePreamble = true;
                        }
                    }
                }

                //move preamble words from ParsedName to Preamble
                node.Preamble = node.ParsedName.GetNewEmpty();
                for (int j = 0; j < wordIndex; j++)
                {
                    node.Preamble.Add(node.ParsedName[0]);
                    node.ParsedName.RemoveWord(0);
                }
            }

            TagPrepostions(node.ParsedName);
        }