The conceptnet module contains the Concept, Relation, Assertion, RawAssertion, Frame, SurfaceForm, and Frequency models, whose database structure appears in the following figure:
It also provides the non-database classes Proposition and Feature.
Concepts are the nodes of ConceptNet. They are the things that people have common sense knowledge about.
Concepts are expressed in natural language with sets of related words and phrases: for example, “take a picture”, “taking pictures”, “to take pictures”, and “you take a picture” are various surface forms of the same Concept.
Get the Concept represented by a given string of text.
If the Concept does not exist, this method will return None by default. However, if the parameter auto_create=True is given, then this will create the Concept (adding it to the database) instead.
You should not run the string through a normalizer, or use a string which came from Concept.text (which is equivalent). If you have a normalized string, you should use get_raw() instead.
Get the Concept whose normalized form is the given string.
If the Concept does not exist, this method will raise a Concept.DoesNotExist exception. However, if the parameter auto_create=True is given, then this will create the Concept (adding it to the database) instead.
Normalized forms should not be assumed to be stable; they may change between releases.
Get an arbitrary SurfaceForm representing this concept.
Returns None if the concept has no surface form.
Relation(id, name, description)
ConceptNet has a closed class of Relations, expressing connections between Concepts. This is the current set of relations, according to what question they each answer:
IsA | What kind of thing is it?
HasA | What does it possess?
PartOf | What is it part of?
UsedFor | What do you use it for?
AtLocation | Where would you find it?
CapableOf | What can it do?
MadeOf | What is it made of?
CreatedBy | How do you bring it into existence?
HasSubevent | What do you do to accomplish it?
HasFirstSubevent | What do you do first to accomplish it?
HasLastSubevent | What do you do last to accomplish it?
HasPrerequisite | What do you need to do first?
MotivatedByGoal | Why would you do it?
Causes | What does it make happen?
Desires | What does it want?
CausesDesire | What does it make you want to do?
HasProperty | What properties does it have?
ReceivesAction | What can you do to it?
DefinedAs | How do you define it?
SymbolOf | What does it represent?
LocatedNear | What is it typically near?
ObstructedBy | What would prevent it from happening?
ConceptuallyRelatedTo | What is related to it in an unknown way?
InheritsFrom | (not stored, but used in some applications)
Assertion(id, language_id, relation_id, concept1_id, concept2_id, score, frequency_id, best_surface1_id, best_surface2_id, best_raw_id, best_frame_id)
An Assertion is uniquely defined by the five properties (language, relation, concept1, concept2, frequency).
A RawAssertion represents the connection between an Assertion and natural language. Where an Assertion describes a Relation between two Concepts, a RawAssertion describes a sentence Frame that connects the SurfaceForms of those concepts.
A RawAssertion also represents how a particular Sentence can be interpreted to make an Assertion. surface1 and surface2 generally come from chunks of a sentence that someone entered into Open Mind.
Create a RawAssertion and a corresponding Assertion and Sentence from user input. Assign votes appropriately.
Requires the following arguments:
Features are not models in the database, but they are useful ways to describe the knowledge contained in the edges of ConceptNet.
A Feature is the combination of a Concept and a Relation. The combination of a Concept and a Feature, then, gives a Proposition, a statement that can have a truth value; when given a truth value, this forms an Assertion.
As an example, the relation PartOf(cello, orchestra) breaks down into the concept cello and the feature PartOf(x, orchestra). It also breaks down into orchestra and PartOf(cello, x).
Features can be left features or right features, depending on whether they include the left or right concept (that is, the first or second argument) in the Assertion. The Feature class itself is an abstract class, which is realized in the classes LeftFeature and RightFeature.
Each Assertion can be described with its left concept (concept1) and its right feature, or its right concept (concept2) and its left feature.
The notation is based on putting the relation in a “bucket”. For example, PartOf(cello, orchestra) = cello\PartOf/orchestra. Breaking this apart gives left and right features:
cello: PartOf/orchestra (left concept and right feature)
orchestra: cello\PartOf (right concept and left feature)
Create a LeftFeature or RightFeature (depending on which class you instantiate), with the given relation and concept.
A Proposition represents a statement that may or may not be true. It is like an Assertion without a truth value.
A Frame is a natural-language template containing two slots, representing a way that a Relation could be expressed in language.
It can be used for pattern matching to create a RawAssertion, or to express an existing RawAssertion as a sentence.