Besides logic and rules, there are structured schemes that organise knowledge about objects, their parts and their typical behaviour.

Semantic Networks

A semantic network is a graph in which nodes are concepts or objects and labelled arcs are the relations between them. Common relations are is-a, which links a type to a more general type, and has-part. For example, Canary is-a Bird, Bird is-a Animal, and Bird has-part Wings. A key feature is inheritance: a node takes the properties of the nodes above it, so a canary can fly, because a bird can. Semantic networks are easy to draw and understand. Their weaknesses are that the meaning of links is not fixed, and that they have no clear way to express negation or quantifiers.

Definition: Semantic network. A graph that represents knowledge, with nodes for concepts and objects and labelled arcs for the relations between them, supporting inheritance along is-a links.

Frames

A frame, proposed by Marvin Minsky, is a data structure for a typical object or situation. It has slots, which are attributes, and each slot has a value, a default value, or a procedure called a demon that runs when the slot is read or changed. Frames are linked in a hierarchy, and a frame inherits slot values from its parent. For example, the frame Student may have slots name, roll number, course and a default value of year. The frame for a particular student, Asha, inherits from Student and fills in the values. Frames are close to objects in programming.

Scripts

A script, proposed by Schank and Abelson, is a structure that describes a stereotyped sequence of events in a familiar situation, such as eating at a restaurant. A script has entry conditions, props such as tables and menus, roles such as customer and waiter, a series of scenes and results. Using a script, a system can fill in missing steps when a story says only that a person went into a restaurant and paid, since it knows that the person was also served food. Scripts support the understanding of stories.

Table 2.5: Structured schemes

Scheme Structure Best for
Semantic net Graph of concepts and relations Taxonomies, inheritance
Frame Slots with values and defaults Typical objects
Script Sequence of scenes Stereotyped events

Example 2.5: Inheritance in a semantic network

Problem: Given Canary is-a Bird, Bird is-a Animal, Bird has Wings, Animal has Skin, and Canary colour Yellow, list the properties of Canary.

Solution:

  1. Canary has its own property: colour Yellow.
  2. From Bird: has Wings.
  3. From Animal, through Bird: has Skin.

Result: A canary is yellow, has wings and has skin, by inheritance up the is-a links.

isa = {"Canary": "Bird", "Bird": "Animal"}
props = {"Canary": ["yellow"], "Bird": ["wings"], "Animal": ["skin"]}
n, out = "Canary", []
while n:
    out += props.get(n, [])
    n = isa.get(n)
print(out)

Output

['yellow', 'wings', 'skin']

Common mistakes

  • Forgetting that a node inherits properties through every is-a link above it.
  • Treating frame default values as certain facts. A specific value overrides them.
  • Using a script for an event that has no standard order.

Key takeaways

  • A semantic network is a graph of concepts with labelled links such as is-a.
  • Inheritance passes properties down the hierarchy.
  • A frame has slots with values, defaults and procedures.
  • A script is a stereotyped sequence of events with roles and scenes.

Practice questions

  1. What is a semantic network?
  2. What is a frame?
  3. What is a script?

Answers to the practice questions

  1. A graph with concepts as nodes and labelled arcs for relations between them.
  2. A structure with slots, values and defaults that describes a typical object or situation.
  3. A structure describing a stereotyped sequence of events, such as dining at a restaurant.

Sources

  • Official BCA syllabus Artificial Intelligence and Expert Systems, course code 25BCA405DS02, Unit II