Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
conceptual-graphs
Advanced tools
Conceptual Graph common structure and functions as a subclass of Knowledge Graphs
Conceptual Graphs are a "formalism for knowledge representation". This npm module hopes to break conceptual graph theory down into managable objects that programmers can play with to explore the world of concepts via graphical notation.
Below is an example of a conceptual graph of the beloved cartoon "Tom and Jerry."
npm i conceptual-graphs
import { Concept, ConceptualGraph, Relation } from "conceptual-graphs";
const tomAndJerryCG: ConceptualGraph = new ConceptualGraph();
const tomConcept: Concept = tomAndJerryCG.createConcept("TomLabel", "Cat", "Tom");
const blueConcept: Concept = tomAndJerryCG.createConcept("BlueLabel", "Colour", "Blue");
const tomIsBlueRelation: Relation =
tomAndJerryCG.createRelation("tom-is-blue-relation-label", "attribute", [tomConcept, blueConcept]);
...
import { ConceptTypeDao, InMemoryConceptTypeDao, SimpleConceptType } from "conceptual-graphs";
const conceptTypeDataAccessObject: ConceptTypeDao = new InMemoryConceptTypeDao();
const initialConceptTypeHierarchy: SimpleConceptType[] = [{
label: "Entity",
subConceptTypes: [
{
label: "Object",
subConceptTypes: [
{
label: "Animal",
subConceptTypes: [
{ label: "Cat" },
{ label: "Mouse" },
{ label: "Dog" }
]
}
]
},
{
label: "Property",
subConceptTypes: [
{ label: "Unlucky" },
{ label: "Colour" }
]
}
]
}]
conceptTypeDataAccessObject.importHierarchyFromSimpleConceptTypes(initialConceptTypeHierarchy);
import { ConceptTypeDao, InMemoryConceptTypeDao, InMemoryRelationTypeDao,
RelationTypeDao, SimpleRelationType } from "conceptual-graphs";
const conceptTypeDataAccessObject: ConceptTypeDao = new InMemoryConceptTypeDao();
const relationTypeDataAccessObject: RelationTypeDao =
new InMemoryRelationTypeDao(conceptTypeDataAccessObject);
const initialRelationTypeHierarchy: SimpleRelationType[] = [{
label: "link",
signature: ["Entity", "Entity"],
subRelationTypes: [
{
label: "personalRelationTo",
signature: ["Entity", "Entity"],
subRelationTypes: [
{
label: "archEnemyOf",
signature: ["Animal", "Animal"]
},
{
label: "friendOf",
signature: ["Animal", "Animal"]
}
]
},
{
label: "attribute",
signature: ["Entity", "Property"]
}
]
}]
relationTypeDataAccessObject.importHierarchyFromSimpleRelationTypes(initialRelationTypeHierarchy);
Conceptual graphs are composed of 2 kinds of nodes: concept nodes and relation nodes. A concept node (the rectangles) is composed of a concept type and a referent which gives meaning to the Concept Type. For example, the concept [Cat: Tom] has a concept type "Cat" and a string literal as a referent, "Tom." A relation node (the rounded nodes) link related concepts to one another.
A conceptual graph is always defined in terms of a "Vocabulary." The vocabulary consists of a concept type hierarchy and a relation type hierarchy.
Concept Types are abstract classes/groups of different kinds of concepts. They are usually arranged in a hierarchical (or partially ordered) graph where the top elements are more general than those below. Usually, at the very top of the hierarchy is the most general class called "Entity."
In this module, a concept type has the following structure:
ConceptType {
id: string;
label: string;
parentConceptTypeLabels: string[];
subConceptTypeLabels: string[];
}
The label is a unique identifier which is used to give the Concept Type human-readable meaning, such as "Entity", or "Cat". Concept types within the hierarchy are also doubly linked with their parents and children via the parentConceptTypeLabels
and subConceptTypeLabels
properties. The id is meant to be a unique identifier generated by the database of choice.
Similar to concept types, relation types are stored in a partially ordered graph ranging from most general at the top to most specific relations at the bottom. The difference between a concept type and a relation type is the addition of a signature. A relation type's signature is a list of concept types. This is similar to a function signature in programming which lists arguments of specific types. The signature specifies the types of the concept instances to which a relation instance would connect.
RelationType {
id: string;
label: string;
subRelationTypeLabels: string[] = [];
parentRelationTypeLabels: string[] = [];
signature: string[];
}
Concepts are instances of concept types. In the same way that in programming an object is an instance of a class. As mentioned before, a concept consists of two parts, namely a required concept type and an optional referent. If the referent is blank, then the concept is general, meaning "any."
Concept {
id: string;
label: string;
conceptTypeLabels: string[] = [];
referent: Referent;
}
Referent {
designatorType: DesignatorType;
designatorValue?: string;
}
enum DesignatorType {
BLANK = "BLANK", // A blank descriptor which is a blank conceptual graph
LITERAL = "LITERAL", // A syntactic representation of the form of the referent
LAMBDA = "LAMBDA" // Used in querying or definitions -> meaning "Any such concept type"
}
In this module, concept referents have a designator type and a designator value. If the type is "BLANK", then the designator value is ignored. A "LITERAL" designator type requires that a string value be supplied to the designator value. "LAMBDA" designator types are used in concept type definitions and in queries.
As concepts are instances of concept types, so relations are instances of relation types. A relation does not have a referent, however. A relation links two concepts together by filling in the signature of the concept type. This is the programming equivalent to passing arguments into a function.
export class Relation {
id: string;
label: string;
relationTypeLabels: string[] = [];
conceptArgumentLabels: string[] = [];
}
FAQs
Conceptual Graph common structure and functions as a subclass of Knowledge Graphs
We found that conceptual-graphs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.