@ector/concept-network v1.1.0
@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
nodeArray<ConceptNetworkNode>?linkArray<ConceptNetworkLink>?
ConceptNetworkNode
Properties
labelstringoccnumber occurrence of the nodebegnumber? Times at the beginning of a sentencemidnumber? Times at the middle of a sentenceendnumber? Times at the end of a sentence
ConceptNetworkLink
Properties
fromnumber incoming node indextonumber outcoming node indexcoOccnumber co-occurrence of both nodes
getNode
Get the node matching label.
Parameters
cnConceptNetworklabelstring label of the node to get
Returns (ConceptNetworkNode | undefined)
getNodeIndex
Get the index of the node matching label.
Parameters
cnConceptNetworklabelstring label of the node to get
Returns number -1 when not found
addNode
Create a node in cn or increment its occurrence.
Parameters
cnConceptNetworklabelstring
addLink
Create a link between from and to, and increment coOcc by one.
Parameters
cnConceptNetworkfromstringtostring
Returns ConceptNetwork the new ConceptNetwork
getLink
Get the link from from to to.
Parameters
cnConceptNetworkfromstring label of the node fromtostring label of the node to
Returns (ConceptNetworkLink | undefined)
getLinksFrom
Get the links from label node.
Parameters
cnConceptNetworklabelstring label of the node from
Returns Array<ConceptNetworkLink>
getLinksTo
Get the links to label node.
Parameters
cnConceptNetworklabelstring label of the node to
Returns Array<ConceptNetworkLink>
removeNode
Remove the node which label is given (and the links to it)
Parameters
cnConceptNetworklabelstring
Returns ConceptNetwork the new ConceptNetwork
nodes
Parameters
nodesArray<ConceptNetworkNode>nodeConceptNetworkNode
Returns Array<ConceptNetworkNode>
removeLinksOfNode
Remove all links of the node which label is given.
Parameters
cnConceptNetworklabelstring label of the node which links are to be removed
Returns ConceptNetwork new ConceptNetwork
removeLink
Remove the link from from to to
Parameters
cnConceptNetworkfromstring label of the outgoing nodetostring label of the ingoing node
Returns ConceptNetwork the new ConceptNetwork
getLinkIndex
Get the index of the link from from to to.
Parameters
cnConceptNetworkfromstring label of the node fromtostring label of the node to
Returns number -1 when not found
getLinkIndex2
Get the index of the link from fromIndex to toIndex.
Parameters
cnConceptNetworkfromIndexnumber label of the node fromtoIndexnumber 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
cnConceptNetworklabelstring
Returns ConceptNetwork the new ConceptNetwork
decrementLink
Decrement the coOcc of the link from from to to by one.
Parameters
cnConceptNetworkfromstring label of the from nodetostring label of the to node
Returns ConceptNetwork new ConceptNetwork
incrementBeginning
Increment the beg of the node which label is given by one.
Parameters
cnConceptNetworklabelstring
Returns ConceptNetwork the new ConceptNetwork
incrementMiddle
Increment the mid of the node which label is given by one.
Parameters
cnConceptNetworklabelstring
Returns ConceptNetwork the new ConceptNetwork
incrementEnd
Increment the end of the node which label is given by one.
Parameters
cnConceptNetworklabelstring
Returns ConceptNetwork the new ConceptNetwork