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.
The Language that this concept is in.
The normalized text for this concept.
A cached value for the number of words in the concept’s normalized form. This gives an estimate of the complexity of the 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 all Assertions about this concept.
Get all Assertions with this concept on the left.
Get all Assertions with this concept on the right.
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)
A standardized string naming this relation.
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).
The Language that the assertion is expressed in.
A Frequency expressing how often the given concepts would be related by the given relation, ranging from “never” to “always”.
A coarse-grained version of the frequency. The polarity is +1 if the assertion makes a positive statement (such as “people want to be happy”) and -1 if it makes a negative statement (such as “people do not want to be shot”).
A cached value representing the reliability of this Assertion: the number of people who support it (including anyone who entered a Sentence that it represents), minus the number of people who oppose it. The score is determined from the voting.Vote objects that apply to this Assertion.
Get the highest scoring RawAssertion for this assertion.
Set a user’s Vote on a certain object. If the user has previously voted on that object, it removes the old vote.
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.
The Sentence that was parsed to form this RawAssertion.
The User responsible for this RawAssertion.
The SurfaceForm of the phrase (concept) that fills the first slot of the frame.
The SurfaceForm of the phrase (concept) that fills the second slot of the frame.
The Language that this RawAssertion is in.
A cached value representing the reliability of this RawAssertion: the number of people who support it (including the person who originally entered it), minus the number of people who oppose it. The score is determined from the voting.Vote objects that apply to this RawAssertion.
Reconstruct the natural language representation. The text concepts are passed to the wrap_text function to allow a view to wrap them in a link (or do any other transformation.) The prototype for wrap_text is wrap_text(assertion, text), where assertion is this RawAssertion object and text is the natural-language text of the concept (text1 or text2).
Set a user’s Vote on a certain object. If the user has previously voted on that object, it removes the old vote.
Create a RawAssertion and a corresponding Assertion and Sentence from user input. Assign votes appropriately.
Requires the following arguments:
Get either surface1 or surface2, depending on the (1-based) idx.
Create a LeftFeature or RightFeature (depending on which class you instantiate), with the given relation and concept.
Create a LeftFeature or RightFeature (depending on which class you instantiate), with the given relation and concept.
Get all Assertions that contain this feature.
Get all RawAssertions that contain this feature.
Fill in the blank of this feature with a Concept. The result is a Proposition.
Some systems such as AnalogySpace use a lower-level representation of features, representing them as a tuple of three strings: (left_or_right, relation, concept). This factory method takes in such a tuple and produces a proper Feature object.
Express this feature as a statement in natural language. The omitted concept is replaced by the value in gap.
Get a good natural-language frame for expressing this feature. For backward compatibility, this is a property.
A Proposition represents a statement that may or may not be true. It is like an Assertion without a truth value.
The first argument of the relation.
The second argument of the relation.
The language that this proposition is in.
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.
Fill in the slots of this frame with the strings a and b.