Click here to Skip to main content
15,879,535 members
Articles / Containers / Virtual Machine

Statistical parsing of English sentences

Rate me:
Please Sign up or sign in to vote.
4.95/5 (88 votes)
13 Dec 200617 min read 984.4K   23.6K   239  
Shows how to generate parse trees for English language sentences, using a C# port of OpenNLP, a statistical natural language parsing library.
using System;

namespace Netron.Lithium
{
	/// <summary>
	/// Generic Collectioon of GraphML related data
	/// </summary>
	public class GraphDataCollection : System.Collections.CollectionBase 
	{
    
		#region Properties
		/// <summary>
		/// integer indexer
		/// </summary>
		public virtual object this[int index] 
		{
			get 
			{
				return this.List[index];
			}
			set 
			{
				this.List[index] = value;
			}
		}
            
		#endregion

		#region Methods
		/// <summary>
		/// Adds and object to the collection
		/// </summary>
		/// <param name="o"></param>
		public virtual void Add(object o) 
		{
			this.List.Add(o);
		}
            
		
		/// <summary>
		/// Returns whether the given object is stored in the collection
		/// </summary>
		/// <param name="o">whatever object</param>
		/// <returns>true if contained otherwise false</returns>
		public virtual bool Contains(object o) 
		{
			return this.List.Contains(o);
		}
            
		
		/// <summary>
		/// Removes an element from the collection
		/// </summary>
		/// <param name="o"></param>
		public virtual void Remove(object o) 
		{
			this.List.Remove(o);
		}
		

		/// <summary>
		/// Overrides the default implementation to collect the data of the collection
		/// </summary>
		/// <returns></returns>
		public override string ToString() 
		{
			System.IO.StringWriter sw = new System.IO.StringWriter();
			// <foreach>
			// This loop mimics a foreach call. See C# programming language, pg 247
			// Here, the enumerator is seale and does not implement IDisposable
			System.Collections.IEnumerator enumerator = this.List.GetEnumerator();
			for (
				; enumerator.MoveNext(); 
				) 
			{
				string s = ((string)(enumerator.Current));
				// foreach body
				sw.Write(s);
			}
			// </foreach>
			return sw.ToString();
		}

		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
Richard Northedge is a senior developer with a UK Microsoft Gold Partner company. He has a postgraduate degree in English Literature, has been programming professionally since 1998 and has been an MCSD since 2000.

Comments and Discussions