Artificial Intelligence Lecture No. 26 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.

Slides:



Advertisements
Similar presentations
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
Advertisements

Chapter 7: Introduction to CLIPS
Artificial Intelligence Lecture No. 18 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
Chapter 8: Advanced Pattern Matching Expert Systems: Principles and Programming, Fourth Edition.
Introduction to Python
How to Program in C++ CHAPTER 3: INPUT & OUTPUT INSTRUCTOR: MOHAMMAD MOJADDAM.
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
1 Character Strings and Variables Character Strings Variables, Initialization, and Assignment Reading for this class: L&L,
Microsoft Access 2010 Chapter 7 Using SQL.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Artificial Intelligence Lecture No. 15 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Input/Output Chapters 7 & 9. Output n Print produces output > (print 100) n It also returns the value it printed –that’s where the second 100 came.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Unix Talk #2 (sed). 2 You have learned…  Regular expressions, grep, & egrep  grep & egrep are tools used to search for text in a file  AWK -- powerful.
An Introduction to Unix Shell Scripting
Chapter 7: Introduction to CLIPS Expert Systems: Principles and Programming, Fourth Edition.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Artificial Intelligence Lecture No. 17 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Chapter 10: Procedural Programming Expert Systems: Principles and Programming, Fourth Edition.
Artificial Intelligence Lecture No. 29 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Input, Output, and Processing
Linux+ Guide to Linux Certification, Third Edition
(Stream Editor) By: Ross Mills.  Sed is an acronym for stream editor  Instead of altering the original file, sed is used to scan the input file line.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
CS 330 Programming Languages 10 / 02 / 2007 Instructor: Michael Eckmann.
JavaScript, Fourth Edition
Using Text Files in Excel File I/O Methods. Working With Text Files A file can be accessed in any of three ways: –Sequential access: By far the most common.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Artificial Intelligence Lecture No. 24 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
1 Lecture 9 Shell Programming – Command substitution Regular expressions and grep Use of exit, for loop and expr commands COP 3353 Introduction to UNIX.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
Artificial Intelligence Lecture No. 19 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Artificial Intelligence Lecture No. 23 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Think Possibility 1 Iterative Constructs ITERATION / LOOPS C provides three loop structures: the for-loop, the while-loop, and the do-while-loop. Each.
CHAPTER 2 PART #3 C++ INPUT / OUTPUT 1 st Semester King Saud University College of Applied studies and Community Service CSC1101 By: Fatimah.
Linux+ Guide to Linux Certification, Second Edition
Artificial Intelligence Lecture No. 22 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Objective Write simple computer program in C++ Use simple Output statements Become familiar with fundamental data types.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 17.
The CLIPS Expert System Shell Dr Nicholas Gibbins
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
1 Lecture 8 Shell Programming – Control Constructs COP 3353 Introduction to UNIX.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Chapter 22 – part a Stream refer to any source of input or any destination for output. Many small programs, obtain all their input from one stream usually.
Chapter 2 part #1 C++ Program Structure
Chapter 7: Introduction to CLIPS
Scripts & Functions Scripts and functions are contained in .m-files
Chapter 2 part #3 C++ Input / Output
Introduction to C++ Programming
Chapter 8: Advanced Pattern Matching
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
Chapter 11: Classes, Instances, and Message-Handlers
Unix Talk #2 (sed).
Notes about Homework #4 Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming:
Chapter 2 part #3 C++ Input / Output
Introduction to Programming - 1
Chapter 1 c++ structure C++ Input / Output
Presentation transcript:

Artificial Intelligence Lecture No. 26 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology (CIIT) Islamabad, Pakistan.

Summary of Previous Lecture If...then...else Function While loop Functions Loop-for-count Defining functions

Today’s Lecture Defglobal Construct File reading writing

Defglobal Construct With the defglobal construct, global variables can be defined, set, and accessed within the CLIPS environment. Global variables can be accessed as part of the pattern- matching process, but changing them does not invoke the pattern matching process. The bind function is used to set the value of global variables. Global variables are reset to their original value when the reset command is performed or when bind is called for the global with no values. Global variables can be removed by using the clear command or the undefglobal command.

Syntax (defglobal [ ] *) ::= = ::= ?* * There may be multiple defglobal constructs and any number of global variables may be defined in each defglobal statement. The optional indicates the module in which the defglobals will be defined. If none is specified, the globals will be placed in the current module.

Global variables may be used anyplace that a local variable could be used (with two exceptions). Global variables may not be used as a parameter variable for a deffunction, defmethod, or message-handler. Global variables may not be used in the same way that a local variable is used on the LHS of a rule to bind a value.

Therefore, the following rule is illegal (fact ?*x*) =>) Note that this rule will not necessarily be updated when the value of ?*x* is changed. For example, if ?*x* is 4 and the fact (fact 3) is added, then the rule is not satisfied. If the value of ?*x* is now changed to 2, the rule will not be activated.

File Open – The open function allows a user to open a file from the RHS of a rule and attaches a logical name to it. – This function takes three arguments: (1) the name of the file to be opened; (2) the logical name which will be used by other CLIPS I/O functions to access the file; and (3) an optional mode specifier.

The mode specifier must be one of the following strings: "r" read access only "w" write access only "r+" read and write access "a" append access only

Syntax (open [ ]) The must either be a string or symbol and may include directory specifiers. If a string is used, the backslash (\) and any other special characters that are part of must be escaped with a backslash. The open function returns TRUE if it was successful, otherwise FALSE.

Close The close function closes a file stream previously opened with the open command. The file is specified by a logical name previously attached to the desired stream. Syntax (close [ ]) If close is called without arguments, all open files will be closed. The user is responsible for closing all files opened during execution. If files are not closed, the contents are not guaranteed correct, however, CLIPS will attempt to close all open files when the exit command is executed. The close function returns TRUE if any files were successfully closed, otherwise FALSE.

Printout The function printout allows output to a device attached to a logical name. The logical name must be specified and the device must have been prepared previously for output (e.g., a file must be opened first). To send output to stdout, use a t for the logical name.

Syntax (printout *) Any number of expressions may be placed in a printout to be printed. Each expression is evaluated and printed (with no spaces added between each printed expression). The symbol crlf used as an will force a carriage return/newline and may be placed anywhere in the list of expressions to be printed. The printout function strips quotation marks from around strings when it prints them. This function has no return value.

Read The read function allows a user to input information for a single field. All of the standard field rules (e.g., multiple symbols must be embedded within quotes) apply.

Syntax (read [ ]) where is an optional parameter. If specified, read tries to read from whatever is attached to the logical file name. If is t or is not specified, the function will read from stdin. If an end of file (EOF) is encountered while reading, read will return the symbol EOF. If errors are encountered while reading, the string "*** READ ERROR ***" will be returned.

Readline The readline function is similar to the read function, but it allows a whole string to be input instead of a single field. Normally, read will stop when it encounters a delimiter. The readline function only stops when it encounters a carriage return, a semicolon, or an EOF. Any tabs or spaces in the input are returned by readline as a part of the string. The readline function returns a string.

Syntax (readline [ ]) where is an optional parameter. If specified, readline tries to read from whatever is attached to the logical file name. If is t or is not specified, the function will read from stdin. As with the read function, if an EOF is encountered, readline will return the symbol EOF. If an error is encountered during input, readline returns the string "*** READ ERROR ***".

Rename The rename function is used to change the name of a file. Syntax (rename ) Both and must either be a string or symbol and may include directory specifiers. If a string is used, the backslash (\) and any other special characters that are part of either or must be escaped with a backslash. The rename function returns TRUE if it was successful, otherwise FALSE.

Remove The remove function is used to delete a file. Syntax (remove ) The must either be a string or symbol and may include directory specifiers. If a string is used, the backslash (\) and any other special characters that are part of must be escaped with a backslash. The remove function returns TRUE if it was successful, otherwise FALSE.

Summery of Today’s Lecture Defglobal Construct File reading writing