Intelligent answer method and system
Technical field
The present invention relates to electric Digital data processing and field of artificial intelligence, more particularly to a kind of intelligent answer method and
System.
Background technology
In Intelligent dialogue system, the method matched usually using problem and problem finds answer.Preserved in knowledge base
Problem and corresponding answer, as one problem A of user's query, the problem of finding similar to problem A from knowledge base B, then
Problem B answer is returned into user.Generally compare the similarity for calculating two problems by keyword, i.e., based on problem A and
Problem B keyword calculates its similarity.In order to improve recall rate, do not require that keyword is matched completely generally, however, this side
Method this may introduce mistake.Because the keyword extracted in two problems may have in very high similarity, but two problems
Comprising semanteme it is different, what problem A may be expressed is the semanteme of affirmative, and problem B expression be probably negative semanteme, because
This, if ignoring the semanteme included in problem, it is likely that to the answer gone wrong be inaccurate.For example, problem A:I likes
You, problem B:I does not like you, and wherein problem A keyword is that " I " " likes " " you ", and problem B keyword is " I " " no "
" liking " " you ", because problem A and problem B have three keywords identical, therefore problem B may enter candidate collection, still
It is semantic different, and one represents affirmative, and one represents negative, it is therefore more likely that inaccurate to the answer gone wrong.
Therefore, defect of the prior art is, in Intelligent dialogue system, it is impossible to semantic according to the difference included in problem
Analyzed, cause the answer provided inaccurate.
The content of the invention
For above-mentioned technical problem, the present invention provides a kind of intelligent Answering method and system, is calculated and used by semantic model
Semantic information in family proposition problem, according in knowledge base preserve the problem of and its semantic information, in knowledge base remove with use
The problem of family is proposed it is semantic inconsistent the problem of, and then match and propose the problem of problem is similar to user, and provide accurate
Answer.
In order to solve the above technical problems, the technical scheme that the present invention is provided is:
In a first aspect, the present invention provides a kind of intelligent Answering method, including:
Step S1, obtains storage problem and correspondence in knowledge base, the knowledge base and answers, according to the semantic mould pre-established
Type calculates the affirmative semantic information and negative semantic information of described problem, is stored in the knowledge base;
Step S2, obtains customer problem, calculates the keyword of the customer problem;
Step S3, calculates the similarity of the keyword and the keyword of problem in the knowledge base of the customer problem,
The similarity is obtained in the knowledge base and is the first problem set of predetermined threshold value, and obtains in the knowledge base described the
The corresponding semantic information certainly of problem and negative semantic information in one problem set;
Step S4, according to the customer problem, the corresponding affirmative of the customer problem is calculated by the semantic model
Adopted information and negative semantic information;
Step S5, by the corresponding semantic information certainly of the customer problem and negative semantic information and the first problem collection
The corresponding semantic information certainly of problem and negative semantic information are compared in conjunction, will affirmative corresponding with the customer problem
The problem of adopted information and inconsistent negative semantic information, removes, and obtains Second Problem set;
Step S6, according to the Second Problem set, obtains a problem as matching problem, the matching problem at random
The corresponding answer answered as the customer problem.
The technical scheme of intelligent Answering method of the present invention is:Knowledge base is obtained, storage problem and right in the knowledge base
It should answer, the affirmative semantic information and negative semantic information of described problem are calculated according to the semantic model pre-established, institute is stored in
State knowledge base;Customer problem is obtained, the keyword of the customer problem is calculated;Calculate the keyword of the customer problem with it is described
The similarity of the keyword of problem in knowledge base, obtains the first problem that the similarity is predetermined threshold value in the knowledge base
Gather, and the corresponding semantic information certainly of problem in the first problem set is obtained in the knowledge base and believe with negative semanteme
Breath;
According to the customer problem, by the semantic model calculate the corresponding semantic information certainly of the customer problem and
It negate semantic information;By the corresponding semantic information certainly of the customer problem and negative semantic information and the first problem set
The corresponding semantic information certainly of middle problem and negative semantic information are compared, will be corresponding with the customer problem certainly semantic
The problem of information and inconsistent negative semantic information, removes, and obtains Second Problem set;According to the Second Problem set, at random
A problem is obtained as matching problem, the corresponding answer answered as the customer problem of the matching problem.
The intelligent answer method of the present invention, calculates the semantic information in user's proposition problem, according to knowing by semantic model
Know the problem of being preserved in storehouse and its semantic information, the crucial Word similarity first in problem obtains first problem set, so
Afterwards in knowledge base remove with user propose the problem of it is semantic inconsistent the problem of, obtain Second Problem set, asked second
The problem of matching similar in topic set, and provide accurate answer.
Further, the foundation of the semantic model, be specially:
Training corpus is obtained, the training corpus includes affirmative mark and negative tag in sentence, sentence;
The training corpus is trained by maximum entropy model, semantic model is obtained.
Further, the training corpus is trained by maximum entropy model, obtains semantic model, be specially:
The feature in training corpus is obtained, it is described to be characterized as from the affirmative mark in the sentence, the sentence and negate
The characteristic sequence obtained in mark;
The characteristic sequence is trained, semantic model is obtained.
Further, the feature includes the negative word number in unitary feature, binary feature and the sentence, described one
Member is characterized as the characteristic sequence of each character formation in the sentence, and the binary feature is former and later two characters in the sentence
The characteristic sequence of formation.
Second aspect, the present invention provides a kind of intelligent Answer System, including:
Knowledge base acquisition module, is answered for obtaining storage problem and correspondence in knowledge base, the knowledge base, according to advance
The semantic model of foundation calculates the affirmative semantic information and negative semantic information of described problem, is stored in the knowledge base;
Keyword acquisition module, obtains customer problem, calculates the keyword of the customer problem;
First problem collection modules, keyword and the key of problem in the knowledge base for calculating the customer problem
The similarity of word, obtains the first problem set that the similarity is predetermined threshold value in the knowledge base, and in the knowledge
The corresponding semantic information certainly of problem in the first problem set and negative semantic information are obtained in storehouse;
Semantic model computing module, for according to the customer problem, calculating the user by the semantic model and asking
The corresponding semantic information certainly of topic and negative semantic information;
Second Problem collection modules, for by the customer problem it is corresponding certainly semantic information and negative semantic information and
The corresponding semantic information certainly of problem and negative semantic information are compared in the first problem set, will be asked with the user
The problem of corresponding semantic information certainly of topic and inconsistent negative semantic information, removes, and obtains Second Problem set;
Acquisition module is answered, matching problem, institute are used as according to the Second Problem set, obtaining a problem at random
State the corresponding answer answered as the customer problem of matching problem.
The technical scheme of intelligent Answer System of the present invention is:Knowledge base acquisition module is first passed through, for obtaining knowledge base,
Storage problem and correspondence are answered in the knowledge base, are believed according to the affirmative semanteme that the semantic model pre-established calculates described problem
Breath and negative semantic information, are stored in the knowledge base;Then by keyword acquisition module, customer problem is obtained, calculates described
The keyword of customer problem;Then by first problem collection modules, for calculate the keyword of the customer problem with it is described
The similarity of the keyword of problem in knowledge base, obtains the first problem that the similarity is predetermined threshold value in the knowledge base
Gather, and the corresponding semantic information certainly of problem in the first problem set is obtained in the knowledge base and believe with negative semanteme
Breath;
Then by semantic model computing module, for according to the customer problem, institute to be calculated by the semantic model
State the corresponding semantic information certainly of customer problem and negative semantic information;Then by Second Problem collection modules, for by institute
State the corresponding semantic information certainly of customer problem and negative semantic information affirmative corresponding with problem in the first problem set
Semantic information and negative semantic information are compared, will the semantic letter of semantic information certainly and negative corresponding with the customer problem
The problem of ceasing inconsistent removes, and obtains Second Problem set;Finally by acquisition module is answered, for according to the Second Problem
Set, obtains a problem as matching problem at random, the corresponding answer answered as the customer problem of the matching problem.
The intelligent Answer System of the present invention, calculates the semantic information in user's proposition problem, according to knowing by semantic model
Know the problem of being preserved in storehouse and its semantic information, the crucial Word similarity first in problem obtains first problem set, so
Afterwards in knowledge base remove with user propose the problem of it is semantic inconsistent the problem of, obtain Second Problem set, asked second
The problem of matching similar in topic set, and provide accurate answer.
Further, in addition to semantic model sets up module, it is used for:
Training corpus is obtained, the training corpus includes affirmative mark and negative tag in sentence, sentence;
The training corpus is trained by maximum entropy model, semantic model is obtained.
Further, the semantic model sets up module, specifically for:
The feature in training corpus is obtained, it is described to be characterized as from the affirmative mark in the sentence, the sentence and negate
The characteristic sequence obtained in mark;
The feature is trained, semantic model is obtained.
Further, the feature includes the negative word number in unitary feature, binary feature and the sentence, described one
Member is characterized as the characteristic sequence of each character formation in the sentence, and the binary feature is former and later two characters in the sentence
The characteristic sequence of formation.
Brief description of the drawings
, below will be to specific in order to illustrate more clearly of the specific embodiment of the invention or technical scheme of the prior art
The accompanying drawing used required in embodiment or description of the prior art is briefly described.
Fig. 1 shows a kind of flow chart for intelligent answer method that the embodiment of the present invention is provided;
Fig. 2 shows a kind of schematic diagram for intelligent Answer System that the embodiment of the present invention is provided.
Embodiment
The embodiment of technical solution of the present invention is described in detail below in conjunction with accompanying drawing.Following examples are only used for
Clearly illustrate technical scheme, therefore be intended only as example, and the protection of the present invention can not be limited with this
Scope.
Embodiment one
Fig. 1 shows a kind of flow chart for intelligent answer method that the embodiment of the present invention is provided;Embodiment as shown in Figure 1
A kind of one intelligent answer method provided, including:
Step S1, obtains storage problem and correspondence in knowledge base, knowledge base and answers, according to the semantic model meter pre-established
The affirmative semantic information and negative semantic information of calculation problem, are stored in knowledge base;
Step S2, obtains customer problem, calculates the keyword of customer problem;
Calculating the keyword of customer problem has two methods, and a kind of method is:
According to customer problem, participle and part-of-speech tagging are carried out to customer problem, obtain specifying word;
It regard specified word as keyword.
Wherein, word is specified to include verb, noun and personal pronoun;
Another method is:
According to customer problem, word segmentation result, part of speech and the interdependent syntax in customer problem are obtained;
According to word segmentation result, part of speech and interdependent syntax, analyzed, obtain analysis result;
According to analysis result, extract feature and train maximum entropy model, keyword is marked by maximum entropy model.
Step S3, calculates the similarity of the keyword of problem in the keyword and knowledge base of customer problem, in knowledge base
Obtain similarity and be the first problem set of predetermined threshold value, and obtain in knowledge base that problem in first problem set is corresponding to agree
Determine semantic information and negative semantic information;
Step S4, according to customer problem, customer problem corresponding semantic information and negative certainly are calculated by semantic model
Semantic information;
Step S5, by the corresponding semantic information certainly of customer problem and negative semantic information and problem in first problem set
Corresponding semantic information certainly and negative semantic information are compared, will corresponding with customer problem semantic information and negative certainly
The problem of semantic information is inconsistent removes, and obtains Second Problem set;
Step S6, according to Second Problem set, obtains a problem as matching problem, corresponding time of matching problem at random
Answer the answer for customer problem.
The technical scheme of intelligent Answering method of the present invention is:Knowledge base is obtained, storage problem and is corresponded to back in knowledge base
Answer, according to the affirmative semantic information of the semantic model computational problem pre-established and negative semantic information, be stored in knowledge base;Obtain
Customer problem, calculates the keyword of customer problem;Calculate the phase of the keyword and the keyword of problem in knowledge base of customer problem
Like spending, similarity is obtained in knowledge base and is the first problem set of predetermined threshold value, and obtains in knowledge base first problem collection
The corresponding semantic information certainly of problem and negative semantic information in conjunction;
According to customer problem, the corresponding semantic information certainly of customer problem and the semantic letter of negative are calculated by semantic model
Breath;By the corresponding semantic information certainly of customer problem and negative semantic information affirmative corresponding with problem in first problem set
Adopted information and negative semantic information are compared, and corresponding with customer problem semantic information certainly and negative semantic information are differed
The problem of cause, removes, and obtains Second Problem set;According to Second Problem set, a problem is obtained at random as matching problem,
The corresponding answer answered as customer problem of matching problem.
The intelligent answer method of the present invention, calculates the semantic information in user's proposition problem, according to knowing by semantic model
Know the problem of being preserved in storehouse and its semantic information, the crucial Word similarity first in problem obtains first problem set, so
Afterwards in knowledge base remove with user propose the problem of it is semantic inconsistent the problem of, obtain Second Problem set, asked second
The problem of matching similar in topic set, and provide accurate answer.
It should be noted that the problem of storing a large amount of in knowledge base, and the corresponding answer of problem, the problem of only storing foot
It is more than enough, it just may provide the user with and more accurately answer.
Specifically, the foundation of semantic model, be specially:
Training corpus is obtained, training corpus includes affirmative mark and negative tag in sentence, sentence;
Training corpus is trained by maximum entropy model, semantic model is obtained.
Specifically, training corpus is trained by maximum entropy model, obtains semantic model, be specially:
The feature in training corpus is obtained, is characterized as what is obtained from the affirmative mark and negative tag in sentence, sentence
Characteristic sequence;
Characteristic sequence is trained, semantic model is obtained.
The feature for representing semantic in training corpus is subjected to extraction training, semantic model, the advantage of maximum entropy model is obtained
For:During modeling, experimenter need to only concentrate one's energy to select feature, consider how to use these features without requiring efforts;It is special
Levy selection flexibly, and do not need extra independence assumption or inherent constraint;Model applies the portability in different field
By force;More rich information can be combined.Therefore training corpus is trained from maximum entropy model in the present invention, obtains semantic mould
Type.
Specifically, feature includes the negative word number in unitary feature, binary feature and sentence, and unitary is characterized as in sentence
The characteristic sequence of each character formation, binary feature is the characteristic sequence of former and later two characters formation in sentence.
Specifically, predetermined threshold value is 60%.Empirical tests, when predetermined threshold value is 60%, i.e., when similarity is 60%, are knowing
The problem of the problem of knowing in the first problem set obtained in storehouse is proposed to user is similar.
Fig. 2 shows a kind of schematic diagram for intelligent Answer System that the embodiment of the present invention is provided, as shown in Fig. 2 this hair
Bright embodiment provides a kind of intelligent Answer System 10, including:
Knowledge base acquisition module 101, is answered for obtaining storage problem and correspondence in knowledge base, knowledge base, according to advance
The affirmative semantic information and negative semantic information of the semantic model computational problem of foundation, are stored in knowledge base;
Keyword acquisition module 102, obtains customer problem, calculates the keyword of customer problem;
Calculating the keyword of customer problem has two methods, and a kind of method is:
According to customer problem, participle and part-of-speech tagging are carried out to customer problem, obtain specifying word;
It regard specified word as keyword.
Wherein, word is specified to include verb, noun and personal pronoun;
Another method is:
According to customer problem, word segmentation result, part of speech and the interdependent syntax in customer problem are obtained;
According to word segmentation result, part of speech and interdependent syntax, analyzed, obtain analysis result;
According to analysis result, extract feature and train maximum entropy model, keyword is marked by maximum entropy model.
The keyword of problem in first problem collection modules 103, the keyword and knowledge base for calculating customer problem
Similarity, similarity is obtained in knowledge base and is the first problem set of predetermined threshold value, and obtains in knowledge base first problem
The corresponding semantic information certainly of problem and negative semantic information in set;
Semantic model computing module 104, for according to customer problem, being calculated by semantic model, customer problem is corresponding to agree
Determine semantic information and negative semantic information;
Second Problem collection modules 105, for by customer problem it is corresponding certainly semantic information and negative semantic information and
The corresponding semantic information certainly of problem and negative semantic information are compared in first problem set, will be corresponding with customer problem
The problem of affirmative semantic information and inconsistent negative semantic information, removes, and obtains Second Problem set;
Acquisition module 106 is answered, for according to Second Problem set, obtaining a problem at random as matching problem,
With the corresponding answer answered as customer problem of problem.
The technical scheme of intelligent Answer System 10 of the present invention is:Knowledge base acquisition module 101 is first passed through, is known for obtaining
Know storage problem and correspondence in storehouse, knowledge base to answer, according to the affirmative semantic information of the semantic model computational problem pre-established
With negative semantic information, knowledge base is stored in;Then by keyword acquisition module 102, customer problem is obtained, customer problem is calculated
Keyword;Then by first problem collection modules 103, problem in the keyword and knowledge base for calculating customer problem
The similarity of keyword, similarity is obtained in knowledge base and is the first problem set of predetermined threshold value, and is obtained in knowledge base
The corresponding semantic information certainly of problem and negative semantic information in first problem set;
Then by semantic model computing module 104, for according to customer problem, customer problem to be calculated by semantic model
Corresponding semantic information certainly and negative semantic information;Then by Second Problem collection modules 105, for by customer problem pair
Affirmative semantic information and negative semantic information corresponding with problem in first problem set semantic information and the negative certainly answered
Adopted information is compared, and will be removed the problem of corresponding with customer problem semantic information certainly and inconsistent negative semantic information,
Obtain Second Problem set;Finally by acquisition module 106 is answered, for according to Second Problem set, random acquirement one to be asked
Topic is as matching problem, the corresponding answer answered as customer problem of matching problem.
The intelligent Answer System 10 of the present invention, the semantic information in user's proposition problem is calculated by semantic model, according to
The problem of being preserved in knowledge base and its semantic information, the crucial Word similarity first in problem obtain first problem set,
Then in knowledge base remove with user propose the problem of it is semantic inconsistent the problem of, Second Problem set is obtained, second
The problem of matching similar in problem set, and provide accurate answer.
Specifically, in addition to semantic model sets up module, it is used for:
Training corpus is obtained, training corpus includes affirmative mark and negative tag in sentence, sentence;
Training corpus is trained by maximum entropy model, semantic model is obtained.
Specifically, semantic model sets up module, specifically for:
The feature in training corpus is obtained, is characterized as what is obtained from the affirmative mark and negative tag in sentence, sentence
Characteristic sequence;
Feature is trained, semantic model is obtained.
It will represent that semantic feature carries out extraction training in training corpus by maximum entropy model, obtain semantic model, most
The advantage of big entropy model is:During modeling, experimenter need to only concentrate one's energy to select feature, consider how to make without requiring efforts
Use these features;Feature selecting flexibly, and does not need extra independence assumption or inherent constraint;Model is applied in different field
When portability it is strong;More rich information can be combined.Therefore training corpus is instructed from maximum entropy model in the present invention
Practice, obtain semantic model.
Specifically, feature includes the negative word number in unitary feature, binary feature and sentence, and unitary is characterized as in sentence
The characteristic sequence of each character formation, binary feature is the characteristic sequence of former and later two characters formation in sentence.
Embodiment two
Based on the intelligent answer method and intelligent Answer System 10 in embodiment one, intelligent answer process is carried out specifically
It is bright:
1st, problem (question) and answer (answer) are added into knowledge base,
For example:
2nd, it is indexed by keyword, meanwhile, question affirmative semantic information is calculated and no according to semantic model M
Determine in semantic information, deposit knowledge base;
Above question keyword and affirmative negative semantic information is as follows:
3rd, the problem of being provided according to user question A " I likes you ", calculate its keyword for " I likes you ";
4th, according to keyword, the question set CQS1 that similarity is top n (predetermined threshold value) is obtained from knowledge base
(first problem set).Calculate obtain question in question A and knowledge base similarity (according to same keyword number/
Total keyword number is calculated) it is as follows:
5th, according to keyword, similar question set CQS1 (similarity is more than 60%) is obtained from knowledge base, and
The corresponding negative semantic informations certainly of these question are obtained from knowledge base simultaneously;CQS1 set, similarity are (according to identical
Keyword number/total keyword number is calculated), certainly negative semantic information it is as follows:
Similar question similarities negate semantic certainly
I likes your 100% affirmative
I does not like your 75% negative
6th, the problem of being provided according to user question A " I likes you ", it is affirmative to calculate it according to semantic model M;
7th, using question A affirmative information and negative semantic information, information certainly is filtered from set CQS1 and no
Determine the inconsistent question of semantic information, obtain set CQS2 (Second Problem set);CQS2 set is as follows:
Similar question negates semantic certainly
I likes you to affirm
8th, for each problem in set CQS2, its corresponding answer is returned into user, therefore user obtains
Answer is " I also likes you ".
Intelligent Answering is carried out by the intelligent answer method and system of the present invention, can and negative semantic according to the affirmative of problem
Semanteme, provides the user with and more accurately answers.
Finally it should be noted that:Various embodiments above is merely illustrative of the technical solution of the present invention, rather than its limitations;To the greatest extent
The present invention is described in detail with reference to foregoing embodiments for pipe, it will be understood by those within the art that:Its according to
The technical scheme described in foregoing embodiments can so be modified, or which part or all technical characteristic are entered
Row equivalent substitution;And these modifications or replacement, the essence of appropriate technical solution is departed from various embodiments of the present invention technology
The scope of scheme, it all should cover among the claim of the present invention and the scope of specification.