Пример #1
0
 /// <summary>
 /// Creates a new WordNode.
 /// </summary>
 /// <param name="text">The actual text of the word.</param>
 /// <param name="tag">The part-of-speech of the word.</param>
 /// <param name="confidence">A rating of the confidence of the part-of-speech tagging for this word.</param>
 public WordNode(String text, PartOfSpeechTag tag, double confidence) {
     if(text == null) { throw new ArgumentNullException("text"); }
     this.Text = text;
     this.Tag = tag;
     this.Confidence = confidence;
     if(text == text.ToUpper()) { this.AllCaps = true; }
 }
Пример #2
0
 /// <summary>
 /// Creates a new WordNode.
 /// </summary>
 /// <param name="text">The actual text of the word.</param>
 /// <param name="tag">The part-of-speech of the word.</param>
 /// <param name="confidence">A rating of the confidence of the part-of-speech tagging for this word.</param>
 public WordNode(String text, PartOfSpeechTag tag, double confidence)
 {
     if (text == null)
     {
         throw new ArgumentNullException("text");
     }
     this.Text       = text;
     this.Tag        = tag;
     this.Confidence = confidence;
     if (text == text.ToUpper())
     {
         this.AllCaps = true;
     }
 }
Пример #3
0
        private int GetWeightForPartOfSpeech(PartOfSpeechTag pos)
        {
            const int NormalWeight     = 1;
            const int PrimaryPosWeight = 5;
            const int PreambleWeight   = 0;
            var       primaryPos       = new[] { PartOfSpeechTag.Noun, PartOfSpeechTag.NounPlural, PartOfSpeechTag.PastParticiple, PartOfSpeechTag.Verb, PartOfSpeechTag.Verb3PS, PartOfSpeechTag.VerbIng };

            int result = NormalWeight;

            if (primaryPos.Contains(pos))
            {
                result = PrimaryPosWeight;
            }
            else if (pos == PartOfSpeechTag.Preamble)
            {
                result = PreambleWeight;
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        /// Returns a PhraseNode containing the noun phrase words from the given name, starting from startIndex.
        /// All noun phrase words prior to the first encountered preposition are included.
        /// </summary>
        /// <param name="parsedName">The PhraseNode to get the noun phrase from.</param>
        /// <param name="startIndex">The index of the word to start from.</param>
        private PhraseNode GetNounPhrase(PhraseNode parsedName, int startIndex)
        {
            PhraseNode phrase = parsedName.GetNewEmpty();

            for (int i = startIndex; i < parsedName.Size(); i++)
            {
                PartOfSpeechTag tag = parsedName[i].Tag;
                if (tag == PartOfSpeechTag.Noun ||
                    tag == PartOfSpeechTag.NounModifier ||
                    tag == PartOfSpeechTag.Determiner ||
                    tag == PartOfSpeechTag.Pronoun ||
                    tag == PartOfSpeechTag.NounIgnorable ||
                    tag == PartOfSpeechTag.Digit ||
                    tag == PartOfSpeechTag.Preamble)
                {
                    phrase.Add(parsedName[i]);
                }
                else if (tag == PartOfSpeechTag.Preposition)
                {
                    break;
                }
            }
            return(phrase);
        }
Пример #5
0
 /// <summary>
 /// Creates a new WordNode. The confidence is set to the default value of 0.0.
 /// </summary>
 /// <param name="text">The actual text of the word.</param>
 /// <param name="tag">The part-of-speech of the word.</param>
 public WordNode(String text, PartOfSpeechTag tag) : this(text, tag, 0.0) { }
Пример #6
0
 /// <summary>
 /// Returns a new node of the same type, containing the given text and part-of-speech tag.
 /// </summary>
 /// <param name="text">The text of the new word.</param>
 /// <param name="tag">the part-of-speech tag of the new word.</param>
 public virtual WordNode GetNewWord(string text, PartOfSpeechTag tag) {
     return new WordNode(text, tag);
 }
Пример #7
0
 /// <summary>
 /// Creates a new WordNode. The confidence is set to the default value of 0.0.
 /// </summary>
 /// <param name="text">The actual text of the word.</param>
 /// <param name="tag">The part-of-speech of the word.</param>
 public WordNode(String text, PartOfSpeechTag tag) : this(text, tag, 0.0)
 {
 }
Пример #8
0
 /// <summary>
 /// Returns a new node of the same type, containing the given text and part-of-speech tag.
 /// </summary>
 /// <param name="text">The text of the new word.</param>
 /// <param name="tag">the part-of-speech tag of the new word.</param>
 public virtual WordNode GetNewWord(string text, PartOfSpeechTag tag)
 {
     return(new WordNode(text, tag));
 }