CN108536837B - Knowledge tree generation method, device, equipment and storage medium - Google Patents

Knowledge tree generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN108536837B
CN108536837B CN201810330016.7A CN201810330016A CN108536837B CN 108536837 B CN108536837 B CN 108536837B CN 201810330016 A CN201810330016 A CN 201810330016A CN 108536837 B CN108536837 B CN 108536837B
Authority
CN
China
Prior art keywords
knowledge
node
nodes
knowledge node
processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810330016.7A
Other languages
Chinese (zh)
Other versions
CN108536837A (en
Inventor
宁录游
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai qujie Information Technology Co.,Ltd.
Original Assignee
Shanghai Qujie Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Qujie Information Technology Co ltd filed Critical Shanghai Qujie Information Technology Co ltd
Priority to CN201810330016.7A priority Critical patent/CN108536837B/en
Publication of CN108536837A publication Critical patent/CN108536837A/en
Application granted granted Critical
Publication of CN108536837B publication Critical patent/CN108536837B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
    • G06Q50/10Services
    • G06Q50/20Education
    • G06Q50/205Education administration or guidance

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Educational Administration (AREA)
  • Educational Technology (AREA)
  • Strategic Management (AREA)
  • Tourism & Hospitality (AREA)
  • Health & Medical Sciences (AREA)
  • Economics (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Resources & Organizations (AREA)
  • Marketing (AREA)
  • Primary Health Care (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a method, a device, equipment and a storage medium for generating a knowledge tree. The method comprises the steps of obtaining two or more knowledge nodes and a hierarchical relation between the knowledge nodes; determining a drawing ordinate corresponding to each knowledge node according to the hierarchical relationship; determining a drawing abscissa corresponding to each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node and the arrangement sequence of the sub knowledge nodes and the knowledge nodes on the same layer; and generating the knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing ordinate and the drawing abscissa.

Description

Knowledge tree generation method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to computer technology, in particular to a method, a device, equipment and a storage medium for generating a knowledge tree.
Background
With the development of science and technology, people need to learn more and more knowledge. In recent years, knowledge trees have emerged as an organizational form of knowledge to assist people in learning.
A knowledge tree is a hierarchical knowledge graph that expresses causal or dependency relationships among all related organizational knowledge to achieve an organizational goal. The knowledge tree is generally in a tree shape or a tree-like shape, and includes a plurality of knowledge nodes having a parent-child relationship.
The existing knowledge tree drawing method usually needs to be repeatedly modified, and the operation is complex.
Disclosure of Invention
The invention provides a method, a device, equipment and a storage medium for generating a knowledge tree, which are used for generating a corresponding knowledge tree from knowledge nodes.
In a first aspect, an embodiment of the present invention provides a method for generating a knowledge tree, including:
acquiring two or more knowledge nodes and a hierarchical relationship between the knowledge nodes;
determining a drawing ordinate corresponding to each knowledge node according to the hierarchical relationship;
determining a drawing abscissa corresponding to each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node and the arrangement sequence of the sub knowledge nodes and the knowledge nodes on the same layer;
and generating a knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing ordinate and the drawing abscissa.
In a second aspect, an embodiment of the present invention further provides an apparatus for generating a knowledge tree, where the apparatus includes:
the acquisition module is used for acquiring two or more knowledge nodes and the hierarchical relationship between the knowledge nodes;
the first determining module is used for determining a drawing ordinate corresponding to each knowledge node according to the hierarchical relationship;
the second determining module is used for determining a drawing abscissa corresponding to each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node and the arrangement sequence between the sub knowledge nodes and the knowledge nodes on the same layer;
and the generating module is used for generating a knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing ordinate and the drawing abscissa.
In a third aspect, an embodiment of the present invention further provides an electronic device, including:
one or more processors;
a memory for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the method for generating a knowledge tree according to any embodiment.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for generating a knowledge tree according to any embodiment.
According to the embodiment of the invention, the knowledge tree is automatically generated by acquiring the hierarchical relationship between two or more knowledge nodes and the knowledge nodes, determining the drawing vertical coordinate corresponding to each knowledge node according to the hierarchical relationship, determining the drawing horizontal coordinate corresponding to each knowledge node according to the standard width value of the sub-knowledge nodes corresponding to each knowledge node and the arrangement sequence between the sub-knowledge nodes and the knowledge nodes on the same layer, and generating the knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing vertical coordinate and the drawing horizontal coordinate, so that manual drawing is not needed, and the labor cost is saved.
Drawings
FIG. 1 is a flow chart of a method for generating a knowledge tree according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method for generating a knowledge tree according to a second embodiment of the present invention;
FIG. 3 is a diagram of a set of nodes of knowledge to be processed according to a second embodiment of the present invention;
FIG. 4 is a diagram of another set of nodes of knowledge to be processed according to the second embodiment of the present invention;
FIG. 5 is a flowchart of a method for generating a knowledge tree according to a third embodiment of the present invention;
FIG. 6 is a diagram illustrating a structure of a knowledge tree according to a third embodiment of the present invention;
FIG. 7 is a block diagram of a knowledge tree generation apparatus according to a fourth embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a method for generating a knowledge tree according to an embodiment of the present invention, where this embodiment is applicable to a case where knowledge nodes generate corresponding knowledge trees, and the method may be executed by a knowledge tree generation apparatus, which may be composed of hardware and/or software and may be generally integrated in a server, and specifically includes the following steps:
and S110, acquiring two or more knowledge nodes and the hierarchical relationship between the knowledge nodes.
In this embodiment, the knowledge node is a node carrying knowledge information, where the form of the knowledge information includes, but is not limited to, text, pictures, videos, links, and the like, and one knowledge node may carry at least one form of knowledge information. The knowledge node also carries a node identifier of the knowledge node and a node identifier of a father knowledge node of the knowledge node, wherein the node identifier is a unique identifier of the node, such as a node number and a node code, and the father knowledge node of the knowledge node can be quickly found through the node identifier.
Two or more knowledge nodes may be pre-stored in an array, and an element of the array may contain one knowledge node or a plurality of knowledge nodes. From the perspective of elements, if one element of the array comprises a plurality of knowledge nodes, the knowledge nodes have a hierarchical relationship; from the perspective of the array, knowledge nodes contained in each element of the array have a hierarchical relationship. The hierarchical relationship among the knowledge nodes is embodied as the hierarchy of the knowledge nodes and the high-low relationship among different levels.
The hierarchical relationship between the knowledge nodes can be obtained according to the parent-child relationship between the knowledge nodes. In some embodiments, obtaining the hierarchical relationship between knowledge nodes comprises the following five steps:
the first step is as follows: and creating a set S and an index L corresponding to the set S, and sequentially adding the acquired knowledge nodes into the set S. And each time a knowledge node is added, acquiring the node identification carried by the knowledge node and the node identification of the father knowledge node of the knowledge node, and correspondingly adding the two node identifications into the index L to be used as an index item. And returning to add the next knowledge node into the set and adding the corresponding index item until all knowledge nodes are added into the set S.
The second step is that: sequentially selecting a knowledge node from the set S as a current knowledge node, and judging whether the current knowledge node has a father knowledge node or not according to the index L and the node identification of the current knowledge node; or judging whether the current knowledge node has the father knowledge node according to whether the current knowledge node carries the node identification of the father knowledge node. If the parent knowledge node exists, jumping to the third step; and if the parent knowledge node is not available, jumping to the fourth step.
The third step: and (3) adding 1 to the hierarchy of the current knowledge node as the hierarchy of the parent knowledge node, and adding the child knowledge nodes of the same parent knowledge node into a new set S1, wherein the number of the sets S1 is equal to that of the parent knowledge nodes. And jumping to the fifth step.
The fourth step: and setting the level of the current knowledge node as a first level, wherein the knowledge node in the first level becomes a root knowledge node. And jumping to the fifth step.
The fifth step: knowledge nodes at the same level are added to a new set S2, the number of sets S2 is equal to the number of levels. Generally, a set S2 includes at least one set S1, where the set S includes sets S2 arranged in a hierarchical relationship.
The current knowledge node may correspond to at least two or more father knowledge nodes, and if the father knowledge nodes are located in different hierarchies, the current knowledge node is located in different hierarchies. Based on this, if the father knowledge node is unique, the hierarchy of the current knowledge node is added with 1 to the hierarchy of the father knowledge node; and if the parent knowledge node is not unique, adding 1 to the highest level in the levels of the parent knowledge nodes to serve as the level where the current knowledge node is located.
It should be noted that, according to the above five steps, the hierarchy of the root knowledge node is lower than that of the leaf knowledge node, where the leaf knowledge node is a node without a child knowledge node, but is not limited thereto. In the third step, the current knowledge node is positioned at the level which is less than 1 of the level which is positioned at the parent knowledge node, so that the level of the root knowledge node is higher than that of the leaf knowledge node. In addition, a knowledge node can be acquired at will, the level where the knowledge node is located is a reference level, and the level where other knowledge nodes are located is determined according to the parent-child relationship among the nodes.
And S120, determining a drawing vertical coordinate corresponding to each knowledge node according to the hierarchical relationship.
And drawing an ordinate refers to the ordinate of the central point of the area occupied by the knowledge node on the knowledge tree. And according to the levels, the drawing vertical coordinates corresponding to the knowledge nodes are different in size. The higher the hierarchy, the larger or smaller the drawing ordinate corresponding to the knowledge node is; and the corresponding drawing vertical coordinates of the knowledge nodes in the same level are the same.
And S130, determining a drawing abscissa corresponding to each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node and the arrangement sequence of the sub knowledge nodes and the knowledge nodes on the same layer.
Wherein the standard width value is the width value of the area occupied by the knowledge node on the knowledge tree. If the sum of the standard widths of the sub knowledge nodes corresponding to the knowledge node is larger, the standard width value of the knowledge node is larger so as to avoid the sub knowledge node from overlapping with other knowledge nodes. The arrangement sequence among the knowledge nodes on the same layer refers to the horizontal sequence. According to the standard width value of the sub knowledge nodes corresponding to each knowledge node and the arrangement sequence of the sub knowledge nodes and the knowledge nodes on the same layer, the drawing abscissa corresponding to each knowledge node, namely the abscissa occupying the central point of the area, can be determined.
And S140, generating a knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing ordinate and the drawing abscissa.
And determining the position of the knowledge node on the knowledge tree according to the drawing ordinate and the drawing abscissa. Connections between knowledge nodes may be drawn according to a hierarchical relationship, such as drawing arrows from a parent knowledge node to a child knowledge node.
A knowledge tree is a hierarchical knowledge graph that expresses causal or dependency relationships among all related organizational knowledge to achieve an organizational goal. In this embodiment, the knowledge tree may be a tree structure or a tree-like structure. The tree structure has a unique root knowledge node, and one child knowledge node corresponds to a unique parent knowledge node. The class tree structure has two or more root knowledge nodes, with at least one child knowledge node corresponding to two or more parent knowledge nodes.
According to the embodiment of the invention, the knowledge tree is automatically generated by acquiring the hierarchical relationship between two or more knowledge nodes and the knowledge nodes, determining the drawing vertical coordinate corresponding to each knowledge node according to the hierarchical relationship, determining the drawing horizontal coordinate corresponding to each knowledge node according to the standard width value of the sub-knowledge nodes corresponding to each knowledge node and the arrangement sequence between the sub-knowledge nodes and the knowledge nodes on the same layer, and generating the knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing vertical coordinate and the drawing horizontal coordinate, so that manual drawing is not needed, and the labor cost is saved.
Example two
Fig. 2 is a flowchart of a method for generating a knowledge tree according to a second embodiment of the present invention. This embodiment further optimizes S130 in the above embodiment. Because the drawing abscissa corresponding to the knowledge node is influenced by the child knowledge node, the drawing abscissa corresponding to each knowledge node can be determined layer by layer from the child knowledge node to the father knowledge node. For convenience of description and distinction, taking the level of the root knowledge node lower than the level of the leaf knowledge node as an example for explanation, a person skilled in the art may know, based on this embodiment, a determination method for drawing the abscissa under the condition that the level of the root knowledge node is higher than the level of the leaf knowledge node, and details are not described here. As shown in fig. 2, the method for generating the knowledge tree includes the following steps:
s210, acquiring two or more knowledge nodes and the hierarchical relationship between the knowledge nodes.
And S220, determining a drawing vertical coordinate corresponding to each knowledge node according to the hierarchical relationship.
Firstly, in each level, any level is selected as a reference level*The base level may be a level at which the root knowledge node is located, a level at which the leaf knowledge node is located, or an intermediate level.
Because the drawing vertical coordinates corresponding to the knowledge nodes on the same layer are the same, the knowledge nodes on the same layer can be sequentially acquired from two or more knowledge nodes as a third processing node set. Alternatively, in the set S, the set S2 is acquired in sequence as the third processing node set.
Then, according to the formula y ═ y*+(level*-level) × a, calculating a rendering ordinate y for the third set of processing nodes, which isIn, y*The drawing ordinate corresponds to the knowledge node at the reference level, the level is the level at which the third processing node set is located, and a is the standard height value of each knowledge node. And after the drawing longitudinal coordinate corresponding to the third processing node set is calculated, returning to execute the operation of sequentially acquiring the knowledge nodes on the same layer as the third processing node set in two or more knowledge nodes until the processing of all the knowledge nodes is completed, and further obtaining the drawing longitudinal coordinate corresponding to each knowledge node.
The calculation method of the drawing ordinate is explained in detail below with an example:
as shown in fig. 3, the knowledge nodes to be processed include a knowledge node a, a knowledge node B, a knowledge node C, and a knowledge node D. Knowledge node A is a root knowledge node and is at a first level; knowledge node B and knowledge node C are child knowledge nodes of knowledge node A, and are in a second level; knowledge node D is a child knowledge node of knowledge node C, at the third level. Selecting the first level where the root knowledge node is as the reference level, namely level*The drawing ordinate corresponding to the known root knowledge node is-1000 pixels, and the standard height value of each knowledge node is 2000 pixels. For the knowledge node B and the knowledge node C of the second hierarchy, from the fact that y is-1000 + (1-2) × 2000 is-3000, the drawing ordinate of the knowledge node B and the knowledge node C is-3000 pixels. For the knowledge node D at the third hierarchical level, the drawing ordinate of the knowledge node C is-5000 pixels from y-1000 + (1-3) × 2000-5000.
S230, obtaining the occupation width attribute of each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node from the high level to the low level, wherein the occupation width attribute comprises: the occupation width of the non-root knowledge node under the corresponding father knowledge node and the occupation width of the root knowledge node.
The standard width value of each knowledge node is obtained by upward superposition of the occupation widths of the sub knowledge nodes, and the upward superposed occupation width of each sub knowledge node is sometimes the standard width value of the sub knowledge node itself and sometimes other values. For the root knowledge node, since it has no parent knowledge node, the occupancy width attribute is the occupancy width of the root knowledge node and is also the standard width value of the root knowledge node. For a non-root knowledge node, the occupancy width attribute is the occupancy width under the corresponding parent knowledge node, i.e., the occupancy width superimposed on the corresponding parent knowledge node.
In some embodiments, in order to arrange the sub-knowledge nodes at each level and to perform complementary overlapping, the standard width value occupied by the knowledge nodes carrying more sub-knowledge nodes at each level should be larger, so that the sub-knowledge nodes at each level carried by the knowledge nodes have enough drawing space. Based on this, in some embodiments, the standard width value of the leaf knowledge node may be set in advance, for example, to be 1000 pixels, 2000 pixels, and so on. And setting the standard width value of the father knowledge node as the sum of the standard width values of all the child knowledge nodes according to the sequence from the high level to the low level, and enabling the occupation width attribute of each knowledge node to be the same as the standard width value.
In other embodiments, especially for tree-like structures, a knowledge node may correspond to at least two or more father knowledge nodes, and the width of the knowledge nodes that are overlaid upwards may be different according to whether the knowledge node is the main father knowledge node or not. Based on this, the occupancy width attribute and the standard width value of each knowledge node can be calculated as follows. The method specifically comprises the following steps:
step one, acquiring a knowledge node as a first processing node in sequence according to the sequence from a high hierarchy to a low hierarchy. Alternatively, in the set S, the knowledge nodes in the sets S1 in the set S2 are acquired in turn as the first processing node.
Step two, if the first processing node corresponds to at least one father knowledge node, determining the occupation width of the first processing node under the at least one father knowledge node according to the standard width value of the first processing node, wherein the leaf knowledge node has a set standard width value; and updating the standard width value of the at least one parent knowledge node to be a superposition sum of the occupation width of the first processing node under the at least one parent knowledge node. And returning to the step one, and continuously acquiring a knowledge node as a first processing node until the processing of all knowledge nodes is completed.
Optionally, the knowledge nodes in one set S1 in one set S2 are acquired first, and then the knowledge nodes in another set S1 in the set S2 are acquired in sequence. After the knowledge nodes in the set S2 are processed, the knowledge nodes in each set S1 in another set S2 are acquired until all the knowledge nodes in each set S2 in the set S are processed.
In the second step, the following two cases are included according to the difference of the number of the father knowledge nodes corresponding to the first processing node:
in the first case: and if the first processing node corresponds to the unique parent knowledge node, determining the standard width value of the first processing node as the occupation width of the first processing node under the unique parent knowledge node. At this time, the occupancy width of the first processing node on top of the overlay is its standard width value.
In the second case: and if the first processing node corresponds to at least two father knowledge nodes, selecting a main father knowledge node from the at least two father knowledge nodes, determining the standard width value of the first processing node as the occupation width of the first processing node under the main father knowledge node, and determining the standard width value of the leaf knowledge node as the occupation width of the first processing node under other father knowledge nodes except the main father knowledge node.
If the first processing node corresponds to at least two father knowledge nodes, one knowledge node needs to be selected from the at least two father knowledge nodes to serve as a main father knowledge node, and the first processing node is drawn at the position corresponding to the main father knowledge node. In order to avoid overlapping of the child knowledge nodes under the main parent knowledge node with other knowledge nodes, the standard width of the main parent knowledge node can be increased emphatically. According to the idea, the occupation width of the first processing node superposed on the main father knowledge node can be made to be the standard width value of the first processing node, and the occupation width of the first processing node superposed on other father knowledge nodes except the main father knowledge node can be made to be the standard width value of the leaf knowledge node. Since the leaf knowledge node does not have a child knowledge node, the standard width value of the leaf knowledge node can be preset. It can be seen that the standard width value of the leaf knowledge node is the smallest among the knowledge nodes.
Optionally, selecting a master parent knowledge node from the at least two parent knowledge nodes includes: the method comprises the steps of respectively obtaining arrangement positions of at least two father knowledge nodes in a hierarchy, and taking the father knowledge node closest to a preset position in each arrangement position as a main father knowledge node.
Wherein, the arrangement position of at least two father knowledge nodes in the hierarchy refers to a horizontal arrangement position, for example, the drawing horizontal coordinate of at least two father knowledge nodes. The preset position may be the leftmost side or the rightmost side, and based on this, the parent knowledge node closest to the leftmost side or the parent knowledge node closest to the rightmost side in each drawing abscissa is taken as the master parent knowledge node.
And step three, if the first processing node is the root knowledge node, directly determining the standard width value corresponding to the first processing node as the occupation width of the first processing node. And returning to the step one, and continuously acquiring a knowledge node as a first processing node until the processing of all knowledge nodes is completed.
The following describes in detail the calculation method of the occupancy width attribute and the standard width value of each knowledge node by using an example:
as shown in fig. 4, the knowledge nodes to be processed include a knowledge node a, a knowledge node b, a knowledge node c, a knowledge node d, a knowledge node e, a knowledge node f, a knowledge node g, and a knowledge node h. The knowledge node a and the knowledge node b are root knowledge nodes and are positioned at a first level; knowledge node c and knowledge node d are in a second hierarchy; knowledge node e and knowledge node f are in a third level; knowledge node g and knowledge node h are in the fourth hierarchy.
According to the sequence from the high level to the low level, the set S2 corresponding to the fourth level includes the set S1 corresponding to the parent knowledge node f, and then the knowledge node g is selected as the first processing node from the set S1 corresponding to the parent knowledge node f. And searching the identification of the knowledge node g in the index item of the index L, determining that the only father knowledge node of the knowledge node g is the knowledge node f, and the knowledge node g is a leaf knowledge node, setting the standard width value of the knowledge node g to be 1000 pixels, and simultaneously setting the occupation width of the knowledge node g under the knowledge node f to be 1000 pixels. In the set S1 corresponding to the parent knowledge node f, the knowledge node h is selected as the first processing node, and similarly, the standard width value of the knowledge node h and the occupation width of the knowledge node h under the knowledge node f are both 1000 pixels. The standard width value of the knowledge node f is the sum of the occupancy width under the knowledge node g and the occupancy width under the knowledge node h, i.e. 2000 pixels. At this point, the processing of the knowledge nodes of the first level is completed.
The set S2 corresponding to the third level includes a set S1 corresponding to the parent node c. And selecting the knowledge node f as a first processing node from the set S1 corresponding to the parent knowledge node c. And searching the identification of the knowledge node f in the index item of the index L, determining a father knowledge node c and a father knowledge node b corresponding to the knowledge node f, wherein in the arrangement positions of the father knowledge node c and the father knowledge node b, the nearest node to the leftmost side is the father knowledge node c, taking the father knowledge node c as a main father knowledge node, and taking 2000 pixels of the standard width value of the knowledge node f as the occupation width under the father knowledge node c. The occupancy width of knowledge node f under parent knowledge node b is determined as the standard width value of the leaf knowledge node, i.e. 1000 pixels. And in the set S1 corresponding to the parent knowledge node c, continuously selecting the knowledge node e as the first processing node. And searching the identification of the knowledge node e in the index item of the index L, and determining that the knowledge node e corresponds to the unique father knowledge node c and is a leaf knowledge node. The standard width value of the knowledge node e and its occupied width under the knowledge node c are both 1000 pixels. Next, the standard width value of the knowledge node c is updated to the sum of the superposition of 1000 pixels and 2000 pixels, i.e., 3000 pixels. The standard width value of knowledge node b is updated to 1000 pixels. At this point, the processing of each knowledge node of the second hierarchy is completed.
The set S2 corresponding to the second hierarchy includes: the set S1 corresponding to the parent knowledge node a and the set S1 corresponding to the parent knowledge node b. In the set S1 corresponding to the parent knowledge node a, the knowledge node c is obtained as a first processing node, the identifier of the knowledge node c is searched in the index entry of the index L, it is determined that the knowledge node c corresponds to the only parent knowledge node a, and then the standard width value 3000 pixels of the knowledge node c are used as the occupation width of the knowledge node c under the parent knowledge node a. Next, the standard width value of the parent knowledge node a is updated to an occupancy width of 3000 pixels under which the knowledge node c is. Then, in the set S1 corresponding to the parent knowledge node b, the knowledge node d is obtained as a first processing node, the identifier of the knowledge node d is searched in the index entry of the index L, and it is determined that the knowledge node d corresponds to the only parent knowledge node b and is a leaf knowledge node, and then the standard width value of the knowledge node d and the occupation width of the knowledge node d under the parent knowledge node b are both 1000 pixels. Then, the standard width value of the parent knowledge node b is updated again to the sum of the superposition of 1000 pixels and 2000 pixels.
The set S2 corresponding to the first hierarchy includes a knowledge node a whose occupancy width is 3000 pixels in its standard width value and a knowledge node b whose occupancy width is 2000 pixels in its standard width value. And finishing the processing of all knowledge nodes.
It should be noted that the knowledge node f corresponds to the parent knowledge node c and the parent knowledge node b, and the level of the parent knowledge node c is higher than the level of the parent knowledge node b, so that when the level of the knowledge node f is calculated, the level of the parent knowledge node c is added by 1.
And S240, calculating a drawing abscissa corresponding to each knowledge node according to the standard width value, the occupation width attribute and the arrangement sequence of the knowledge nodes on the same layer from the low level to the high level.
And S250, generating a knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing ordinate and the drawing abscissa.
In this embodiment, the standard width and the occupation width attribute of the knowledge nodes are calculated according to the sequence from the high hierarchy to the low hierarchy, and then the drawing abscissa corresponding to each knowledge node is calculated according to the standard width value, the occupation width attribute of each knowledge node and the arrangement sequence between the knowledge nodes on the same layer, so that the knowledge nodes are prevented from being overlapped, and the generated knowledge tree is neat and beautiful.
EXAMPLE III
Fig. 5 is a flowchart of a method for generating a knowledge tree according to a third embodiment of the present invention. This embodiment further optimizes S240 in the above embodiment. As shown in fig. 5, the method comprises the following steps:
s310, acquiring two or more knowledge nodes and the hierarchical relationship between the knowledge nodes.
And S320, determining a drawing vertical coordinate corresponding to each knowledge node according to the hierarchical relationship.
S330, obtaining the occupation width attribute of each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node from the high level to the low level, wherein the occupation width attribute comprises: the occupation width of the non-root knowledge node under the corresponding father knowledge node and the occupation width of the root knowledge node.
S310, S320, and S330 are the same as S210, S220, and S230, respectively, and are not described herein again.
And S340, sequentially acquiring a knowledge node as a second processing node according to the sequence from the low hierarchy to the high hierarchy.
It should be noted that, in the case where the hierarchy of the root knowledge node is lower than the hierarchy of the leaf knowledge nodes, one knowledge node may be sequentially acquired as the second processing node in the order from the lower hierarchy to the higher hierarchy, as described in this embodiment. For the case that the hierarchy of the root knowledge node is higher than the hierarchy of the leaf knowledge nodes, one knowledge node may be sequentially obtained as the second processing node according to the sequence from the higher hierarchy to the lower hierarchy, and for the processing method of the second processing node, reference may be made to this embodiment, and details are not described here.
In some embodiments, the knowledge nodes in the sets S1 in the set S2 may be acquired in turn as the second processing node in the set S. Specifically, the knowledge nodes in one set S1 in one set S2 are acquired first, and then the knowledge nodes in another set S1 in the set S2 are acquired in sequence. After the knowledge nodes in the set S2 are processed, the knowledge nodes in each set S1 in another set S2 are acquired until all the knowledge nodes in each set S2 in the set S are processed.
And S350, judging whether the second processing node is a root knowledge node or not. If the second processing node is the root knowledge node, jumping to S360; if the second processing node is a non-root knowledge node, then a jump is made to S370.
Because the root knowledge node has no father knowledge node, the calculation methods for drawing the abscissa corresponding to the root knowledge node and the non-root knowledge node are different.
And S360, calculating a drawing abscissa corresponding to the second processing node according to the occupation width of the second processing node and the arrangement sequence between the second processing node and the same-layer root knowledge node. Execution continues with S380.
For the tree structure, as only one root knowledge node exists, the central abscissa of the whole knowledge tree drawing space is directly taken as the drawing abscissa. For the tree-like structure, because two or more root knowledge nodes are included, and the root knowledge nodes need to be drawn at the same level, the drawing abscissa corresponding to each root knowledge node is calculated according to the occupied width of each root knowledge node, namely the standard width and the arrangement sequence between the root knowledge nodes at the same layer, so that each root knowledge node is transversely arranged, and the overlapping of the sub-knowledge nodes at different levels below the root knowledge node is avoided.
In some embodiments, before S360, a calculation process of the rank order between the second processing node and the peer root knowledge node is further included. Specifically, the number of child knowledge nodes of each knowledge node is counted; and sequencing the knowledge nodes from left to right according to the sequence of the number of the child knowledge nodes of each knowledge node from small to large so as to obtain the sequence of the second processing node and the root knowledge nodes on the same layer. Of course, the knowledge nodes may be ordered from left to right according to the descending order of the number of the child knowledge nodes of each knowledge node, so as to obtain the order between the second processing node and the root knowledge node on the same layer. In addition to sorting the knowledge nodes according to the number of the child knowledge nodes, the knowledge nodes can be sorted according to other rules, such as the width of the knowledge node, the importance degree of the knowledge information carried by the knowledge node, and the like. Any method for ordering the same-layer root knowledge nodes is within the protection scope of the present application.
After the arrangement sequence between the second processing node and the root knowledge node on the same side is obtained, the drawing abscissa corresponding to the second processing node can be calculated continuously according to the occupation width of the second processing node and the arrangement sequence between the root knowledge nodes on the same layer, and the method specifically comprises the following steps:
step 1, calculating the sum w of the occupied widths of root knowledge nodes arranged in the preset direction of the second processing node in the root knowledge nodes in the same layer according to the arrangement sequence of the second processing node and the root knowledge nodes in the same layerp. Wherein the preset direction is left or right.
Step 2, according to the formula x ═ plus or minus (w)p+ w/2), calculating a drawing abscissa x corresponding to the second processing node; where w is the footprint of the second processing node.
It should be noted that when the preset direction is left, the formula x ═ w is adoptedp+ w/2; when the preset direction is right, the formula x ═ - (w) is adoptedp+w/2)。
The following describes the plotting abscissa calculation method of the root knowledge node in detail with reference to the root knowledge node shown in fig. 4. The first-level correspondence set S2 includes a knowledge node a and a knowledge node b, the knowledge node a being arranged on the left of the knowledge node b. Acquiring a knowledge node a from the set S2 corresponding to the first level as a second processing node, and if no knowledge node exists on the left side of the knowledge node a, making wpIs 0. The occupancy width of the knowledge node a is 3000 pixels. Substituting the data into the formula x ═ wp+ w/2, the drawing abscissa corresponding to the obtained knowledge node a is 1500 pixels. Then, the knowledge node b is acquired as the second processing node in the set S2 corresponding to the first hierarchy, and the occupation width of the root knowledge node a arranged on the left side of the knowledge node b is 3000, let w bepIs 3000 pixels. The occupancy width of knowledge node b is 2000 pixels. According to the formula x ═ wp+ w/2, the drawing abscissa corresponding to the obtained knowledge node b is 4000 pixels.
S370, calculating a drawing abscissa corresponding to the second processing node according to the drawing abscissa corresponding to the target parent knowledge node corresponding to the second processing node, the standard width value of the target parent knowledge node, the standard width value of the second processing node and the arrangement sequence of other child knowledge nodes under the target parent knowledge node, wherein the target parent knowledge node comprises: a unique parent of the second processing node, or a master parent of the second processing node. Execution continues with S380.
For a tree structure, the target parent knowledge node corresponding to the second processing node is the only parent knowledge node. For a tree-like structure, the target parent knowledge node corresponding to the second processing node comprises the only parent knowledge node of the second processing node, or the main parent knowledge node of the second processing node.
In some embodiments, before S370, a calculation process of the rank order between the second processing node and other child knowledge nodes under the target parent knowledge node is further included. Specifically, the number of the child knowledge nodes of each child knowledge node under the target parent knowledge node is counted; and sequencing the child knowledge nodes under the target father knowledge node from left to right according to the sequence of the number of the child knowledge nodes of each child knowledge node under the target father knowledge node from small to large so as to obtain the sequence of the second processing node and other child knowledge nodes under the target father knowledge node. Of course, the child knowledge nodes under the target parent knowledge node may also be ordered from left to right according to the descending order of the number of the child knowledge nodes of each child knowledge node under the target parent knowledge node, so as to obtain the order of the second processing node and the other child knowledge nodes under the target parent knowledge node. In addition to sorting the sub-knowledge nodes according to the number of the sub-knowledge nodes of each sub-knowledge node, the sub-knowledge nodes may also be sorted by other rules, for example, the width of the sub-knowledge node, the importance of the knowledge information carried by the sub-knowledge node, and the like. Any method for ordering the child knowledge nodes under the target parent knowledge node is within the scope of the present application.
Then, according to the drawing abscissa corresponding to the target parent knowledge node corresponding to the second processing node, the standard width value of the target parent knowledge node, the standard width value of the second processing node, and the arrangement sequence between the second processing node and other child knowledge nodes under the target parent knowledge node, the drawing abscissa corresponding to the second processing node is calculated. The method specifically comprises the following steps:
step 1', calculating the sum w of the occupied widths of the knowledge nodes arranged in the preset direction of the second processing node in all the child knowledge nodes under the target father knowledge node under the basis of the arrangement sequence of the second processing node and other child knowledge nodes under the target father knowledge nodeq. Wherein the preset direction may be left or right.
Step 2', according to the formula x ═ xf±[wq+(w-wf)/2]Calculating a drawing abscissa x corresponding to the second processing node; where w is the standard width value of the second processing node, xfIs the drawing abscissa, w, corresponding to the target parent knowledge node corresponding to the second processing nodefIs the standard width value of the target parent knowledge node corresponding to the second processing node.
It should be noted that, when the preset direction is the left side, the formula x ═ x is adoptedf+wq+(w-wf) 2; when the preset direction is the right side, the formula x is adopted as xf-[wq+(w-wf)/2]。
The following describes the plotting abscissa calculation method of the non-root knowledge node in detail with reference to the non-root knowledge node shown in fig. 4. The set S2 corresponding to the second hierarchy includes: the set S1 corresponding to the parent knowledge node a and the set S1 corresponding to the parent knowledge node b. In the set S1 corresponding to the parent knowledge node a, the knowledge node c is obtained as the second processing node, and since the parent knowledge node a only has one child knowledge node of the knowledge node c, the sum w of the occupation widths of the knowledge nodes arranged on the left side of the knowledge node c under the target parent knowledge node aq Is 0. The standard width value w of knowledge node c is 3000 pixels. Drawing abscissa x corresponding to parent knowledge node afIs 1500 pixels. Standard width value w of father knowledge node af Is 3000 pixels. Substituting the data into x ═ xf+wq+(w-wf) And/2, obtaining a drawing abscissa x corresponding to the knowledge node c as 1500 pixels. In the set S1 corresponding to the father knowledge node b, the knowledge node is acquiredd as a second processing node. Sum w of occupation widths of knowledge node f arranged at left side of knowledge node d under target parent knowledge node bqThe standard width value w of the knowledge node d is 1000 pixels, and the drawing abscissa x corresponding to the target parent knowledge node afFor 4000 pixels, the data is substituted into the formula x ═ xf+wq+(w-wf) The corresponding plotted abscissa x of the/2-available knowledge node d is 4000 pixels.
The knowledge node f includes both the set S1 corresponding to the parent knowledge node b and the set S1 corresponding to the parent knowledge node c. To avoid repeated calculations, the plotted abscissa corresponding to the knowledge node f is calculated only in the set S1 corresponding to the parent knowledge node c at the higher hierarchy.
The set S2 corresponding to the third level includes a set S1 corresponding to the parent knowledge node c, and in the set S1 corresponding to the parent knowledge node c, the knowledge node e is selected as the second processing node. If there is no other knowledge node under the target parent knowledge node c on the left side of the knowledge node e, let w q0, the standard width value w of the knowledge node e is 1000 pixels, and the drawing abscissa x corresponding to the target parent knowledge node cfA standard width value w of 1500 pixels, parent knowledge node cfIs 3000 pixels. Substituting the data into the formula x ═ xf+wq+(w-wf) The corresponding plotted abscissa x of the/2-available knowledge node e is 500 pixels. And continuing to select the knowledge node f as a second processing node in the set S1 corresponding to the parent knowledge node c. Sum w of occupation widths of knowledge nodes e arranged on the left side of the knowledge node f under the target parent knowledge node cqIs 1000 pixels, the standard width value w of the knowledge node f is 2000 pixels, and the drawing abscissa x corresponding to the target father knowledge node cfA standard width value w of 1500 pixels for the target parent knowledge node cfIs 3000 pixels. Substituting the data into the formula x ═ xf+wq+(w-wf) The corresponding plotted abscissa x of the/2-available knowledge node f is 2000 pixels.
The set S2 corresponding to the fourth level includes the set S1 corresponding to the parent knowledge node f, and then the knowledge node g is selected as the second process from the set S1 corresponding to the parent knowledge node fAnd (4) nodes. If there is no other knowledge node under the target father knowledge node f on the left side of the knowledge node g, let w q0, the standard width value w of the knowledge node g is 1000 pixels, and the drawing abscissa x corresponding to the target parent knowledge node ffStandard width value w of target parent knowledge node f of 2000 pixelsfWhich is 2000 pixels. Substituting the data into the formula x ═ xf+wq+(w-wf) The corresponding plotted abscissa x of the available knowledge node g is 1500 pixels. And continuing to select the knowledge node h as a second processing node from the set S1 corresponding to the parent knowledge node f. Sum w of occupation widths of knowledge nodes arranged on the left side of the knowledge node h under the target parent knowledge node fqIs 1000 pixels, the standard width value w of the knowledge node h is 1000 pixels, and the drawing abscissa x corresponding to the target father knowledge node ffStandard width value w of target parent knowledge node f of 2000 pixelsfWhich is 2000 pixels. Substituting the data into the formula x ═ xf+wq+(w-wf) The corresponding plotted abscissa x of the available knowledge node h is 2500 pixels.
S380, judging whether all the knowledge nodes are processed, and if all the knowledge nodes are processed, jumping to S390; if not, returning to S340, and continuing to sequentially acquire a knowledge node as a second processing node in the order from the lower hierarchy to the higher hierarchy.
And S390, generating a knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing ordinate and the drawing abscissa.
Optionally, in order to keep a certain gap between knowledge nodes and alleviate the congestion between knowledge nodes, the display width and the display height may be set with the drawing abscissa and the drawing ordinate corresponding to each knowledge node as the center, respectively. The display width is less than or equal to the standard width value corresponding to the corresponding knowledge node, and the display height is less than or equal to the standard height value corresponding to the corresponding knowledge node.
Optionally, canvas software may be adopted to render each knowledge node in the set S according to the display width and the display height, fill corresponding knowledge information in each knowledge node, and draw a connection line between the knowledge nodes, and the generated knowledge tree is shown in fig. 6. Alternatively, the display shape of the knowledge node may be various shapes such as a circle, a rectangle, a rounded rectangle, and the like.
In this embodiment, for the root knowledge node, the drawing abscissa corresponding to the second processing node is calculated according to the occupation width of the second processing node and the arrangement sequence between the second processing node and the root knowledge node on the same layer, so that the root knowledge node can be horizontally arranged, and the root knowledge node is prevented from overlapping. For the non-root knowledge node, the drawing abscissa corresponding to the second processing node is calculated according to the drawing abscissa corresponding to the target parent knowledge node corresponding to the second processing node, the standard width value of the target parent knowledge node, the standard width value of the second processing node and the arrangement sequence of other child knowledge nodes under the target parent knowledge node, so that the child knowledge nodes are drawn under the corresponding main parent knowledge node, the knowledge tree is more attractive, and the parent-child relationship is clearer.
Example four
The device for generating the knowledge tree provided by the embodiment of the invention can execute the method for generating the knowledge tree provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Fig. 7 is a schematic block diagram of an apparatus for generating a knowledge tree according to a fourth embodiment of the present invention, as shown in fig. 7, the apparatus includes an obtaining module 410, a first determining module 420, a second determining module 430, and a generating module 440.
An obtaining module 410, configured to obtain two or more knowledge nodes and a hierarchical relationship between the knowledge nodes.
The first determining module 420 is configured to determine a drawing ordinate corresponding to each knowledge node according to the hierarchical relationship.
And a second determining module 430, configured to determine the drawing abscissa corresponding to each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node and the arrangement sequence between the sub knowledge nodes and the knowledge nodes on the same layer.
And the generating module 440 is configured to generate a knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing ordinate, and the drawing abscissa.
According to the embodiment of the invention, the knowledge tree is automatically generated by acquiring the hierarchical relationship between two or more knowledge nodes and the knowledge nodes, determining the drawing vertical coordinate corresponding to each knowledge node according to the hierarchical relationship, determining the drawing horizontal coordinate corresponding to each knowledge node according to the standard width value of the sub-knowledge nodes corresponding to each knowledge node and the arrangement sequence between the sub-knowledge nodes and the knowledge nodes on the same layer, and generating the knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing vertical coordinate and the drawing horizontal coordinate, so that manual drawing is not needed, and the labor cost is saved.
In an alternative embodiment, the hierarchy of root knowledge nodes is lower than the hierarchy of leaf knowledge nodes; the second determining module 430 is specifically configured to, when determining the drawing abscissa corresponding to each knowledge node according to the standard width value of the sub-knowledge node corresponding to each knowledge node and the arrangement sequence between the sub-knowledge nodes and the knowledge nodes on the same layer: according to the sequence from a high level to a low level, obtaining the occupation width attribute of each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node, wherein the occupation width attribute comprises: the occupation width of the non-root knowledge node under the corresponding father knowledge node and the occupation width of the root knowledge node; and calculating drawing abscissas corresponding to the knowledge nodes according to the sequence from the low level to the high level and according to the standard width value, the occupation width attribute and the arrangement sequence of the knowledge nodes on the same layer.
In an optional embodiment, the second determining module 430, when obtaining the occupancy width attribute of each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node in the order from the higher level to the lower level, is specifically configured to: sequentially acquiring a knowledge node as a first processing node according to the sequence from a high level to a low level; if the first processing node corresponds to at least one father knowledge node, determining the occupation width of the first processing node under the at least one father knowledge node according to the standard width value of the first processing node, wherein the leaf knowledge node has a set standard width value; updating the standard width value of at least one father knowledge node into a superposition sum of the occupation width of the first processing node under the at least one father knowledge node; if the first processing node is a root knowledge node, directly determining a standard width value corresponding to the first processing node as the occupation width of the first processing node; and returning to execute the operation of sequentially acquiring a knowledge node as a first processing node according to the sequence from the high level to the low level until the processing of all the knowledge nodes is completed.
In an optional embodiment, the second determining module 430, when determining the occupancy width of the first processing node under the at least one parent knowledge node according to the standard width value of the first processing node, is specifically configured to: if the first processing node corresponds to the unique father knowledge node, determining the standard width value of the first processing node as the occupation width of the first processing node under the unique father knowledge node; and if the first processing node corresponds to at least two father knowledge nodes, selecting a main father knowledge node from the at least two father knowledge nodes, determining the standard width value of the first processing node as the occupation width of the first processing node under the main father knowledge node, and determining the standard width value of the leaf knowledge node as the occupation width of the first processing node under other father knowledge nodes except the main father knowledge node.
In an alternative embodiment, the second determining module 430, when selecting the primary parent knowledge node from the at least two parent knowledge nodes, is specifically configured to: the method comprises the steps of respectively obtaining arrangement positions of at least two father knowledge nodes in a hierarchy, and taking the father knowledge node closest to a preset position in each arrangement position as a main father knowledge node.
In an alternative embodiment, the second determining module 430, when calculating the drawing abscissa corresponding to each knowledge node according to the standard width value, the occupation width attribute, and the arrangement order between the knowledge nodes on the same layer in order from the lower level to the upper level, is specifically configured to: sequentially acquiring a knowledge node as a second processing node according to the sequence from a low hierarchy to a high hierarchy; if the second processing node is the root knowledge node, calculating a drawing abscissa corresponding to the second processing node according to the occupied width of the second processing node and the arrangement sequence between the second processing node and the root knowledge node on the same layer; if the second processing node is a non-root knowledge node, calculating a drawing abscissa corresponding to the second processing node according to a drawing abscissa corresponding to a target parent knowledge node corresponding to the second processing node, a standard width value of the target parent knowledge node, a standard width value of the second processing node and an arrangement sequence between the second processing node and other child knowledge nodes under the target parent knowledge node; the target parent knowledge node comprises: a unique parent of the second processing node, or a master parent of the second processing node.
In an optional embodiment, when the second determining module 430 calculates the drawing abscissa corresponding to the second processing node according to the occupation width of the second processing node and the arrangement sequence between the second processing node and the root knowledge node on the same layer if the second processing node is the root knowledge node, the second determining module is specifically configured to: according to the arrangement sequence between the second processing node and the root knowledge nodes in the same layer, calculating the sum w of the occupied widths of the root knowledge nodes arranged in the preset direction of the second processing node in the root knowledge nodes in the same layerp(ii) a According to the formula x ═ + - (w)p+ w/2), calculating a drawing abscissa x corresponding to the second processing node; where w is the footprint of the second processing node.
In an optional embodiment, the second determining module 430 is specifically configured to, when calculating the drawing abscissa corresponding to the second processing node according to the drawing abscissa corresponding to the target parent knowledge node corresponding to the second processing node, the standard width value of the target parent knowledge node, the standard width value of the second processing node, and an arrangement order between the second processing node and other child knowledge nodes under the target parent knowledge node, if the second processing node is a non-root knowledge node: according to the arrangement sequence between the second processing node and other child knowledge nodes under the target father knowledge node, calculating the sum w of the occupied widths of the knowledge nodes arranged in the preset direction of the second processing node in the child knowledge nodes under the target father knowledge nodeq(ii) a According to the formula x ═ xf±[wq+(w-wf)/2]Calculating a drawing abscissa x corresponding to the second processing node; where w is the standard width value of the second processing node, xfIs a target parent knowledge node corresponding to the second processing nodePlotted abscissa, w, corresponding to the pointfIs the standard width value of the target parent knowledge node corresponding to the second processing node.
In an optional embodiment, the second determining module 430 calculates a sum w of occupied widths of root knowledge nodes arranged in a preset direction of the second processing node in the root knowledge nodes of the same layer according to an arrangement order between the second processing node and the root knowledge nodes of the same layerpPreviously, it was also used to: counting the number of the child knowledge nodes of each knowledge node; and sequencing the knowledge nodes from left to right according to the sequence of the number of the child knowledge nodes of each knowledge node from small to large so as to obtain the sequence of the second processing node and the root knowledge nodes on the same layer.
In an optional implementation manner, the second determining module 430 calculates the sum w of the occupied widths of the knowledge nodes arranged in the preset direction of the second processing node in the target parent knowledge node among the child knowledge nodes under the target parent knowledge node according to the arrangement sequence between the second processing node and other child knowledge nodes under the target parent knowledge nodeqPreviously, it was also used to: counting the number of the child knowledge nodes of each child knowledge node under the target parent knowledge node; and sequencing the child knowledge nodes under the target father knowledge node from left to right according to the sequence of the number of the child knowledge nodes of each child knowledge node under the target father knowledge node from small to large so as to obtain the sequence of the second processing node and other child knowledge nodes under the target father knowledge node.
In an optional embodiment, when determining the drawing ordinate corresponding to each knowledge node according to the hierarchical relationship, the first determining module 420 is specifically configured to: selecting any level from the levels as a reference level*(ii) a Sequentially acquiring the knowledge nodes on the same layer from two or more knowledge nodes as a third processing node set; according to the formula y ═ y*+(level*-level) × a, calculating a rendering ordinate y for the third set of processing nodes, wherein y is*The drawing ordinate corresponds to the knowledge node at the reference level, the level is the level at which the third processing node set is located, and a is the standard height value of each knowledge node.
EXAMPLE five
Fig. 8 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention, as shown in fig. 8, the electronic device includes a processor 80 and a memory 81; the number of the processors 80 in the electronic device may be one or more, and one processor 80 is taken as an example in fig. 8; the processor 80 and the memory 81 in the electronic device may be connected by a bus or other means, and fig. 8 illustrates the connection by the bus as an example.
The memory 81 is used as a computer-readable storage medium for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the method for generating a knowledge tree in the embodiment of the present invention (for example, the obtaining module 410, the first determining module 420, the second determining module 430, and the generating module 440 in the knowledge tree generating apparatus). The processor 80 executes various functional applications and data processing of the electronic device by executing software programs, instructions and modules stored in the memory 81, that is, implements the above-described knowledge tree generation method.
The memory 81 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 81 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the memory 81 may further include memory located remotely from the processor 80, which may be connected to the electronic device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
EXAMPLE six
An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, the computer program, when executed by a computer processor, is configured to perform a method for generating a knowledge tree, the method including:
acquiring two or more knowledge nodes and a hierarchical relationship between the knowledge nodes;
determining a drawing ordinate corresponding to each knowledge node according to the hierarchical relationship;
determining a drawing abscissa corresponding to each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node and the arrangement sequence of the sub knowledge nodes and the knowledge nodes on the same layer;
and generating a knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing ordinate and the drawing abscissa.
Of course, the computer program of the computer-readable storage medium storing thereon the computer program according to the embodiments of the present invention is not limited to the above method operations, and may also perform related operations in the method for generating a knowledge tree according to any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods of the embodiments of the present invention.
It should be noted that, in the embodiment of the knowledge tree generation apparatus, the included units and modules are only divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments illustrated herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (12)

1. A method for generating a knowledge tree, comprising:
acquiring two or more knowledge nodes and a hierarchical relationship between the knowledge nodes;
determining a drawing ordinate corresponding to each knowledge node according to the hierarchical relationship;
determining a drawing abscissa corresponding to each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node and the arrangement sequence of the sub knowledge nodes and the knowledge nodes on the same layer;
generating a knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing ordinate and the drawing abscissa;
the hierarchy of the root knowledge node is lower than the hierarchy of the leaf knowledge node;
the determining of the drawing abscissa corresponding to each knowledge node according to the standard width value of the sub-knowledge node corresponding to each knowledge node and the arrangement sequence between the sub-knowledge nodes and the knowledge nodes on the same layer comprises:
according to the sequence from a high level to a low level, obtaining the occupation width attribute of each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node, wherein the occupation width attribute comprises: the occupation width of the non-root knowledge node under the corresponding father knowledge node and the occupation width of the root knowledge node;
calculating drawing abscissas corresponding to the knowledge nodes according to the sequence from a low level to a high level and according to the standard width value, the occupation width attribute and the arrangement sequence of the knowledge nodes on the same layer;
the knowledge node carries knowledge information in at least one form, and the knowledge node also carries a node identification of the knowledge node and a node identification of a father knowledge node of the knowledge node;
determining a drawing ordinate corresponding to each knowledge node according to the hierarchical relationship comprises:
selecting any level from the levels as a reference level*
Sequentially acquiring the knowledge nodes on the same layer from the two or more knowledge nodes as a third processing node set;
according to the formula y ═ y*+(level*-level) × a, calculating a rendering ordinate y for the third set of processing nodes, wherein y is*The drawing ordinate corresponds to the knowledge node at the reference level, the level is the level at which the third processing node set is located, and a is the standard height value of each knowledge node.
2. The method of claim 1, wherein obtaining the occupancy width attribute of each knowledge node according to the standard width value of the sub-knowledge node corresponding to each knowledge node in an order from a high level to a low level comprises:
sequentially acquiring a knowledge node as a first processing node according to the sequence from a high level to a low level;
if the first processing node corresponds to at least one father knowledge node, determining the occupation width of the first processing node under the at least one father knowledge node according to the standard width value of the first processing node, wherein leaf knowledge nodes have set standard width values;
updating the standard width value of the at least one parent knowledge node to be a superposition sum of the occupation width of the first processing node under the at least one parent knowledge node;
if the first processing node is a root knowledge node, directly determining a standard width value corresponding to the first processing node as the occupation width of the first processing node;
and returning to execute the operation of sequentially acquiring a knowledge node as a first processing node according to the sequence from the high level to the low level until the processing of all the knowledge nodes is completed.
3. The method of claim 2, wherein determining the occupancy width of the first processing node under the at least one parent knowledge node based on the standard width value of the first processing node comprises:
if the first processing node corresponds to a unique parent knowledge node, determining the standard width value of the first processing node as the occupation width of the first processing node under the unique parent knowledge node;
if the first processing node corresponds to at least two father knowledge nodes, selecting a main father knowledge node from the at least two father knowledge nodes, determining the standard width value of the first processing node as the occupation width of the first processing node under the main father knowledge node, and determining the standard width value of a leaf knowledge node as the occupation width of the first processing node under other father knowledge nodes except the main father knowledge node.
4. The method of claim 3, wherein selecting a master parent knowledge node among the at least two parent knowledge nodes comprises:
and respectively acquiring the arrangement positions of the at least two father knowledge nodes in the hierarchy, and taking the father knowledge node closest to a preset position in each arrangement position as the main father knowledge node.
5. The method according to any one of claims 2-4, wherein the calculating the drawing abscissa corresponding to each knowledge node according to the standard width value, the occupancy width attribute and the arrangement sequence of the knowledge nodes on the same layer from the lower level to the upper level comprises:
sequentially acquiring a knowledge node as a second processing node according to the sequence from a low hierarchy to a high hierarchy;
if the second processing node is a root knowledge node, calculating a drawing abscissa corresponding to the second processing node according to the occupied width of the second processing node and the arrangement sequence between the second processing node and the root knowledge node on the same layer;
if the second processing node is a non-root knowledge node, calculating a drawing abscissa corresponding to the second processing node according to a drawing abscissa corresponding to a target parent knowledge node corresponding to the second processing node, a standard width value of the target parent knowledge node, a standard width value of the second processing node and an arrangement sequence between the second processing node and other child knowledge nodes under the target parent knowledge node;
the target parent knowledge node comprises: a unique parent of the second processing node, or a master parent of the second processing node.
6. The method according to claim 5, wherein if the second processing node is a root knowledge node, calculating a drawing abscissa corresponding to the second processing node according to the occupation width of the second processing node and the arrangement sequence between the second processing node and the root knowledge node at the same layer comprises:
according to the arrangement sequence between the second processing node and the root knowledge nodes in the same layer, calculating the sum w of the occupied widths of the root knowledge nodes arranged in the preset direction of the second processing node in the root knowledge nodes in the same layerp
According to the formula x ═ + - (w)p+ w/2), calculating a drawing abscissa x corresponding to the second processing node;
wherein w is the footprint of the second processing node.
7. The method of claim 5, wherein if the second processing node is a non-root knowledge node, calculating a drawing abscissa corresponding to the second processing node according to a drawing abscissa corresponding to a target parent knowledge node corresponding to the second processing node, a standard width value of the target parent knowledge node, a standard width value of the second processing node, and an arrangement order among other child knowledge nodes under the target parent knowledge node, comprises:
calculating the sum w of the occupied widths of the knowledge nodes arranged in the preset direction of the second processing node in all the child knowledge nodes under the target father knowledge node according to the arrangement sequence between the second processing node and other child knowledge nodes under the target father knowledge nodeq
According to the formula x ═ xf±[wq+(w-wf)/2]Calculating a drawing abscissa x corresponding to the second processing node;
wherein w is a standard width value of the second processing node, xfIs a drawing abscissa, w, corresponding to a target parent knowledge node corresponding to the second processing nodefIs the standard width value of the target parent knowledge node corresponding to the second processing node.
8. The method according to claim 6, wherein the sum w of the occupied widths of the root knowledge nodes arranged in the preset direction of the second processing node in the root knowledge nodes in the same layer is calculated according to the arrangement sequence between the second processing node and the root knowledge nodes in the same layerpBefore, still include:
counting the number of the child knowledge nodes of each knowledge node;
and sequencing the knowledge nodes from left to right according to the sequence of the number of the child knowledge nodes of each knowledge node from small to large so as to obtain the sequence of the second processing node and the root knowledge nodes on the same layer.
9. The method of claim 7, wherein calculating the second processing node default for each of the children nodes under the target parent node based on the rank between the second processing node and other children nodes under the target parent nodeSum w of occupation widths of directional knowledge nodes under the target parent knowledge nodeqBefore, still include:
counting the number of the child knowledge nodes of each child knowledge node under the target parent knowledge node;
and sequencing the child knowledge nodes under the target father knowledge node from left to right according to the sequence of the number of the child knowledge nodes of each child knowledge node under the target father knowledge node from small to large so as to obtain the sequence of the second processing node and other child knowledge nodes under the target father knowledge node.
10. An apparatus for generating a knowledge tree, comprising:
the acquisition module is used for acquiring two or more knowledge nodes and the hierarchical relationship between the knowledge nodes;
the first determining module is used for determining a drawing ordinate corresponding to each knowledge node according to the hierarchical relationship;
the second determining module is used for determining a drawing abscissa corresponding to each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node and the arrangement sequence between the sub knowledge nodes and the knowledge nodes on the same layer;
the generating module is used for generating a knowledge tree corresponding to the knowledge node according to the hierarchical relationship, the drawing ordinate and the drawing abscissa;
the second determining module is specifically configured to, when determining the drawing abscissa corresponding to each knowledge node according to the standard width value of the sub-knowledge node corresponding to each knowledge node and the arrangement order between the sub-knowledge nodes and the knowledge nodes on the same layer: according to the sequence from a high level to a low level, obtaining the occupation width attribute of each knowledge node according to the standard width value of the sub knowledge node corresponding to each knowledge node, wherein the occupation width attribute comprises: the occupation width of the non-root knowledge node under the corresponding father knowledge node and the occupation width of the root knowledge node; calculating drawing abscissas corresponding to the knowledge nodes according to the sequence from a low level to a high level and according to the standard width value, the occupation width attribute and the arrangement sequence of the knowledge nodes on the same layer;
the knowledge node carries knowledge information in at least one form, and the knowledge node also carries a node identification of the knowledge node and a node identification of a father knowledge node of the knowledge node;
the first determining module is specifically configured to, when determining the drawing ordinate corresponding to each knowledge node according to the hierarchical relationship: selecting any level from the levels as a reference level*(ii) a Sequentially acquiring the knowledge nodes on the same layer from two or more knowledge nodes as a third processing node set; according to the formula y*+(level*-level) × a, calculating a drawing ordinate y corresponding to the third processing node set, where y is the drawing ordinate corresponding to the knowledge node at the reference level, level is the level at which the third processing node set is located, and a is the standard height value of each knowledge node.
11. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a memory for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a method of generating a knowledge tree as claimed in any one of claims 1-9.
12. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method of generating a knowledge tree according to any one of claims 1 to 9.
CN201810330016.7A 2018-04-13 2018-04-13 Knowledge tree generation method, device, equipment and storage medium Active CN108536837B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810330016.7A CN108536837B (en) 2018-04-13 2018-04-13 Knowledge tree generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810330016.7A CN108536837B (en) 2018-04-13 2018-04-13 Knowledge tree generation method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN108536837A CN108536837A (en) 2018-09-14
CN108536837B true CN108536837B (en) 2022-04-01

Family

ID=63480567

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810330016.7A Active CN108536837B (en) 2018-04-13 2018-04-13 Knowledge tree generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN108536837B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5752253A (en) * 1994-06-28 1998-05-12 Bull, S.A. Process and device for the automatic generation of spreadsheets
CN102135973A (en) * 2010-08-09 2011-07-27 华为软件技术有限公司 Knowledge search map as well as method and device for generating same
CN102467535A (en) * 2010-11-12 2012-05-23 金蝶软件(中国)有限公司 Method, device and system for acquiring tree data output coordinate
CN102566849A (en) * 2010-12-10 2012-07-11 金蝶软件(中国)有限公司 Method and device for acquiring tree-form data drawing output positions and ERP (enterprise resource planning) system
CN108694876A (en) * 2017-04-10 2018-10-23 郑柏胜 Electrophonic musical shines knowledge tree

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5752253A (en) * 1994-06-28 1998-05-12 Bull, S.A. Process and device for the automatic generation of spreadsheets
CN102135973A (en) * 2010-08-09 2011-07-27 华为软件技术有限公司 Knowledge search map as well as method and device for generating same
CN102467535A (en) * 2010-11-12 2012-05-23 金蝶软件(中国)有限公司 Method, device and system for acquiring tree data output coordinate
CN102566849A (en) * 2010-12-10 2012-07-11 金蝶软件(中国)有限公司 Method and device for acquiring tree-form data drawing output positions and ERP (enterprise resource planning) system
CN108694876A (en) * 2017-04-10 2018-10-23 郑柏胜 Electrophonic musical shines knowledge tree

Also Published As

Publication number Publication date
CN108536837A (en) 2018-09-14

Similar Documents

Publication Publication Date Title
CN106570453B (en) Method, device and system for pedestrian detection
US10083517B2 (en) Segmentation of an image based on color and color differences
US8605092B2 (en) Method and apparatus of animation planning for a dynamic graph
CN109994038B (en) Method and device for determining interest points in irregular area and electronic equipment
JP2012530319A (en) Method and system for quasi-duplicate image retrieval
CN111428457B (en) Automatic formatting of data tables
CN106649805B (en) Efficient detection system and method for cross-browser layout compatibility of Web application
CN105957113B (en) Manhattan network-based horizontal inscribed rectangle algorithm and device for any connected domain
JP6608972B2 (en) Method, device, server, and storage medium for searching for group based on social network
CN112328880A (en) Geographical region clustering method and device, storage medium and electronic equipment
CN112717414B (en) Game scene editing method and device, electronic equipment and storage medium
CN114418836B (en) Data processing method, device, equipment and medium
CN110120059B (en) Icon generation method and device
CN112652189B (en) Traffic distribution method, device and equipment based on policy flow and readable storage medium
CN108536837B (en) Knowledge tree generation method, device, equipment and storage medium
CN111161289B (en) Method and device for improving contour precision of object in image
CN112734900A (en) Baking method, baking device, baking equipment and computer-readable storage medium of shadow map
CN115779424A (en) Navigation grid path finding method, device, equipment and medium
CN115147442A (en) Grid pattern vectorization method, mobile terminal, electronic device, and medium
CN104008125B (en) The dynamic multi-level histogram methods of exhibiting of hierarchical data
CN104541289B (en) A kind of point of interest determination methods and point of interest judgment means
JP6713099B2 (en) Learned model integration method, device, program, IC chip, and system
Tian et al. An approach to generate spatial Voronoi Treemaps for points, lines, and polygons
CN113191310A (en) Boundary identification method, device and equipment for vector PDF drawing entity filling
JP2009116404A (en) Alloy design support system, alloy design support program, and alloy design support method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20220302

Address after: Room 118, building 20, no.1-42, Lane 83, Hongxiang North Road, Lingang New District, China (Shanghai) pilot Free Trade Zone, Pudong New Area, Shanghai

Applicant after: Shanghai qujie Information Technology Co.,Ltd.

Address before: 200233 room 310-1, building 84 (Building 1), No. 700, Yishan Road, Xuhui District, Shanghai

Applicant before: DROILAW (SHANGHAI) NETWORK TECHNOLOGY Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant
CP02 Change in the address of a patent holder

Address after: Room 102, Building 18, No. 1625 Caobao Road, Minhang District, Shanghai, 201101

Patentee after: Shanghai qujie Information Technology Co.,Ltd.

Address before: Room 118, building 20, no.1-42, Lane 83, Hongxiang North Road, Lingang New District, China (Shanghai) pilot Free Trade Zone, Pudong New Area, Shanghai

Patentee before: Shanghai qujie Information Technology Co.,Ltd.

CP02 Change in the address of a patent holder