/// <summary> /// Concatenates the supplied phrase to the end of the current phrase. /// </summary> /// <param name="phrase">The phrase to add.</param> public void Add(PhraseNode phrase) { if (phrase != null) { Words.AddRange(phrase.GetPhrase()); } }
/// <summary> /// Tags any word nodes in the given phrase that are prepositions. /// </summary> /// <param name="phrase">The phrase to tag.</param> public void TagPrepostions(PhraseNode phrase) { if (phrase == null) { return; } foreach (var word in phrase.GetPhrase()) { if (pos.IsPreposition(word.Text)) { word.Tag = PartOfSpeechTag.Preposition; } } }
/// <summary> /// Tags any word nodes in the given phrase that contain digits. /// </summary> /// <param name="phrase">The phrase to tag.</param> public void TagDigits(PhraseNode phrase) { if (phrase == null) { return; } foreach (var word in phrase.GetPhrase()) { if(Regex.IsMatch(word.Text, @"\d+")) { word.Tag = PartOfSpeechTag.Digit; } } }
private bool IsPrepositionalPhrase(PhraseNode parsedName) { foreach (WordNode word in parsedName.GetPhrase()) { if (word.Tag == PartOfSpeechTag.Preposition) { return true; } } return false; }
/// <summary> /// Finds all the verbs in the given name and adds them to the given preamble. /// </summary> /// <param name="parsedName">The PhraseNode to gets the verbs from.</param> /// <param name="preamble">The preamble PhraseNode to add the verbs to.</param> /// <returns>The preamble PhraseNode with the verbs added.</returns> private PhraseNode GetVerbPhrase(PhraseNode parsedName, PhraseNode preamble) { //TODO: should this make a copy of the preamble first? PhraseNode phrase = preamble; foreach (WordNode word in parsedName.GetPhrase()) { if (word.Tag == PartOfSpeechTag.Verb || word.Tag == PartOfSpeechTag.VerbModifier || word.Tag == PartOfSpeechTag.VerbParticle || word.Tag == PartOfSpeechTag.NonVerb || word.Tag == PartOfSpeechTag.VerbIgnorable) { phrase.Add(word); } } return phrase; }
/// <summary> /// Concatenates the supplied phrase to the end of the current phrase. /// </summary> /// <param name="phrase">The phrase to add.</param> public void Add(PhraseNode phrase) { if(phrase != null) { Words.AddRange(phrase.GetPhrase()); } }