Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Neural Dot Net Pt 3 The Adaline Network

, 23 Oct 2003
A neural network library in C#.
neural_dot_net_2002.zip
Neural Dot Net 2002
App.ico
bin
Debug
AdalineWordFile.dat
adalinewordWorkingFile.wrk
adword.trn
App.ico
BackpropagationWorkingFile.wrk
Lin2Var.trn
Neural Dot Net 2002.exe
Neural Net Library.dll
SelfOrganizingNetworkOne.trn
SelfOrganizingNetworkOne.wrk
SelfOrganizingNetworkOneTest.tst
SharpUtils.dll
SharpUtils.pdb
equations.Bak
Neural Dot Net 2002.csproj.user
Neural Net Library
bin
Debug
Neural Net Library.csproj.user
Neural Net Library.suo
obj
Debug
Neural Net Library.projdata
temp
TempPE
SharpUtils
bin
Debug
obj
Debug
SharpUtils.projdata
temp
TempPE
SharpUtils.csproj.user
SharpUtils.suo
neural_network_first_release.zip
Neural Network First release
3e5b39da.jpg
3e5b3ee8.jpg
3e65d686.jpg
3e65d687.jpg
Adaline.png
AdalineOneOptions.png
AdalineTwoOptions.jpg
AdalineWordClassDiagram.png
Adalinewordpattern.png
Addwordtoadalinetwofile.png
Backpropagationclasses.png
BackPropagationOneDiagram.png
backpropagationoneoptions.png
BackPropagationWordDiagram.png
BackPropagationWordOptions.png
BackPropagationWordPattern.png
Basic.png
BasicLinkWorks.png
BasicNetworkTester Overview.png
BasicNeuronComponent.png
changedBasicClassDiagram.png
equationTest.jpg
equationwithbias.jpg
function.jpg
Generating a given File.png
Inside Adaline Transition Function.png
Inside Self Organizing network run.png
Inside The Adaline Run Function Plus Bias.png
Inside The Adaline Run Function.png
learn For the self organizing network.png
Learning For the Backpropagation Network.png
LogViewer
LogViewer.csproj.user
Neural Net Library
Adaline.png
Adalinewordpattern.png
BackPropagation.emf
Basic.png
librarytobackprop.png
Neural Net Library.csproj.user
Pattern.png
Thumbs.db
Neural Net Test
App.ico
bin
Debug
AdalineWordFile.dat
adalinewordWorkingFile.wrk
adword.trn
AxInterop.SHDocVw.dll
BackpropagationWorkingFile.wrk
Interop.SHDocVw.dll
Lin2Var.trn
LogViewer.dll
Neural Net Library.dll
Neural Net Test.exe
SelfOrganizingNetworkOne.trn
SelfOrganizingNetworkOne.wrk
SelfOrganizingNetworkOneTest.tst
SharpUtils.dll
Neural Net Test.csproj.user
NeuralNetTesterPackages.png
Pattern.png
SelfOrganizingNetworkDiagram.png
SelfOrganizingNetworkOneClasses.png
selfOrganizingnetworkoneoptions.png
SelfOrganizingNetworkTwoOptions.png
selforganizingnetworkword.png
Setting Options For a Given Network.png
SharpUtils
SharpUtils.csproj.user
Testing a Given Network.png
Thumbs.db
Train Network Interaction.png
Training a given Network.png
TransferEq.jpg
TransferFunctionlogic.jpg
Transferfunctionwithbias.jpg
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Text;

namespace Neural_Net_Test
{
	/// <summary>
	/// Summary description for AddWordToAdalineWordFile.
	/// </summary>
	public class AddWordToAdalineWordFile : System.Windows.Forms.Form
	{
		private System.Windows.Forms.ListView listView1;
		private System.Windows.Forms.ColumnHeader columnHeader1;
		private System.Windows.Forms.ColumnHeader columnHeader2;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button3;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		private Icon icon;

		public AddWordToAdalineWordFile()
		{
			icon = new Icon( "App.ico" );
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			this.Icon = icon;

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			try
			{
				FileInfo file = new FileInfo( "AdalineWordFile.dat" );
				if( file.Exists == false )
				{
					MessageBox.Show( "Error Unable to find the AdalineWordFile" );
					this.Close();
				}

				FileStream stream = new FileStream( file.FullName, FileMode.Open, FileAccess.ReadWrite );
				StreamReader reader = new StreamReader( stream );
				string strString;
				double dValue = 0.0;
				
				while( reader.Peek() > -1 )
				{
					strString = reader.ReadLine();
					ListViewItem item = this.listView1.Items.Add( strString );
					
					for( int i=0; i<strString.Length; i++ )
					{
						dValue = strString[ i ] *i+1;
					}

					item.SubItems.Add( dValue.ToString() ); 
				}

				reader.Close();
			}
			catch( IOException ioExp )
			{
				MessageBox.Show( "Error io exception thrown " + ioExp.Message );
			}

			listView1.Sort();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(AddWordToAdalineWordFile));
			this.listView1 = new System.Windows.Forms.ListView();
			this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
			this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// listView1
			// 
			this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																						this.columnHeader1,
																						this.columnHeader2});
			this.listView1.FullRowSelect = true;
			this.listView1.Location = new System.Drawing.Point(8, 80);
			this.listView1.Name = "listView1";
			this.listView1.Size = new System.Drawing.Size(448, 97);
			this.listView1.Sorting = System.Windows.Forms.SortOrder.Ascending;
			this.listView1.TabIndex = 0;
			this.listView1.View = System.Windows.Forms.View.Details;
			// 
			// columnHeader1
			// 
			this.columnHeader1.Text = "Words";
			this.columnHeader1.Width = 186;
			// 
			// columnHeader2
			// 
			this.columnHeader2.Text = "Value";
			this.columnHeader2.Width = 231;
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(24, 40);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(152, 20);
			this.textBox1.TabIndex = 1;
			this.textBox1.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(256, 23);
			this.label1.TabIndex = 2;
			this.label1.Text = "Enter the word to add to the file";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(32, 208);
			this.button1.Name = "button1";
			this.button1.TabIndex = 3;
			this.button1.Text = "OK";
			this.button1.Click += new System.EventHandler(this.OnOK);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(328, 208);
			this.button2.Name = "button2";
			this.button2.TabIndex = 4;
			this.button2.Text = "Cancel";
			this.button2.Click += new System.EventHandler(this.OnCancel);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(192, 40);
			this.button3.Name = "button3";
			this.button3.TabIndex = 5;
			this.button3.Text = "Add";
			this.button3.Click += new System.EventHandler(this.OnAdd);
			// 
			// AddWordToAdalineWordFile
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(472, 246);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.button3,
																		  this.button2,
																		  this.button1,
																		  this.label1,
																		  this.textBox1,
																		  this.listView1});

			this.Name = "AddWordToAdalineWordFile";
			this.Text = "Add Word To Adaline Word File";
			this.ResumeLayout(false);

		}
		#endregion

		private void OnOK(object sender, System.EventArgs e)
		{
			FileInfo file = new FileInfo( "AdalineWordFile.dat" );
			if( file.Exists == false )
			{
				MessageBox.Show( "Error Unable to find the AdalineWordFile" );
				this.Close();
			}
			else
				file.Delete();

			FileStream stream = new FileStream( file.FullName, FileMode.Create, FileAccess.ReadWrite );
			StreamWriter writer = new StreamWriter( stream );

			ListView.ListViewItemCollection col = listView1.Items;

			foreach( ListViewItem item in col )
			{
				writer.WriteLine( item.Text );
			}

			writer.Close();

			this.Close();
		}

		private void OnCancel(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void OnAdd(object sender, System.EventArgs e)
		{
			ListViewItem item = new ListViewItem( textBox1.Text );
			double dValue = 0.0;
			string strTemp = textBox1.Text;
			string strCompare;
			bool bFound = false;

			for( int i=0; i<listView1.Items.Count; i++ )
			{
				strCompare = listView1.Items[ i ].Text;
				strCompare = strCompare.TrimEnd( ' ', '\n', '\r' );				
				if( strCompare == strTemp )
				{
					bFound = true;
					i = listView1.Items.Count;
				}
			}

			if( bFound == true )
			{
				MessageBox.Show( "The word " + strTemp + " is already in the list " );
				return;
			}
			
			for( int i=0; i<strTemp.Length; i++ )
			{
				dValue += strTemp[ i ] *i+1;
			}

			item.SubItems.Add( dValue.ToString() );

			listView1.Items.Add( item );
			listView1.Sort();
		}

	}
}

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

Share

About the Author

pseudonym67

United Kingdom United Kingdom
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140902.1 | Last Updated 24 Oct 2003
Article Copyright 2003 by pseudonym67
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid