@ector/concept-network
Concept Network is weighted directed graph, in which activation values can be
propagated, using @ector/state
.
Usage
const conceptNetwork = require('@ector/concept-network');
let cn = conceptNetwork.addNode({}, 'node1');
cn = conceptNetwork.addNode(cn, 'node2');
cn = conceptNetwork.addLink(cn, 'node1', 'node2');
// {
// node: [ { label: 'node1', occ: 1 }, { label: 'node2', occ: 1 } ],
// link: [ { from: 0, to: 1, coOcc: 1 } ]
// }
Functions
Table of Contents
- ConceptNetwork
- ConceptNetworkNode
- ConceptNetworkLink
- getNode
- getNodeIndex
- addNode
- addLink
- getLink
- getLinksFrom
- getLinksTo
- removeNode
- nodes
- removeLinksOfNode
- removeLink
- getLinkIndex
- getLinkIndex2
- decrementNode
- decrementLink
- incrementBeginning
- incrementMiddle
- incrementEnd
ConceptNetwork
Properties
-
node
Array<ConceptNetworkNode>? -
link
Array<ConceptNetworkLink>?
ConceptNetworkNode
Properties
-
label
string -
occ
number occurrence of the node -
beg
number? Times at the beginning of a sentence -
mid
number? Times at the middle of a sentence -
end
number? Times at the end of a sentence
ConceptNetworkLink
Properties
-
from
number incoming node index -
to
number outcoming node index -
coOcc
number co-occurrence of both nodes
getNode
Get the node matching label
.
Parameters
-
cn
ConceptNetwork -
label
string label of the node to get
Returns (ConceptNetworkNode | undefined)
getNodeIndex
Get the index of the node matching label
.
Parameters
-
cn
ConceptNetwork -
label
string label of the node to get
Returns number -1 when not found
addNode
Create a node in cn
or increment its occurrence.
Parameters
-
cn
ConceptNetwork -
label
string
addLink
Create a link between from
and to
, and increment coOcc
by one.
Parameters
-
cn
ConceptNetwork -
from
string -
to
string
Returns ConceptNetwork the new ConceptNetwork
getLink
Get the link from from
to to
.
Parameters
-
cn
ConceptNetwork -
from
string label of the node from -
to
string label of the node to
Returns (ConceptNetworkLink | undefined)
getLinksFrom
Get the links from label
node.
Parameters
-
cn
ConceptNetwork -
label
string label of the node from
Returns Array<ConceptNetworkLink>
getLinksTo
Get the links to label
node.
Parameters
-
cn
ConceptNetwork -
label
string label of the node to
Returns Array<ConceptNetworkLink>
removeNode
Remove the node which label
is given (and the links to it)
Parameters
-
cn
ConceptNetwork -
label
string
Returns ConceptNetwork the new ConceptNetwork
nodes
Parameters
-
nodes
Array<ConceptNetworkNode> -
node
ConceptNetworkNode
Returns Array<ConceptNetworkNode>
removeLinksOfNode
Remove all links of the node which label
is given.
Parameters
-
cn
ConceptNetwork -
label
string label of the node which links are to be removed
Returns ConceptNetwork new ConceptNetwork
removeLink
Remove the link from from
to to
Parameters
-
cn
ConceptNetwork -
from
string label of the outgoing node -
to
string label of the ingoing node
Returns ConceptNetwork the new ConceptNetwork
getLinkIndex
Get the index of the link from from
to to
.
Parameters
-
cn
ConceptNetwork -
from
string label of the node from -
to
string label of the node to
Returns number -1 when not found
getLinkIndex2
Get the index of the link from fromIndex
to toIndex
.
Parameters
-
cn
ConceptNetwork -
fromIndex
number label of the node from -
toIndex
number label of the node to
Returns number -1 when not found
decrementNode
Decrement the occ
of the node which label
is given by one.
Parameters
-
cn
ConceptNetwork -
label
string
Returns ConceptNetwork the new ConceptNetwork
decrementLink
Decrement the coOcc of the link from from
to to
by one.
Parameters
-
cn
ConceptNetwork -
from
string label of the from node -
to
string label of the to node
Returns ConceptNetwork new ConceptNetwork
incrementBeginning
Increment the beg
of the node which label
is given by one.
Parameters
-
cn
ConceptNetwork -
label
string
Returns ConceptNetwork the new ConceptNetwork
incrementMiddle
Increment the mid
of the node which label
is given by one.
Parameters
-
cn
ConceptNetwork -
label
string
Returns ConceptNetwork the new ConceptNetwork
incrementEnd
Increment the end
of the node which label
is given by one.
Parameters
-
cn
ConceptNetwork -
label
string
Returns ConceptNetwork the new ConceptNetwork