UML class diagrams (1st pic) and frames (which belong to knowledge representation and artificial intelligence) (2nd pic) look pretty alike. But do class diagrams exactly type of frames or they just look similar?
There's no direct mapping between frame representations and a UML model. The frame language is something that is specific to representing knowledge in an AI system, while UML is designed for a generic model of software (primarily object-oriented software).
The first link you provided says this:
Frames are extensions of the traditional 'record' datatype used in databases. If you choose to program your agents in an object-oriented language such as Java or C++, then you will be able to represent knowledge as objects, which are very similar to frame structures.
The closest thing in UML to the frame notation is an object diagram. Each frame is a specific instance of a class. However, an object diagram (in the formal usage) doesn't allow you to capture all of the contextual information (in your example, things like "if difficult, then pay attention"). Many UML tools do allow for capturing notes as part of the model, though, which is how you would represent this.
A composite structure diagram may also show how a specific instance is built.
In order to accurately capture all of the information, you may also need a class diagram to show the general relationship between types.