Summary of the invention
In view of the above problem of the existing technology, the present invention proposes that a kind of three-valued logic question and answer seek advice from optimization method, are
System, medium and equipment mainly solve the problems, such as that logical description improves natural language processing efficiency and precision.
To achieve the goals above and other purposes, the technical solution adopted by the present invention are as follows.
A kind of three-valued logic question and answer consulting optimization method method, comprising:
Semantic analysis and logic analysis are carried out respectively for the knowledge base obtained in advance, obtain semantic node and logic respectively
Node;
The three-valued logic operation values of the logical node and semantic node are calculated according to the inquiry text obtained in advance, are counted
Semantic node jumps probability;
Probability is jumped and the three-valued logic operation values calculate the probability that each node obtains definite answer according to described;
Optimal consultation and advices node is obtained according to the probability that each node obtains definite answer.
Optionally, the semantic analysis includes:
Extract the semantic feature of text in the knowledge base;
According to the semantic feature constructing semantic node, and based on context, relationship establishes the semanteme between the semantic node
Connection.
Optionally, the logic analysis includes:
Extract the logical implication of text in the knowledge base;
According to the logical implication constitutive logic node;
According to the logical relation between the logical implication, the logical connection between the logical node is established;
Based on context the semantic connection relationship for establishing the logical node Yu the semantic node.
Optionally, the inquiry text that the basis obtains in advance calculates the three-valued logic of the logical node and semantic node
Operation values specifically include:
Extract the key feature of the inquiry text;
The key feature is compared with the semantic node and the logical node respectively, according to preset three value
Logic rules judge the semantic node and the corresponding logical value of the logical node respectively;
The logic is calculated in conjunction with the connection relationship between logical node according to the logic true value of the logical node
Logical operation value between node.
Optionally, the preset three-valued logic rule, specifically includes:
The semantic node and the logical node are classified together, classification type includes semantic type node, number
Value Types node, Boolean type node and character string type node;
When there is feature associated with the semantic type node in the key feature, if the semantic type section
The semanteme of point is higher than the similarity threshold of setting with the similarity of the character pair in the key feature, then the semantic type
The logical value of node be it is true, otherwise the logical value of the semantic type node is false, when being not present in the key feature and institute
When the associated feature of predicate justice type node, the logical value of the semantic type node is unknown;
When the semantic type node connecting with the value type node is true, if in the key feature exist with
The corresponding numerical value of the value type node, then the logical value of the value type node is true, otherwise the value type section
The logical value of point is unknown;
When the semantic category node connecting with the Boolean type node is true, if existed and institute in the key feature
The corresponding verifying feature of Boolean type node is stated, then the logical value of the Boolean type node is true, otherwise the Boolean type
The logical value of node is vacation, when verifying content corresponding with the Boolean type node is not present in the key feature, then
The logical value of the Boolean type node is unknown;
When the semantic type node connecting with the character string type node is true, if existed in the key feature
Character string corresponding with the character string type node, then the logical value of the character string type node is true, otherwise the word
It is unknown for according with the logical value of string type node.
Optionally, the logic probability that obtains includes calculating the logic probability that the logical value is unknown node, is calculated
Formula are as follows:
Wherein, R (k) indicates the logical value of node k, and LPr (i) indicates all logical nodes connecting with node i
Set, Pr (i) indicate the set for all semantic nodes connecting with node i, LkiIndicate the logical operation value of node k and node i,
SkiIt indicates to jump probability between node k and i.
Optionally, the probability for calculating each node and obtaining definite answer, is embodied as:
Wherein, c1And c2For weight, c1+c2=1, LC (i) indicates logic section described in all next stage connecting with node i
The set of point;C (i) indicates the set for all next stage nodes connecting with node i;LijIndicate that node i is transported to the logic of node j
Calculation value;SijIndicate that node i jumps probability to what node j was jumped.
A kind of three-valued logic question and answer consulting optimization system, comprising:
Node creation module, for carrying out semantic analysis and logic analysis respectively for the knowledge base obtained in advance, respectively
Obtain semantic node and logical node;
Logic calculation module, for calculating the three of the logical node and semantic node according to the inquiry text obtained in advance
It is worth logical operation value;
Probability evaluation entity, statistical semantic node jump probability;Probability and three-valued logic fortune are jumped according to described
Calculation value calculates the probability that each node obtains definite answer;
Optimizing module, the probability for obtaining definite answer according to each node obtain optimal consultation and advices node.
A kind of computer readable storage medium, wherein being stored with computer program, the computer program is added by processor
When carrying execution, the logic optimization method is realized.
A kind of equipment, including processor and memory;Wherein,
The memory is for storing computer program;
The processor is for loading and executing the computer program, so that the equipment executes the logic optimizing
Method.
As described above, a kind of three-valued logic question and answer consulting optimization method of the present invention, system, medium and equipment, have following
Beneficial effect.
By calculating logic probability and probability is jumped, logical node and semantic node are combined, improves natural language processing
Accuracy;Increase logical operation, optimizing result more rapid convergence can be made, improves Searching efficiency.
Specific embodiment
Illustrate embodiments of the present invention below by way of specific specific example, those skilled in the art can be by this specification
Other advantages and efficacy of the present invention can be easily understood for disclosed content.The present invention can also pass through in addition different specific realities
The mode of applying is embodied or practiced, the various details in this specification can also based on different viewpoints and application, without departing from
Various modifications or alterations are carried out under spirit of the invention.It should be noted that in the absence of conflict, following embodiment and implementation
Feature in example can be combined with each other.
It should be noted that illustrating the basic structure that only the invention is illustrated in a schematic way provided in following embodiment
Think, only shown in schema then with related component in the present invention rather than component count, shape and size when according to actual implementation
Draw, when actual implementation kenel, quantity and the ratio of each component can arbitrarily change for one kind, and its assembly layout kenel
It is likely more complexity.
Referring to Fig. 1, this programme provides a kind of three-valued logic question and answer consulting optimization method, including step S01-S04.
In step S01, semantic analysis and logic analysis are carried out respectively for the knowledge base obtained in advance, obtains language respectively
Adopted node and logical node:
In one embodiment, knowledge base can collect corresponding field the relevant technologies document, arrange according to different technical fields
Obtain knowledge base.By taking legal field as an example, by compiling legal regulation, law works forum, relevant law paper periodical and miscellaneous
The information such as will in entering computer database, form knowledge base.
It carries out semantic analysis and when logic analysis, text in knowledge base can be segmented, subordinate sentence and segment processing, it will be literary
Originally relatively independent word, sentence and paragraph are divided into.Then to treated Text Feature Extraction semantic feature and logical implication.
Here semantic feature is primarily referred to as word, numerical value or character string etc. comprising certain semantic, and logical implication is primarily referred to as semanteme
Logical constraint relationship in feature, including logical relation, condition judge relationship, arithmetic operator relationship, in this way whether, to mistake
Deng.
In one embodiment, semantic feature is converted into term vector input identification model training question and answer network, it will be semantic special
Semantic node as question and answer network is levied, corresponds to the context semantic relation of text in conjunction with semantic feature, between building semantic node
Semantic connection.Simultaneously using logical implication as the logical node of question and answer network, logical node is established with corresponding semantic node
Logical connection, and the logical relation between logical implication is combined, establish the logical connection between logical node.Pass through logical node and language
Adopted node constructs complete question and answer network.
In step S02, transported according to the three-valued logic of the inquiry text calculating logic node and semantic node that obtain in advance
Calculation value, statistical semantic node jump probability:
In one embodiment, inquiry text refers to that user is directed to the inquiry text that particular problem proposes, can be voice text
Sheet or the writing text directly inputted.Inquiry text is segmented, after subordinate sentence and segment processing, the key of inquiry text is extracted
Feature, key feature include semanteme, semantic context relationship, logical relation etc..By semantic information corresponding in key feature with
The semantic node of question and answer network compares in step S01, by calculating in the corresponding term vector of semantic information and question and answer network
The similarity of the corresponding term vector of semantic node.The similarity of term vector can be obtained by calculating the normal form distance of term vector.When
When similarity reaches given threshold, then determine that corresponding semantic information is corresponding with semantic node in question and answer network in key feature
Semantic information is similar, and the similar semantic node to be calculated is as the access node of question and answer network.Similarly, it calculates crucial
The similarity of corresponding logical message and logical node in feature.Using access point as basic point, according to the key feature of inquiry text
With the similarity of question and answer network corresponding node, carries out semantic node and jump.When the semantic node or logical node being connect with basic point
When reaching given threshold with inquiry text character pair similarity, basic point is jumped to corresponding semantic node or logical node, system
The number of hops of basic point is counted, the ratio of the number from basic point to a certain node connected to it and the total number of hops of basic point that jump with
Probability is jumped with respect to basic point for the node.For example, A node has jumped once to B node, and A node with A node to connecting
The number of hops of other nodes is N, then the probability that jumps of B node is 1/N.In this approach, other sections other than basic point can be calculated
Point jumps probability.
For the ease of carrying out quantum chemical method to the node in question and answer network, all nodes in question and answer network are divided into semanteme
Type node, four class of value type node, Boolean type node and character string type node.And three-valued logic is defined for quantifying
The logical value of each node.
In one embodiment, definable three-valued logic is respectively true T, vacation F and unknown U.Very being indicated with 1, vacation is indicated with 0,
The unknown numerical value between 0 to 1 indicates.
Define may be expressed as: with operation for three-valued logic
C=A*B
Wherein, it is genuine possibility that A and B, which respectively represents different nodes,.
Table 1
Table 1 is the truth table that A node and B node carry out logic and operation.
Define three-valued logic or operation may be expressed as:
C=min { 1, A+B }
Table 2
Table 2 is the truth table that A node and B node carry out logic or operation.
The inverse for defining three-valued logic may be expressed as:
C=1-A
Table 3
Table 3 is the truth table that A node carries out logical not operation.
The operation rule of three-valued logic is defined according to the node type of question and answer network based on the above logical operation, is wrapped
It includes:
For semantic type node, when existing in the key feature of inquiry text and the associated feature of semantic type node
When, if the semanteme of semantic type node is higher than the similarity threshold of setting with the similarity of the character pair in key feature,
Then the logical value of semantic type node is true, and otherwise the logical value of semantic type node is false, when in key feature there is no with
When the associated feature of semantic type node, the logical value of semantic type node is unknown;
For value type node, when the semantic type node connecting with value type node is true, if crucial special
There is numerical value corresponding with value type node in sign, then the logical value of value type node is true, otherwise value type node
Logical value be it is unknown;
For Boolean type node, when the semantic category node connecting with Boolean type node is true, if the key
There is verifying feature corresponding with Boolean type node in feature, then the logical value of Boolean type node is true, otherwise Boolean Class
The logical value of type node be it is false, when verifying content corresponding with Boolean type node is not present in the key feature, then cloth
The logical value of your type node is unknown;
For character string type node, when the semantic type node connecting with character string type node is true, if institute
It states and there is character string corresponding with character string type node in key feature, then the logical value of the character string type node is
Very, otherwise the logical value of the character string type node is unknown.
In one embodiment, also the comparison operation under three-valued logic can be defined for value type, including be greater than, be less than,
It is more than or equal to, be less than or equal to and is equal to.Pass through the final result of the comparison function decision logic operation of construction.Comparison function can
It is configured according to actual context or application scenarios, when the logical value of two value type nodes is simultaneously true, with comparison function
Calculated result as logical operation value, in the case of other, can one of node logical value as comparison operation
Value.
It also can define the arithmetical operation of three-valued logic, including add, subtract, the operations such as multiplication and division, when patrolling for two value type nodes
When volume value is simultaneously true, the result of arithmetic operator be it is true, in the case of other, can one of node logical value as calculation
The value of number operation.
By the logical operation mode of definition and logical operation rule, patrolling between each node of question and answer network can be calculated
Collect operation values.
In one embodiment, statistical semantic node jumps probability, can also pass through and read semantic node and its child node
History jump record, count number of hops, probability jumped by Bayesian probability calculation method constructing semantic node, with certain
One node is father node, and the node connecting with the node is child node, the number that statistics father node is jumped to child node, and then structure
It makes and jumps probability.
In step S03, according to jumping probability and three-valued logic operation values calculate each node and obtain the general of definite answer
Rate:
According to the logical operation mode and rule in step S02, can calculate all for constructing the logic of question and answer network
And arithmetic is genuine possibility.During calculating logic operation values, since the unknown U of logical value is between 0 to 1
Therefore number, can be unknown node by determining node true value constitutive logic value for indicating the uncertainty of node true value
Value.Its calculation formula may be expressed as:
Wherein, R (k) indicates the logical value of node k, and LPr (i) indicates all logical nodes connecting with node i
Set, Pr (i) indicate the set for all semantic nodes connecting with node i, LkiIndicate the logical operation value of node k and node i,
SkiIt indicates to jump probability between node k and i.
In one embodiment, according to the logical operation value being calculated, each section in question and answer network can be further calculated out
Point can finally obtain the probability of definite answer, as P (xi).It may be expressed as:
Wherein, c1And c2For weight, c1+c2=1, LC (i) indicates logic section described in all next stage connecting with node i
The set of point;C (i) indicates the set for all next stage nodes connecting with node i;LijIndicate that node i is transported to the logic of node j
Calculation value;SijIndicate that node i jumps probability to what node j was jumped.
In step S04, optimal consultation and advices node is obtained according to the probability that each node obtains definite answer:
It is unknown node according to the logical value being calculated in step S03, available one using unknown node as side
The set on boundary, it is genuine semantic type node that all nodes, which are logical value, in set, and it is unknown that contour connection, which has logical value,
Node.
According to the probability value of the step S03 node being calculated, the highest node of probability value is selected from set as most
Excellent consultation and advices node.Its calculating process may be expressed as:
Wherein, KE indicates that logical value is the set of genuine semantic type node.
According to an embodiment of the invention, additionally providing a kind of computer storage medium, computer is stored in storage medium
Logic optimization method above-mentioned may be implemented when executing in program, the computer program.Computer storage medium may include calculating
The data storage such as any usable medium of machine storage or the server, the data center that are integrated comprising one or more usable mediums
Equipment.Usable medium include magnetic medium (such as: floppy disk, hard disk, tape), optical medium (such as: DVD), semiconductor medium (such as: Gu
State hard disk) etc..
Referring to Fig. 2, the present embodiment provides a kind of three-valued logic question and answer to seek advice from optimization system, for executing preceding method reality
Apply logic optimization method described in example.Due to the technical principle phase of the technical principle and preceding method embodiment of system embodiment
Seemingly, thus no longer repeatability is done to same technical detail to repeat.
In one embodiment, three-valued logic question and answer consulting optimization system includes node creation module 10, logic calculation module
11, probability evaluation entity 12 and optimizing module 13;Node creation module 10 executes preceding method embodiment Jie for assisting
The step S01 to continue, logic calculation module 11 are used to execute the step S02 of preceding method embodiment introduction, probability evaluation entity 12
For executing the step S03 in preceding method embodiment, optimizing module 13 is used to execute the step in preceding method embodiment
S04。
Referring to Fig. 3, equipment can be desktop computer, portable computer etc. the present embodiment provides a kind of equipment, specifically,
Equipment includes at least processor 20 and memory 21.
Processor 20 is used to execute all or part of the steps in preceding method embodiment.Processor 20 can be general place
Manage device, including central processing unit (Central Processing Unit, abbreviation CPU), network processing unit (Network
Processor, abbreviation NP) etc.;It can also be digital signal processor (Digital Signal Processing, abbreviation
DSP), specific integrated circuit (Application Specific Integrated Circuit, abbreviation ASIC), scene can compile
It is journey gate array (Field-Programmable Gate Array, abbreviation FPGA) or other programmable logic device, discrete
Door or transistor logic, discrete hardware components.
In conclusion a kind of three-valued logic question and answer consulting optimization method of the present invention, system, medium and equipment, pass through three values
The semantic information and logical relation of logical description node can expand semantic expression;Search Range is determined by unknown node, it can
Natural language processing convergence is improved, is improved efficiency, reasoning from logic is combined with semantic analysis, can ensure the complete of knowledge
Whole degree.So the present invention effectively overcomes various shortcoming in the prior art and has high industrial utilization value.
The above-described embodiments merely illustrate the principles and effects of the present invention, and is not intended to limit the present invention.It is any ripe
The personage for knowing this technology all without departing from the spirit and scope of the present invention, carries out modifications and changes to above-described embodiment.Cause
This, institute is complete without departing from the spirit and technical ideas disclosed in the present invention by those of ordinary skill in the art such as
At all equivalent modifications or change, should be covered by the claims of the present invention.