AI System useful short codes for Programmers
In this topic, you will find the most helpful summary of the AI system presented by Azizi.
Expert: a person or machine who has acquired skills from experience.
Expert System: it’s a piece of software that contains useful facts, data, and relationships, used to solve the issues.
MYCIN: used for diagnosing blood disorders and the use of this program is optimal, BUT the final decision depends upon the physician.
DENDRAL: used to identify the structure of chemical compounds.
PROSPECTOR: used by geologists to identify sites for mining or drilling.
El: it’s an excellent tool for assisting the design engineer, which analyzes electronic circuits made up of diodes, and transistors.
DELTA: used to assist maintenance personnel in locating problems in diesel-electric locomotive engines.
Miscellaneous Applications (Weather Forecasting /Aircraft Identification /Battlefield Management)
Advantage
Allow non-experts to do the work of experts / Improve productivity / Save time / Simplify some operations / overly complex processes / Capture and store valuable knowledge forever.
Disadvantage
Development is difficult / very expensive / not 100% reliable
Type of Expert System
Stand-Alone: it’s a software package that runs on a personal computer, minicomputer, or mainframe.
Embedded: it’s just a portion of another larger program.
Working with Expert Systems
The components are (the knowledge base, inference system, the database, and user interface)
Knowledge base: it’s the heart of an expert system, and there are many different methods for representing knowledge in AI software.
Rule: any kind of knowledge can be written to fit the IF-THEN rule format, and formatted into two parts;
IF the animal lives in the water
AND the animal breathes in water
THEN the animal is a fish
Database: it contains information about the current status of the problem to be solved.
Inference Engine: it’s the brain of the expert system , which is a computer program that derive answers from a knowledge base.
User Interface: its The front end that enables to communication with the inference engine & knowledge base.
Steps to retrieve data from Data source:
1-connect to the data source: use” connection string, name of the provider, database user, password…”
2: open the connection
3: issue a SQL query
4: Read and display the data with a data reader
5: close the data reader and the connection
@ : its an operator used to not face errors in SQL commands.
=========================================================
Browse the picture in the program: there are two methods
1- store pictures in a database , which is stored in byte format, not in jpg or other.
2-put pictures in a folder put their path in database, and use the built-in library to convert it.
Open File Dialog(OFD): is a class used to browse a file.
OpenFileDialog ofd = new openFileDialog();
ofd.showDialog();
pictureBox1.imagelocation = ofd.FileName;
//for filteration ; ofd.Filter = “JPG files|*.jpg|JPEG files|*.JPEG|PNG files|*.png|All files|*.*”;
Memory stream class: is a memory location where we can store our file or picture, which is located in
system.io namespace,
image.FromStream: a function used to convert a picture from byte to its original type.
Image List: used to manage a collection of images used by other controls, like list view, tree, etc…
If we want to make our application setting and connection to the instance dynamic, we need to add an application configuration file or App. config.
Data Grid View: its like list view, in this we would create tables, columns rows manually and set data to it
Key pressed: when a key is pressed it should be validated.
eg: with the key pressed we want to get the key pressed and to be shown:
char ch = e.keychain; MessageBox.show(ch.toString());
Leave Control for Name TextBox, when its left null;
if(txtname.text == “” || txtname.text ==null) { txtname.BackColor = color.Red; }
Regular Expression:
for the handling of a regular expression, we use namespace system.text.regularexpression, there is a class named reject class used for the regular expression.
We use leave Event for mobile Numbers and implement validations like country code, 10digits, and others.
This regular expression is used to start with 07 digit: @”^(07)[1-9]{8}$”;
This regular expression is used to start with country code: @”^(\+)[0-9]{2,3}[1-9]{9}$”;
User Control: used to have user information, and used for preconfigured in any part of our program.
Timer Control: it’s a control that if we want to execute a code after a time interval automatically then timer control is used.
Leave Control: when the user leaves the textbox, for example, it should validate.
Error Provider Control: used to give a warning to the User with a message.
if(txtname.text == “” || txtname.text ==null) { errorProvider1.SetError(txt name, “Input name”); }
=================== ==============================
Using File System for File and Folder Creation: We can use System.I/O namespace.
Creating a Directory:
Directory.CreateDirectory(“F:\\test\\test folder”);
we can have conditions for directory creation and void duplicate:
if(!Directory.Exist(“F:\\test\\test folder”)) Directory.CreateDirectory(“F:\\test\\test folder”);
else{ Directory.CreateDirectory(“F:\\test\\test folder1”); }
Check Folder Info: we use directory info Class(System.IO namespace)to get different information like Data and Time, Full Name, full path for directory etc….
DirectoryInfo dirinfo = new DirectoryInfo(@”F:\test”);
MessageBox.Show(dirinfo.CreationTime.ToString());
Create File:we can use file info class and file classs as well,
for(int i=0;i<10;i++) { file.create(@”F:\test\test folder1\test file”+i.ToString()+”.txt”; }
Application configuration File: to have a dynamic connection we save our connection on xml file, we can do it through application configuration File:
====================================================
File Stream :
File stream class is child class of stream class, which represent a file in the computer. Used to read a form ,write to, open and close file on file system.
Methods to read the data : byte by byte and character by character .
Decoder and Encoder Class : converting byte to character is called decoding and converting character to byte is called encoding .
Steps :
1-Should know the File Location
2-the data is in byte format in file ,and we should have byte array to save the readied data in it .
3-should copy the Byte array data in to character data array, mean should have the Character array.
4-convert character array in to string.
5- initialize the string data to text box
Character by character Method or format:
Stream reader: it’s a class in “System. I/O” namespace used to read the data.
We can pass reference of child object to a parent object.
Stream writer: it’s a class in “System. I/O” namespace used to write or edit the data.
Text and text box type: plane text (no collar, no format and we used simple text box for it) and rich text which used rich text box.
Name space: are the containers ,which organize our codes for ease and good programming access.
=================================================
Exception Handling:
Exception occur when the program is running and will terminate the program.
Exception is a class “Exception Class In system Name space” Used to handle the exception “error “and to prevent abnormally termination of program. and has 3 blocks:
Try block: the code which may have the exception should writ in it.
Catch block: in catch block we will catch the exception, and it will execute if the exception occurs in try block, and we can have many catch blocks after a single try block.
finally block: it will execute at any time, mean the exception occur on not occur.
Exception Types: Application Exception and system exception which are derived from Exception class.
Build in Exception’ derive from system exception class.
User Define Exception’ derive from Application Exception class.
===========================================================
Application Trading:
Trade mean process and by default one trade should be in every application which is called main trade, and the other trades are child of it.
2-Single Trading Application: an application which can perform only one process at a time.
3-Multi Trading Application: an application which can perform many process at a time, and used to improve the Application performance. We can schedule the trades “giving priority to them…”.
Its cods are in Library in system. Multi trading namespace.
In C# form ‘We can’t access the control which has written on an other trade, mean every trade can access only their own controls.
Invoke function: it’s a function which call when the control is create in one trade and the property is created in to another trade.
Note: the parent class can save and catch the child class reference .and we can pass the child object to parent class as well.
=================================================
Reporting :
Using reporting we can share data, summarize data, create summarize reports .
Cristal Report : made by a third party, its free and open source and available in the internet. Cristal report for c# 2010…
Report sections are ( report header ,page header ,Data section , Report footer , page footer) we need the report viewer to display the report into form.
Report Filtration : we can do it by 2 Methods ; by crystal report and by query