CN106156238B - Ontology information querying method and system - Google Patents

Ontology information querying method and system Download PDF

Info

Publication number
CN106156238B
CN106156238B CN201510205659.5A CN201510205659A CN106156238B CN 106156238 B CN106156238 B CN 106156238B CN 201510205659 A CN201510205659 A CN 201510205659A CN 106156238 B CN106156238 B CN 106156238B
Authority
CN
China
Prior art keywords
leaf node
known variables
query
traversal
positive sequence
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
CN201510205659.5A
Other languages
Chinese (zh)
Other versions
CN106156238A (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.)
Tsinghua University
iFlytek Co Ltd
Original Assignee
Tsinghua University
iFlytek 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 Tsinghua University, iFlytek Co Ltd filed Critical Tsinghua University
Priority to CN201510205659.5A priority Critical patent/CN106156238B/en
Publication of CN106156238A publication Critical patent/CN106156238A/en
Application granted granted Critical
Publication of CN106156238B publication Critical patent/CN106156238B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/31Indexing; Data structures therefor; Storage structures
    • G06F16/316Indexing structures
    • G06F16/322Trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/36Creation of semantic tools, e.g. ontology or thesauri
    • G06F16/367Ontology

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Animal Behavior & Ethology (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a kind of ontology information querying method and systems, this method comprises: receiving inquiry request;Query tree is constructed according to the inquiry request;Each leaf node that the query tree is traversed in such a way that positive sequence and inverted order combine obtains known variables value set in the leaf node;If the known variables have corresponding value in the known variables value set, using the known variables value set as query result.Using the present invention, information search efficiency can be improved, reduce the consumption to memory.

Description

Ontology information querying method and system
Technical field
The present invention relates to information query technique fields, and in particular to a kind of ontology information querying method and system.
Background technique
With the development of internet technology, the speed that information increases is getting faster, and people are also usually by a large amount of garbages Perplexed, can not from a large amount of information quick search to oneself interested resource.
Ontology is the key element in research of semantic web field, it is the specification explanation of shared conceptual model formalization, clear Explicitly define the relationship between concept and concept.Since its concept criterion, semantic relation are clear, it is easy to find out resource Between implicit connection, resource is effectively organized, become expression domain knowledge main means.Knowing based on ontology Know library bottom knowledge base is described using ontology.Since ontology and ontology knowledge base are built upon the logical description of formalization On, therefore the knowledge in ontology knowledge base in order to obtain, it usually needs the query information of user is converted into ontology knowledge base The inquiry request supported handles inquiry request in such a way that deep grammar analysis and Shallow Semantic Parsing combine, most The query result of user's needs is obtained eventually.Therefore, how efficiently and rapidly by ontology knowledge base carry out information inquiry at For the hot issue of researcher's research.
Existing ontology information querying method is usually to construct corresponding query tree according to the inquiry request of user, then right Query tree is traversed to obtain query result.When existing method traverses query tree, need to save in non-leaf nodes The value set of known variables, the value set simultaneously participate in the intersection operation that takes of known variables value, and in non-leaf nodes The known variables value of preservation had been saved in leaf node, therefore, was equivalent to unknown in repetition preservation non-leaf nodes Variable-value or value set at the end of query tree traverses, generally require to repeat to save known variables in a large amount of leaf nodes and take Value or value set, cause search efficiency to substantially reduce, especially there are when a large amount of non-leaf nodes in query tree.
Summary of the invention
The embodiment of the present invention provides a kind of ontology information querying method and system, to improve information search efficiency.
For this purpose, the embodiment of the present invention provides the following technical solutions:
A kind of ontology information querying method, comprising:
Receive inquiry request;
Query tree is constructed according to the inquiry request;
Each leaf node that the query tree is traversed in such a way that positive sequence and inverted order combine obtains the leaf section Known variables value set in point.
Preferably, described to include: according to inquiry request building query tree
The inquiry request is converted into Ontology Query sentence;
According to the Ontology Query sentence builder query tree, described in each triple correspondence in the Ontology Query sentence A leaf node in query tree records the known variables information in triple on the leaf node.
Preferably, the positive sequence traversal direction is to traverse from bottom to top, and inverted order traversal direction is to traverse from top to down;
It is described to traverse the query tree in such a way that positive sequence and inverted order combine, obtain the leaf node of the query tree Middle known variables value set includes:
The each leaf node for traversing the query tree from bottom to top with positive sequential mode obtains positive sequence traversal queries result;
If after positive sequence traverses, had containing element is not used in the value set of aleatory variable, then from positive sequential mode The last one leaf node of traversal starts, and each leaf node of the top-down traversal query tree, obtains in a manner of inverted order To inverted order traversal queries result;
According to the positive sequence traversal queries result and inverted order traversal queries as a result, obtaining known variables in the leaf node Value set.
Preferably, each leaf node for traversing the query tree from bottom to top with positive sequential mode, obtains positive sequence time Going through query result includes:
Obtain the leaf node of current positive sequence traversal;
If the leaf node is first leaf node, the corresponding ternary of first leaf node is inquired Group obtains known variables value set in first leaf node;
If the known variables value set is not sky, a member is chosen from the known variables value set Current value of the element as known variables described in first leaf node, then traverses next leaf node;
If the leaf node is not first leaf node, non-new known variables in the leaf node are obtained Then current value inquires the corresponding triple of the leaf node;
If inquiring the corresponding triple success of the leaf node, obtains known variables in the leaf node and take Value, or obtain known variables value and new known variables value set in the leaf node;
If inquiring the corresponding triple failure of the leaf node, back to new unknown change non-in the leaf node Leaf node that flow control once occurs simultaneously executes inverted order traversing operation to it, and positive sequence traverses next leaf section after the completion of operation Point;
After the completion of the last one node positive sequence traversal of the query tree, if all known variables all obtain value, Positive sequence traverses successfully, and the value of the known variables of acquisition is added in positive sequence traversal queries result.
Preferably, each leaf node of the traversal query tree top-down in a manner of inverted order, obtains inverted order time Going through query result includes:
Obtain the leaf node of current inverted order traversal;
If the leaf node is the last one leaf node, by the unknown change in the last one described leaf node It measures unused element in value set to be added in inverted order traversal queries result, then traverses next leaf node;
If the leaf node is not the last one leaf node of positive sequence traversal, whether the leaf node is judged Comprising new known variables, and comprising element is not used in new known variables value set;
If it is, successively taking a unused element as described new unknown from the new known variables value set The current value of variable, then positive sequence traverses the query tree since next leaf node;If it is not, then under inverted order traversal One leaf node;
After the completion of first node inverted order traversal of the query tree, the value of the known variables of acquisition is added to inverted order In traversal queries result.
Preferably, the method also includes:
If there is any known variables do not inquire corresponding value, it is determined that inquiry failure.
A kind of ontology information inquiry system, comprising:
Receiving module, for receiving inquiry request;
Query tree constructs module, for constructing query tree according to the inquiry request;
Enquiry module, for traversing each leaf node of the query tree in such a way that positive sequence and inverted order combine, Obtain known variables value set in the leaf node.
Preferably, the query tree building module includes:
Sentence converting unit, for the inquiry request to be converted to Ontology Query sentence;
Construction unit, for according to each of the Ontology Query sentence builder query tree, the Ontology Query sentence Triple corresponds to a leaf node in the query tree, and the known variables letter in triple is recorded on the leaf node Breath.
Preferably, the positive sequence traversal direction is to traverse from bottom to top, and inverted order traversal direction is to traverse from top to down;
The enquiry module includes:
First query unit is obtained for traversing each leaf node of the query tree from bottom to top with positive sequential mode Positive sequence traversal queries result;
Second query unit, for having the value collection of aleatory variable after the first query unit positive sequence traversal It is top-down in a manner of inverted order since the last one leaf node that positive sequential mode traverses when in conjunction containing element is not used The each leaf node for traversing the query tree obtains inverted order traversal queries result;
Query result obtaining unit, for according to the positive sequence traversal queries result and inverted order traversal queries as a result, obtaining Known variables value set in the leaf node.
Preferably, the query process of first query unit is as follows:
Obtain the leaf node of current positive sequence traversal;
If the leaf node is first leaf node, the corresponding ternary of first leaf node is inquired Group obtains known variables value set in first leaf node;
If the known variables value set is not sky, a member is chosen from the known variables value set Current value of the element as known variables described in first leaf node, then traverses next leaf node;
If the leaf node is not first leaf node, non-new known variables in the leaf node are obtained Then current value inquires the corresponding triple of the leaf node;
If inquiring the corresponding triple success of the leaf node, obtains known variables in the leaf node and take Value, or obtain known variables value and new known variables value set in the leaf node;
If inquiring the corresponding triple failure of the leaf node, back to new unknown change non-in the leaf node Leaf node that flow control once occurs simultaneously executes inverted order traversing operation to it, and positive sequence traverses next leaf section after the completion of operation Point;
After the completion of the last one node positive sequence traversal of the query tree, if all known variables all obtain value, Positive sequence traverses successfully, and the value of the known variables of acquisition is added in positive sequence traversal queries result.
Preferably, the query process of second query unit is as follows:
Obtain the leaf node of current inverted order traversal;
If the leaf node is the last one leaf node, by the unknown change in the last one described leaf node It measures unused element in value set to be added in inverted order traversal queries result, then traverses next leaf node;
If the leaf node is not the last one leaf node of positive sequence traversal, whether the leaf node is judged Comprising new known variables, and comprising element is not used in new known variables value set;
If it is, successively taking a unused element as described new unknown from the new known variables value set The current value of variable, then positive sequence traverses the query tree since next leaf node;If it is not, then under inverted order traversal One leaf node;
After the completion of first node inverted order traversal of the query tree, the value of the known variables of acquisition is added to inverted order In traversal queries result.
Preferably, the enquiry module is also used to after the completion of traversal, has any known variables not inquire corresponding When value, inquiry failure is determined.
Ontology information querying method provided in an embodiment of the present invention and system, are looked into using the method that positive sequence and inverted order combine Known variables value set in each leaf node of query tree is looked for, query process does not need to save unknown change in non-leaf nodes The value of amount need to only save known variables value set in traversed leaf node once, while to first in value set Element also only carries out a search operation, so as to greatly save query time, improves search efficiency.
Detailed description of the invention
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, below will be to institute in embodiment Attached drawing to be used is needed to be briefly described, it should be apparent that, the accompanying drawings in the following description is only one recorded in the present invention A little embodiments are also possible to obtain other drawings based on these drawings for those of ordinary skill in the art.
Fig. 1 is the flow chart of ontology information querying method of the embodiment of the present invention;
Fig. 2 is an example of query tree of the embodiment of the present invention;
Fig. 3 is the flow chart of positive sequence traversal queries tree in the embodiment of the present invention;
When Fig. 4 is positive sequence traversal queries tree in the embodiment of the present invention, to the inquiry operation flow chart of k-th of leaf node;
Fig. 5 is the flow chart of inverted order traversal queries tree in the embodiment of the present invention;
When Fig. 6 is inverted order traversal queries tree in the embodiment of the present invention, to the inquiry operation flow chart of q-th of leaf node;
Fig. 7 is the structural schematic diagram of ontology information inquiry system of the embodiment of the present invention.
Specific embodiment
The scheme of embodiment in order to enable those skilled in the art to better understand the present invention with reference to the accompanying drawing and is implemented Mode is described in further detail the embodiment of the present invention.
As shown in Figure 1, being the flow chart of semantics comprehension on natural language method of the embodiment of the present invention, comprising the following steps:
Step 101, inquiry request is received.
Step 102, query tree is constructed according to the inquiry request.
Firstly, the inquiry request is converted to Ontology Query sentence, then looked into according to the Ontology Query sentence builder Ask tree.
Specifically, the query statement that the inquiry request that user inputs is converted to ontology knowledge base support, as SPARQL is looked into Sentence is ask, the form that triple can be used in the query statement indicates that the triple is according to S-P-O (i.e. Subject- Predicate-Object form) indicates, specific conversion method can be used natural language understanding method or artificial side Method.
Inquiry request as user inputs is " course which teacher student Alice has selected ", and the SPARQL after conversion is looked into It is as follows to ask sentence:
Select? teacher
Where{
Person name " Alice "
Person type Student.
Person takesCourse? course.
Person teacherOf? course.
}
Process according to Ontology Query sentence builder query tree is as described below:
Step 1: creating a leaf node for each triple in Ontology Query sentence, record should in leaf node The value of known variables and known variables and known variables in triple.Untreated node is added in all leaf nodes Set.
Step 2: increasing a new node as the two sections if there is common known variables between two nodes The father node of point, and using the union of the known variables of the two nodes as the known variables of father node.By the two nodes from It is deleted in untreated node set, and untreated node set is added in father node.
Step 3: the process of second step is repeated, until only including a node in untreated node set.The node The root node as set.
The query tree completed is constructed, contains common known variables between the brotgher of node.If Fig. 2 is according to above-mentioned inquiry language The query tree of sentence building, the query tree share 4 leaf nodes, i.e. L1, L2, L3, L4.Each leaf node is corresponding in query tree A triple in query statement records known variables and known variables in the triple in each leaf node, and Know the value of variable.
Step 103, the query tree is traversed in such a way that positive sequence and inverted order combine, obtained in the leaf node not Know variable-value set.
The positive sequence traversal direction is to traverse from bottom to top, and inverted order traversal direction is to traverse from top to down.In practical application In, positive sequence traversal can be first carried out, then carry out inverted order traversal.In ergodic process, saves each known variables and occur for the first time Leaf node index.Specific ergodic process will be described in detail later.
In practical applications, query result can be returned to inquiry application, and/or query result is presented to user. Certainly, after being traversed to query tree, if showing that this is looked into there are still the known variables for not inquiring corresponding value Ask failure.In this case, the information of inquiry failure can also be returned to inquiry application or user.
The detailed process traversed separately below to two kinds is described in detail.
As shown in figure 3, for the flow chart of positive sequence traversal queries tree in the embodiment of the present invention, comprising the following steps:
Walk a1) obtain the specified leaf node of query tree.
Step b1) judge the leaf node whether be the query tree lower left corner first leaf node, if so, executing step c1);Otherwise, step e1 is executed).
Walk c1) the corresponding triple of first leaf node of inquiry, obtain known variables value in first leaf node Set.If the known variables value set is not sky, take an element as first leaf from the value set The current value of known variables described in child node executes step d1);Otherwise, step i1 is executed).
Step d1) next leaf node is traversed upwards in turn, it is assumed that be k-th of leaf node, execute step e1).
Step e1) k-th of leaf node is operated, specific operation process is as shown in Figure 4, comprising:
41) step obtains the current value of non-new known variables in k-th of leaf node, the non-new known variables refer to Then 42) known variables occurred in node in query tree before k-th of leaf node execute step.
42) step inquires the corresponding triple of k-th of leaf node.If successful inquiring, it is unknown to obtain the leaf node Variable-value or known variables value and new known variables value set (leaf node contains new known variables), then execute Walk d1);If 43) inquiry failure, executes step.
43) inverted order traverses step the leaf node of non-new known variables first time appearance since k-th of leaf node.
Step f1) judge whether to traverse the last one leaf node of query tree.If so, illustrating this positive sequence traversal Terminate, execute step g1);Otherwise, step d1 is executed).
Step g1) judge whether all known variables of this positive sequence traversal all obtain value, if obtained, execute step h1); Otherwise, step i1 is executed).
Step h1) all known variables all obtain a value, and this positive sequence traversal terminates, known variables value is added most In whole query result.Then inverted order traversal is executed since the last one leaf node.
Step i1) there are known variables not to obtain value, inquiry failure.
Inverted order traversal is successively to traverse the process of first leaf node downwards from some specified node of query tree.Just In sequence ergodic process, element in some known variables value set is simultaneously not used by, and needing will in such a way that inverted order traverses These elements are found out, then finally looking into as a result, being not used by element described in judgement and whether can be added in conjunction with positive sequence traversal Ask result.
As shown in figure 5, for the flow chart of inverted order traversal queries tree in the embodiment of the present invention, comprising the following steps:
Walk a2) obtain the specified leaf node of query tree.
Step b2) judge whether the leaf node is the last one leaf node.If it is, executing step c2);Otherwise, Execute step f2).
Step c2) judge whether leaf node contains known variables value set.If it is, executing step d2);Otherwise, it holds Row step e2).
Step d2) not used element in known variables value set is directly added into final query result, execute step e2)。
Step e2) next leaf node is successively traversed downwards, it is assumed that be q-th of leaf node, execute step f2).
Step f2) q-th of leaf node may finally get downwards the 1st leaf node, q-th of leaf node grasped Make, specific operation process is as shown in Figure 6, comprising:
61) step judges whether q-th of leaf node contains new known variables.If it is, executing step 62);Otherwise, it executes Walk e2).
62) step judges whether contain original element in the new known variables value set of q-th of leaf node.If It is then to execute step 63);Otherwise, step e2 is executed).
63) step successively takes an original element from the new known variables value set of q-th of leaf node, as The current value of the new known variables of q-th of leaf node, positive sequence traverses since the q+1 node.
Step g2) judge whether first leaf node traverses and terminates.If it is, executing step h2);Otherwise, step is executed e2)。
Step h2) inverted order traversal terminate, judge whether all known variables have corresponding value in final query result.If It is then to execute step i2);Otherwise, step j2 is executed).
Step i2) all known variables have corresponding value, final successful inquiring.
Walk j2) there are known variables not to find corresponding value, final inquiry failure.
The ergodic process in embodiment to query tree is illustrated the present invention further below.
As shown in Fig. 2, for the query tree of " course which teacher student Alice has selected " building, the query tree shares 4 A leaf node, the process for searching known variables value set in leaf node using the method for the embodiment of the present invention are as follows:
Positive sequence traversal: L1- > L3- > L2- > L4
(1) the leaf node L1 of query tree lower-left first is found, leaf node L1 includes a known variables, inquires leaf Does the corresponding triple of node L1, obtain known variables? value set { P1 }={ p11, p12, p13, the p14 } of person, takes p11 As known variables? the current value of person.
(2) leaf node L3 is traversed upwards in turn, contain non-new known variables in leaf node L3? person and it is new not Do you know variable? course, non-new known variables p11 being assigned in leaf node L3? person, at this time leaf node L3 containing only It is there a known variables? the corresponding triple of course, inquiry leaf node L3;If successful inquiring, leaf node L3 is obtained Known variables? the value p11 and known variables of person? value set { C1 }={ c11, c12, the c13 } of course;If looked into Ask failure, then return to known variables? the leaf node L1 that person occurs for the first time executes inverted order traversal to leaf node L1 Operation, i.e., take the unused element p12 in set { P1 } as known variables backward? the current value of person.Assuming that unknown Variable? does the corresponding triple success of inquiry leaf node L3 obtain known variables when the current value of person is p12? Does is the value of person p12 and known variables? value set { C2 }={ c21, the c22 } of course.
(3) leaf node L2 is traversed upwards in turn, get and contain non-new known variables in leaf node L2? Does is p12 assigned to non-new known variables in leaf node L2 by person? person, leaf node L2 no longer contains unknown change at this time Amount, the corresponding triple of inquiry leaf node L2;If successful inquiring, known variables in leaf node L2 are obtained? person's Value p12;If inquiry failure, returns to known variables? the leaf node L1 that person occurs for the first time, to leaf node L1 executes inverted order traversing operation.Assuming that known variables? when the current value of person is p13, inquiry leaf node L3 is corresponding Does triple success, obtain non-new known variables? does is the value of person p13 and known variables? the value set { C3 } of course ={ c31, c32, c33 }, using c31 as known variables? the current value of course;Inquire the corresponding triple of leaf node L2 Success, known variables? person value is p13.
(4) leaf node L4 is traversed upwards in turn, does leaf node L4 contain new known variables? teacher and it is non-it is new not Do you know variable? course, non-new known variables c31 being assigned in leaf node L4? course, leaf node L4 contains at this time One known variables? the corresponding triple of teacher, inquiry leaf node L4.If successful inquiring, leaf node L4 is obtained Middle known variables? the value c31 and known variables of course? value set { T1 }={ t11, t12, the t13 } of teacher;Such as Fruit inquiry failure, then return to non-new known variables? the leaf node L3 that course occurs for the first time executes leaf node L3 Inverted order traversing operation.Assuming that known variables? when the current value of course is c32, the corresponding triple of inquiry leaf node L4 Does success, obtain the known variables that leaf node L4 includes? the value c32 and known variables of course? the value set of teacher Does { T2 }={ t21, t22, t23 }, take the t21 to be? the current value of teacher.
(5) a positive sequence traversal queries are completed, it is as follows to obtain positive sequence traversal queries result:
Person={ p13 }
Course={ c32 }
Teacher={ t21 }
All known variables have value, and positive sequence traverses successfully.
After positive sequence traversal queries, variable? the value set { P1 } of person, variable? the value set of course { C3 }, variable? all containing element is not used in the value set { T1 } of teacher, need to traverse by inverted order by these values It finds out, is verified then in conjunction with positive sequence traversal and be not used whether element can be added final query result.
Inverted order traversal: L4- > L2- > L3-L1
(1) the last one leaf node of query tree L4, leaf node L4 are found and contains known variables? the value of teacher Gather { T2 }, directly element t22 will be not used in { T2 }, t23 is added in inverted order traversal queries result.
(2) leaf node L2 is successively found downwards, does not contain new known variables in leaf node L2.
(3) leaf node L3 is successively found downwards, contain new known variables in leaf node L3? course, it is new unknown Variable? does is the value collection of course combined into { C3 }, wherein containing element c33 is not used, using c33 as known variables? course's Current value, positive sequence traverses since leaf node L2, and positive sequence traverses leaf node L4.Assuming that successful inquiring, obtains unknown Variable? course value c33 and known variables? teacher value set { T3 }={ t31 }, by known variables? course value C33 and known variables? teacher value t31 is added in inverted order traversal queries result.Then using t31 as variable? The current value of teacher carries out inverted order again from leaf node L4 and traverses leaf node L3, do not contain not in leaf node L3 Use element.
(4) leaf node L1 is successively traversed downwards, does leaf node L1 contain new known variables? person, value collection Close containing element p14 is not used in { P1 }, using p14 as variable? the value of person, the positive sequence directly since leaf node L3 Traversal searches the corresponding triple of leaf node L3, it is assumed that inquiry failure.
(5) no longer containing unused element in leaf node L1, and leaf node L1 is first leaf section of query tree Point, inverted order traversal terminate, and it is as follows to obtain inverted order traversal queries result:
Course={ c33 }
Teacher={ t22, t23, t31 }
In summary positive sequence traversal queries result and inverted order traversal queries are as follows as a result, obtain final query result:
Person={ p13 }
Course={ c32, c33 }
Teacher={ t21, t22, t23, t31 }
It should be noted that in practical applications, when not inquiring corresponding value if there is any known variables, then Illustrate inquiry failure.In such a case, it is possible to corresponding message or prompt information be returned to, for example, answering if it is towards other Inquiry can return to corresponding message to the application;If it is user oriented inquiry, " inquiry can be showed to user The prompt informations such as failure ".
As it can be seen that ontology information querying method provided in an embodiment of the present invention, is looked into using the method that positive sequence and inverted order combine Known variables value set in each leaf node of query tree is looked for, saves institute in the leaf node that known variables occur for the first time The value or value set for stating known variables, take an element from value set, as the current value of known variables, work as institute When stating known variables and occurring again in other leaf nodes, current value need to be only saved.Query process does not need to save The value of known variables in non-leaf nodes need to only save known variables value set in traversed leaf node once, A search operation is also only carried out to element in value set simultaneously, so as to greatly save query time, improves inquiry effect Rate reduces the consumption to memory.
Correspondingly, the embodiment of the present invention also provides a kind of ontology information inquiry system, as shown in fig. 7, being implementation of the present invention The structural schematic diagram of example ontology information inquiry system.
In this embodiment, the system comprises:
Receiving module 701, for receiving inquiry request;
Query tree constructs module 702, for constructing query tree according to the inquiry request;
Enquiry module 703, for traversing each leaf section of the query tree in such a way that positive sequence and inverted order combine Point obtains known variables value set in the leaf node.
Above-mentioned query tree building module 702 may include: sentence converting unit and construction unit.Wherein:
The sentence converting unit is used to the inquiry request being converted to Ontology Query sentence, which is The query statement that the ontology knowledge base to be inquired can be supported, such as SPARQL query statement, specific conversion method be can be used The method etc. of natural language understanding.
The construction unit is used for according to the Ontology Query sentence builder query tree, every in the Ontology Query sentence A triple corresponds to a leaf node in the query tree, and the known variables letter in triple is recorded on the leaf node Breath.
In practical applications, the positive sequence traversal direction is to traverse from bottom to top, and inverted order traversal direction is from top to down time It goes through.
A kind of specific structure of the enquiry module 703 includes:
First query unit is obtained for traversing each leaf node of the query tree from bottom to top with positive sequential mode Positive sequence traversal queries result;
Second query unit, for having the value collection of aleatory variable after the first query unit positive sequence traversal It is top-down in a manner of inverted order since the last one leaf node that positive sequential mode traverses when in conjunction containing element is not used The each leaf node for traversing the query tree obtains inverted order traversal queries result;
Query result obtaining unit, for according to the positive sequence traversal queries result and inverted order traversal queries as a result, obtaining Known variables value set in the leaf node.
The specific query process of above-mentioned first query unit and the second query unit can be found in the implementation of front the method for the present invention Description in example, details are not described herein.
In addition, in practical applications, if above-mentioned first query unit and the second query unit inquired it is any unknown When variable does not have corresponding value, then enquiry module 703 can also determine inquiry failure.In this case, enquiry module 703 Corresponding message or prompt information can be returned to, for example, if it is the inquiry towards other application, enquiry module 703 can be to The application returns to corresponding message;If it is user oriented inquiry, also settable display module in the system, in determination After inquiry failure, enquiry module 703 can show prompt informations such as " inquiry fail " to user by display module.
Ontology information inquiry system provided in an embodiment of the present invention searches inquiry using the method that positive sequence and inverted order combine Known variables value set in each leaf node of tree, query process do not need to save known variables in non-leaf nodes and take Value, known variables value set in traversed leaf node need to only be saved it is primary, while also only to element in value set A search operation is carried out, so as to greatly save query time, search efficiency is improved, reduces the consumption to memory.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for system reality For applying example, since it is substantially similar to the method embodiment, so describing fairly simple, related place is referring to embodiment of the method Part explanation.System embodiment described above is only schematical, wherein described be used as separate part description Unit may or may not be physically separated, component shown as a unit may or may not be Physical unit, it can it is in one place, or may be distributed over multiple network units.It can be according to the actual needs Some or all of the modules therein is selected to achieve the purpose of the solution of this embodiment.Those of ordinary skill in the art are not paying In the case where creative work, it can understand and implement.
The embodiment of the present invention has been described in detail above, and specific embodiment used herein carries out the present invention It illustrates, method and system of the invention that the above embodiments are only used to help understand;Meanwhile for the one of this field As technical staff, according to the thought of the present invention, there will be changes in the specific implementation manner and application range, to sum up institute It states, the contents of this specification are not to be construed as limiting the invention.

Claims (12)

1. a kind of ontology information querying method characterized by comprising
Receive inquiry request;
Query tree is constructed according to the inquiry request;
Each leaf node that the query tree is only traversed in such a way that positive sequence and inverted order combine, obtains the leaf node Middle known variables value set;
Wherein, in ergodic process, the leaf node index that each known variables occur for the first time is saved to avoid repeating to save Known variables.
2. the method according to claim 1, wherein described include: according to inquiry request building query tree
The inquiry request is converted into Ontology Query sentence;
According to the Ontology Query sentence builder query tree, each triple in the Ontology Query sentence corresponds to the inquiry A leaf node in tree records the known variables information in triple on the leaf node.
3. the method according to claim 1, wherein the positive sequence traversal direction be traverse from bottom to top, inverted order Traversal direction is to traverse from top to down;
Each leaf node that the query tree is only traversed in such a way that positive sequence and inverted order combine, obtains the inquiry Known variables value set includes: in the leaf node of tree
The each leaf node for traversing the query tree from bottom to top with positive sequential mode obtains positive sequence traversal queries result;
If after positive sequence traverses, having in the value set of aleatory variable containing element is not used, then being traversed from positive sequential mode The last one leaf node start, each leaf node of the top-down traversal query tree, is fallen in a manner of inverted order Sequence traversal queries result;
According to the positive sequence traversal queries result and inverted order traversal queries as a result, obtaining known variables value in the leaf node Set.
4. according to the method described in claim 3, it is characterized in that, described traverse the query tree with positive sequential mode from bottom to top Each leaf node, obtaining positive sequence traversal queries result includes:
Obtain the leaf node of current positive sequence traversal;
If the leaf node is first leaf node, the corresponding triple of first leaf node is inquired, is obtained The known variables value set into first leaf node;
If the known variables value set is not sky, an element is chosen from the known variables value set and is made For the current value of known variables described in first leaf node, next leaf node is then traversed;
If the leaf node is not first leaf node, the current of non-new known variables in the leaf node is obtained Then value inquires the corresponding triple of the leaf node;
If inquiring the corresponding triple success of the leaf node, known variables value in the leaf node is obtained, or Obtain known variables value and new known variables value set in the leaf node;
If inquiring the leaf node corresponding triple failure, back to non-new known variables in the leaf node the The leaf node that once occurs simultaneously executes inverted order traversing operation to it, and positive sequence traverses next leaf node after the completion of operation;
After the completion of the last one node positive sequence traversal of the query tree, if all known variables all obtain value, positive sequence It traverses successfully, the value of the known variables of acquisition is added in positive sequence traversal queries result.
5. according to the method described in claim 4, it is characterized in that, the traversal query tree top-down in a manner of inverted order Each leaf node, obtaining inverted order traversal queries result includes:
Obtain the leaf node of current inverted order traversal;
If the leaf node is the last one leaf node, the known variables in the last one described leaf node are taken Element is not used in value set to be added in inverted order traversal queries result, then traverses next leaf node;
If the leaf node be not positive sequence traversal the last one leaf node, judge the leaf node whether include New known variables, and comprising element is not used in new known variables value set;
If it is, successively taking a unused element as the new known variables from the new known variables value set Current value, then positive sequence traverses the query tree since next leaf node;If it is not, then inverted order traversal is next Leaf node;
After the completion of first node inverted order traversal of the query tree, the value of the known variables of acquisition is added to inverted order traversal In query result.
6. method according to any one of claims 1 to 5, which is characterized in that the method also includes:
If there is any known variables do not inquire corresponding value, it is determined that inquiry failure.
7. a kind of ontology information inquiry system characterized by comprising
Receiving module, for receiving inquiry request;
Query tree constructs module, for constructing query tree according to the inquiry request;
Enquiry module is obtained for only traversing each leaf node of the query tree in such a way that positive sequence and inverted order combine The known variables value set into the leaf node;Wherein, in ergodic process, each known variables is saved and are occurred for the first time Leaf node index to avoid repeat save known variables.
8. system according to claim 7, which is characterized in that the query tree constructs module and includes:
Sentence converting unit, for the inquiry request to be converted to Ontology Query sentence;
Construction unit, for each ternary according to the Ontology Query sentence builder query tree, in the Ontology Query sentence Group corresponds to a leaf node in the query tree, and the known variables information in triple is recorded on the leaf node.
9. system according to claim 7, which is characterized in that the positive sequence traversal direction is to traverse from bottom to top, inverted order Traversal direction is to traverse from top to down;
The enquiry module includes:
First query unit obtains positive sequence for traversing each leaf node of the query tree from bottom to top with positive sequential mode Traversal queries result;
Second query unit, for having in the value set of aleatory variable after the first query unit positive sequence traversal When containing unused element, since the last one leaf node that positive sequential mode traverses, the top-down traversal in a manner of inverted order Each leaf node of the query tree obtains inverted order traversal queries result;
Query result obtaining unit, for according to the positive sequence traversal queries result and inverted order traversal queries as a result, obtaining described Known variables value set in leaf node.
10. system according to claim 9, which is characterized in that the query process of first query unit is as follows:
Obtain the leaf node of current positive sequence traversal;
If the leaf node is first leaf node, the corresponding triple of first leaf node is inquired, is obtained The known variables value set into first leaf node;
If the known variables value set is not sky, an element is chosen from the known variables value set and is made For the current value of known variables described in first leaf node, next leaf node is then traversed;
If the leaf node is not first leaf node, the current of non-new known variables in the leaf node is obtained Then value inquires the corresponding triple of the leaf node;
If inquiring the corresponding triple success of the leaf node, known variables value in the leaf node is obtained, or Obtain known variables value and new known variables value set in the leaf node;
If inquiring the leaf node corresponding triple failure, back to non-new known variables in the leaf node the The leaf node that once occurs simultaneously executes inverted order traversing operation to it, and positive sequence traverses next leaf node after the completion of operation;
After the completion of the last one node positive sequence traversal of the query tree, if all known variables all obtain value, positive sequence It traverses successfully, the value of the known variables of acquisition is added in positive sequence traversal queries result.
11. system according to claim 10, which is characterized in that the query process of second query unit is as follows:
Obtain the leaf node of current inverted order traversal;
If the leaf node is the last one leaf node, the known variables in the last one described leaf node are taken Element is not used in value set to be added in inverted order traversal queries result, then traverses next leaf node;
If the leaf node be not positive sequence traversal the last one leaf node, judge the leaf node whether include New known variables, and comprising element is not used in new known variables value set;
If it is, successively taking a unused element as the new known variables from the new known variables value set Current value, then positive sequence traverses the query tree since next leaf node;If it is not, then inverted order traversal is next Leaf node;
After the completion of first node inverted order traversal of the query tree, the value of the known variables of acquisition is added to inverted order traversal In query result.
12. according to the described in any item systems of claim 7 to 11, which is characterized in that the enquiry module is also used to traversing After the completion, when there are any known variables not inquire corresponding value, inquiry failure is determined.
CN201510205659.5A 2015-04-27 2015-04-27 Ontology information querying method and system Active CN106156238B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510205659.5A CN106156238B (en) 2015-04-27 2015-04-27 Ontology information querying method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510205659.5A CN106156238B (en) 2015-04-27 2015-04-27 Ontology information querying method and system

Publications (2)

Publication Number Publication Date
CN106156238A CN106156238A (en) 2016-11-23
CN106156238B true CN106156238B (en) 2019-09-03

Family

ID=57347400

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510205659.5A Active CN106156238B (en) 2015-04-27 2015-04-27 Ontology information querying method and system

Country Status (1)

Country Link
CN (1) CN106156238B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109947892B (en) * 2017-12-04 2023-01-06 阿里巴巴集团控股有限公司 Analysis path determination method and system, interface and log tree construction method

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102084363B (en) * 2008-07-03 2014-11-12 加利福尼亚大学董事会 A method for efficiently supporting interactive, fuzzy search on structured data
US8244768B2 (en) * 2009-12-17 2012-08-14 International Business Machines Corporation Implementing service oriented architecture industry model repository using semantic web technologies
CN102270232B (en) * 2011-07-21 2012-09-26 华中科技大学 Semantic data query system with optimized storage
CN102693310B (en) * 2012-05-28 2016-08-03 无锡成电科大科技发展有限公司 A kind of resource description framework querying method based on relational database and system
CN103116625A (en) * 2013-01-31 2013-05-22 重庆大学 Volume radio direction finde (RDF) data distribution type query processing method based on Hadoop
CN103927358B (en) * 2014-04-15 2017-02-15 清华大学 text search method and system

Also Published As

Publication number Publication date
CN106156238A (en) 2016-11-23

Similar Documents

Publication Publication Date Title
CN106155522B (en) Session data processing, knowledge base foundation, optimization, exchange method and device
Pham et al. S3g2: A scalable structure-correlated social graph generator
CN102868695B (en) Conversation tree-based intelligent online customer service method and system
CN107291807B (en) SPARQL query optimization method based on graph traversal
CN107402927A (en) A kind of enterprise's incidence relation topology method for building up and querying method based on graph model
CN107229684A (en) Statement classification method, system, electronic equipment, refrigerator and storage medium
CN106021457B (en) RDF distributed semantic searching method based on keyword
CN104090901B (en) A kind of method that data are processed, device and server
CN104572970B (en) A kind of SPARQL query statements generation system based on ontology library content
CN102571752B (en) Service-associative-index-map-based quality of service (QoS) perception Top-k service combination system
CN110019555B (en) Relation data semantical modeling method
CN112667860A (en) Sub-graph matching method, device, equipment and storage medium
CN102722566A (en) Method for inquiring potential friends in social network
CN111680144A (en) Method and system for multi-turn dialogue voice interaction, storage medium and electronic equipment
CN109948151A (en) The method for constructing voice assistant
Baglatzi et al. Semantifying OpenStreetMap.
CN108681603A (en) The method of fast search tree structure data, storage medium in database
CN101222391A (en) Method for constructing topological tree in server/client terminal structure
CN106156238B (en) Ontology information querying method and system
CN104346350B (en) The tree node querying method and system of Asynchronous Tree
CN111352961A (en) Distributed RDF stream data processing method, system, device and medium
Fengjuan et al. The research on complex event processing method of internet of Things
CN106933844A (en) Towards the construction method of the accessibility search index of extensive RDF data
CN109558427A (en) Intelligent inquiry system and method based on steel industry data platform
Gupta et al. Search bot: Search intention based filtering using decision tree based technique

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant