CN111241841B - Semantic analysis method and device, computing device and readable medium - Google Patents

Semantic analysis method and device, computing device and readable medium Download PDF

Info

Publication number
CN111241841B
CN111241841B CN201811347302.0A CN201811347302A CN111241841B CN 111241841 B CN111241841 B CN 111241841B CN 201811347302 A CN201811347302 A CN 201811347302A CN 111241841 B CN111241841 B CN 111241841B
Authority
CN
China
Prior art keywords
facts
reasoning
target sentence
inference
rules
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
CN201811347302.0A
Other languages
Chinese (zh)
Other versions
CN111241841A (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.)
4Paradigm Beijing Technology Co Ltd
Original Assignee
4Paradigm Beijing Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 4Paradigm Beijing Technology Co Ltd filed Critical 4Paradigm Beijing Technology Co Ltd
Priority to CN201811347302.0A priority Critical patent/CN111241841B/en
Publication of CN111241841A publication Critical patent/CN111241841A/en
Application granted granted Critical
Publication of CN111241841B publication Critical patent/CN111241841B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Machine Translation (AREA)

Abstract

The invention provides a semantic analysis method and device, a computing device and a readable medium. The method comprises the following steps: acquiring a target sentence; analyzing the target sentence to obtain the basic fact about the target sentence; according to a plurality of preset reasoning rules, carrying out reasoning processing on the basic facts to obtain a plurality of reasoning facts about the sentences; based on the plurality of reasoning facts, a semantic analysis result is generated with respect to the labeled sentence. Compared with the prior art, the technical scheme of the invention can effectively infer the basic facts corresponding to the target sentences to obtain a plurality of inference facts, and perform semantic analysis based on the plurality of inference facts, so that the semantic analysis process is finer and more reasonable, and the accuracy of the semantic analysis result can be effectively improved.

Description

Semantic analysis method and device, computing device and readable medium
Technical Field
The present invention relates to the field of natural language processing technologies, and in particular, to a semantic analysis method and apparatus, a computing device, and a readable medium.
Background
Artificial intelligence (Artificial Intelligence; AI) is a branch of computer science that attempts to understand the nature of intelligence and to produce a new intelligent machine that can react in a similar manner to human intelligence, research in this field including robotics, language recognition, image recognition, natural language processing, and expert systems. Therefore, it is a new technical science to research, develop theories, methods, techniques and application systems for simulating, extending and expanding human intelligence.
For example, the field of natural language processing is a very important direction of AI research. In many intelligent question-answering systems of the prior art, AI may be employed. In the specific implementation process, a user inputs target corpus, and a natural language processing device in the intelligent question-answering system can analyze the target corpus based on a grammar rule set to obtain grammar. After determining that the grammar includes a semantic slot that needs to be validated, querying a built-in knowledge base for the presence of a result that matches the slot value of the semantic slot. When a result matching the slot value cannot be obtained, it is determined that the semantics of the slot value are incorrect. When a result matching the slot value is obtained, a semantic analysis result of the grammar is output. And then provides solutions for the user based on the semantic analysis result.
The existing semantic analysis scheme is too coarse and simple in technology, so that the accuracy of semantic analysis results is poor.
Disclosure of Invention
The invention provides a semantic analysis method and device, computing equipment and a readable medium, which are used for improving the accuracy of semantic analysis.
The invention provides a semantic analysis method, which comprises the following steps:
acquiring a target sentence;
analyzing the target sentence to acquire a ground fact about the target sentence;
Carrying out reasoning processing on the basic facts according to a plurality of preset reasoning rules to obtain a plurality of reasoning facts about the target statement;
based on a plurality of the reasoning facts, semantic analysis results about the target sentence are generated.
Further optionally, in the method as described above, analyzing the target sentence, obtaining a ground truth about the target sentence includes:
performing lexical analysis and syntactic analysis on the target sentence;
based on the analysis results of the lexical analysis and the syntactic analysis, the ground truth about the target sentence is acquired.
Further optionally, in the method as described above, performing lexical analysis on the target sentence includes:
word segmentation processing is carried out on the target sentence;
and marking the parts of speech and identifying the named entity for each word after the word segmentation.
Further optionally, in the method as described above, after part-of-speech tagging and named entity recognition are performed on each word after the word segmentation, the method further includes:
and checking the part of speech and named entity of each word by adopting a dictionary, and correcting errors.
Further optionally, in the method as described above, the parsing the target sentence includes:
and performing dependency syntactic analysis on the target sentence to acquire the sentence structure of the target sentence.
Further alternatively, in the method as described above, generating a semantic analysis result regarding the target sentence based on a plurality of the inference facts includes:
judging whether a plurality of reasoning facts have conflicted reasoning fact pairs or not;
if yes, acquiring the priority of an inference rule adopted by each inference fact in the mutually conflicting inference fact pair;
deleting the reasoning facts corresponding to the reasoning rules with low priority in the mutually conflicting reasoning facts pair, and retaining the reasoning facts corresponding to the reasoning rules with high priority;
generating the target semantic analysis result about the target sentence according to the left reasoning facts.
Further alternatively, in the method as described above, after the target sentence is acquired, the target sentence is analyzed, and before the ground truth about the target sentence is acquired, the method further includes:
and detecting and determining that the target sentence is suitable for the current application scene according to a white list preset for the current application scene.
Further optionally, in the method as described above, performing inference processing on the ground facts according to a plurality of preset inference rules, and obtaining the inference facts about the target sentence includes:
importing the preset multiple reasoning rules into a reasoning engine;
inputting the ground facts into the reasoning engine, and acquiring a plurality of reasoning facts output by the reasoning engine.
Further optionally, in the method as described above, before performing inference processing on the ground facts according to a plurality of preset inference rules to obtain a plurality of inference facts about the target sentence, the method further includes:
receiving a plurality of configured reasoning rules and priorities of the reasoning rules;
and storing a plurality of the inference rules and the priority of each inference rule.
The invention also provides a semantic analysis device, comprising:
the sentence acquisition module is used for acquiring a target sentence;
the fact analysis module is used for analyzing the target sentence and acquiring the basic fact about the target sentence;
the reasoning module is used for carrying out reasoning processing on the basic facts according to a plurality of preset reasoning rules to obtain a plurality of reasoning facts about the target statement;
And the generation module is used for generating a semantic analysis result about the target sentence based on a plurality of reasoning facts.
Further alternatively, in the apparatus as described above, the fact analysis module includes:
a lexical analysis unit for lexically analyzing the target sentence
A syntactic analysis unit, configured to perform syntactic analysis on the target sentence;
and a fact analysis unit for acquiring the ground facts about the target sentence based on the analysis results of the lexical analysis and the syntactic analysis.
Further optionally, in the apparatus as described above, the lexical analysis unit is configured to:
word segmentation processing is carried out on the target sentence;
and marking the parts of speech and identifying the named entity for each word after the word segmentation.
Further optionally, in the apparatus as described above, the lexical analysis unit is further configured to verify the part of speech and the named entity of each of the segmented words using a dictionary, and correct for an error.
Further optionally, in the apparatus as described above, the syntax analysis unit is configured to perform dependency syntax analysis on the target sentence, and obtain a sentence structure of the target sentence.
Further optionally, in the apparatus as described above, the generating module is configured to:
judging whether a plurality of reasoning facts have conflicted reasoning fact pairs or not;
if yes, acquiring the priority of an inference rule adopted by each inference fact in the mutually conflicting inference fact pair;
deleting the reasoning facts corresponding to the reasoning rules with low priority in the mutually conflicting reasoning facts pair, and retaining the reasoning facts corresponding to the reasoning rules with high priority;
generating the target semantic analysis result about the target sentence according to the left reasoning facts.
Further optionally, in the apparatus as described above, the apparatus further includes:
the detection module is used for detecting and determining that the target sentence is suitable for the current application scene according to a white list preset for the current application scene.
Further optionally, in the apparatus as described above, the inference module is configured to:
importing the preset multiple reasoning rules into a reasoning engine;
inputting the ground facts into the reasoning engine, and acquiring a plurality of reasoning facts output by the reasoning engine.
Further optionally, in the apparatus as described above, further includes:
The receiving module is used for receiving the configured plurality of reasoning rules and the priority of each reasoning rule;
and the storage module is used for storing a plurality of reasoning rules and the priority of each reasoning rule.
The present invention also provides a computing device comprising:
a processor; and
a memory having executable code stored thereon which, when executed by the processor, causes the processor to perform a method as described in any of the above.
The invention also provides a non-transitory machine-readable storage medium having stored thereon executable code which, when executed by a processor of an electronic device, causes the processor to perform the method of any of the above.
The semantic analysis method, the semantic analysis device, the computing equipment and the readable medium are used for acquiring target sentences; analyzing the target sentence to obtain the basic fact about the target sentence; according to a plurality of preset reasoning rules, carrying out reasoning processing on the basic facts to obtain a plurality of reasoning facts about the sentences; based on the plurality of reasoning facts, a semantic analysis result is generated with respect to the labeled sentence. Compared with the prior art, the method has the advantages that the foundation facts corresponding to the target sentences can be effectively inferred to obtain a plurality of inference facts, and semantic analysis is performed based on the plurality of inference facts, so that the semantic analysis process is finer and more reasonable, and the accuracy of the semantic analysis result can be effectively improved.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following more particular descriptions of exemplary embodiments of the disclosure as illustrated in the accompanying drawings wherein like reference numbers generally represent like parts throughout exemplary embodiments of the disclosure.
Fig. 1 is a flowchart of a semantic analysis method according to a first embodiment of the present invention.
Fig. 2 is a schematic diagram of the results of lexical analysis and syntactic analysis in the semantic analysis method of the present invention.
Fig. 3 is a flowchart of a second embodiment of the semantic analysis method according to the present invention.
Fig. 4 is a block diagram of a first embodiment of the semantic analysis device according to the present invention.
Fig. 5 is a block diagram of a second embodiment of the semantic analysis device according to the present invention.
FIG. 6 illustrates a schematic diagram of a computing device that may be used to implement the semantic analysis method described above according to one embodiment of the invention.
Detailed Description
Preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the preferred embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Fig. 1 is a flowchart of a semantic analysis method according to a first embodiment of the present invention. As shown in fig. 1, the semantic analysis method of the present embodiment may specifically include the following steps:
s100, acquiring a target sentence;
the execution subject of the semantic analysis method of this embodiment is a semantic analysis device, which may be disposed in an online smart device to provide online semantic analysis services. In this embodiment, the semantic analysis device corresponds to an application scenario, such as an application scenario of a riding information service, or a dining service scenario, or other application scenarios. That is, the user cannot query the dining-related service in the application of the ride information service, and vice versa.
Specifically, in this embodiment, the target sentence may be obtained by collecting a target sentence input by a user through voice or text. If the target sentence input by the user is in a voice form, voice recognition can be performed first, and the target sentence can be converted into a corresponding target sentence in a text form.
S101, analyzing a target sentence to acquire a basic fact about the target sentence;
in this embodiment, the target sentence may be analyzed, and the ground truth included in the target sentence may be acquired. Specifically, the number of ground truths included in the target sentence may be one, two, or more. And the type of the basic facts included in the target sentence may also be not limited, for example, may include part-of-speech facts, may include named entity class facts, may also include dependency type facts or other custom facts, and so on.
For example, in this embodiment, the process of analyzing the target sentence and obtaining the ground truth about the target sentence may include both lexical analysis and syntactic analysis. At this time, the step S101 may specifically include the following steps:
(a) Performing lexical analysis and syntactic analysis on the target sentence;
(b) Based on analysis results of lexical analysis and syntactic analysis, a ground truth about the target sentence is acquired.
The lexical analysis of the target sentence in the step (a) may include: word segmentation processing is carried out on the target sentence; and marking the parts of speech and identifying the named entities of each word after word segmentation.
In this embodiment, the word segmentation processing of the target sentence may be implemented with reference to a word segmentation processing tool in the related art, and details may refer to the related art, which is not described herein. In this embodiment, after word segmentation processing is performed on the target sentence, a plurality of word segments in the target sentence can be obtained. And then, marking the part of speech and identifying the named entity for each word after word segmentation. The parts of speech may include parts of speech in various grammars such as nouns, verbs, prepositions, conjunctions, etc., and when labeling parts of speech for each word, the parts of speech may be specifically labeled by a letter identifier corresponding to each part of speech, for example, the letter n is used to identify the part of speech of the noun, and the letter v is used to identify the part of speech of the verb, etc. Named entity identification in this embodiment is to identify only some of the partial words in the noun that belong to the entity name. Such as Beijing, shanghai, etc. all belong to named entities, and can be labeled by using named entities.
In practical application, when part of speech labeling and named entity recognition are performed on each segmented word after segmentation, recognition errors may be caused, and at this time, a dictionary may be used to check the part of speech and named entity of each segmented word and correct the error.
In this embodiment, the part-of-speech information of each word segment recorded in the dictionary, and the information record of each word segment that can be a named entity are the most authoritative. Therefore, in this embodiment, a dictionary may be used to check and correct the part of speech and named entity of each word. For example, some segmentations have only one part of speech explicitly recorded in the dictionary, and marked with another part of speech at part of speech tags, where correction is required. And for each named entity, a dictionary is also needed to check whether the named entity is the named entity, if a certain word is recorded in the dictionary and cannot be used as the named entity, the named entity label of the word is canceled. Through the verification and correction of the dictionary, the part of speech of the word segmentation and the accuracy of the named entity labeling can be improved.
The syntactic analysis of the target sentence in the step (a) includes: and performing dependency syntactic analysis on the target sentence to obtain the sentence structure of the target sentence. In the dependency syntax analysis of this embodiment, the dependency relationship between any two of the tokens in the target sentence may be marked, for example, the dependency relationship between two tokens may include a centering relationship ATT, a quantitative relationship QUN (quality), a juxtaposition relationship COO (coordinate), a parity relationship APP (appositive), an additional relationship ADJ (join), a moving object relationship VOB (verb-object), a mediate object relationship POB (pre-object), a main-predicate relationship SBV (subject-verb), and so on. After dependency relationship analysis, the sentence structure of the analyzed target sentence can be obtained.
For example, fig. 2 is a schematic diagram of the results of a lexical analysis and a syntactic analysis in the semantic analysis method of the present invention. In this embodiment, as shown in fig. 2, the technical scheme of the present invention is described by taking the target sentence as "buy a train ticket going to the mountain". After the target sentence "buy a train ticket to go down mountain" is lexically analyzed, the part of speech of each word can be marked, as shown in fig. 2, the part of speech of "buying" is marked as v, the part of speech of "one" is marked as m, the part of speech of "going" is marked as v, and so on. In addition, "Tangshan" is a place name, so named entity labeling is also added. In the specific implementation of dependency analysis, a head "Root" may be added at the beginning of the target sentence to facilitate analysis of dependencies between the tokens. As shown in fig. 2, in this embodiment, the dependency relationship between "Root" and the first word "buy" at the beginning of the target sentence is HED (head), and other dependency relationships are shown in fig. 2 in detail. The specific dependency analysis used may be described with reference to the related art, and will not be described in detail herein.
Thus, the analysis result shown in fig. 2 can be obtained for the target sentence based on the lexical analysis and the syntactic analysis. Finally, the ground truth about the target sentence can be acquired based on the analysis results of the lexical analysis and the syntactic analysis. For example, the ground truth that can be included in the analysis results shown in fig. 2 is numerous.
For example, the representation of the ground truth of the present embodiment may take the following form:
part of speech facts: pos (wn, 'part of speech identity'), where wn denotes the nth word. Such as pos (w 1, 'v'), pos (w 2,'m'), pos (w 3, 'v'), pos (w 4, 'ns'), pos (w 5, 'u'), and pos (w 6, 'n'), and so forth.
Named entity class facts: ner (w 4, 'LOC').
Dependency class facts: dep (wi, 'wi, dependency with wj', wj); such as dep (w 1, 'VOB', w 2), dep (w 1, 'VOB', w 6), dep (w 3, 'VOB', w 4), dep (w 3, 'RAD', w 5), dep (w 3, 'ATT', w 6), and the like;
literal facts: eq (wn, "word corresponding to wn"), such as eq (w 1, "buy"), eq (w 2, "one piece"), eq (w 3, "go"), eq (w 4, "tangshan"), eq (w 5, "etc.), eq (w 6," train ticket "), and the like.
In practical application, the fact can be customized, and the structure can be expressed as: fact name (parameter 1, parameter 2.., parameter n).
S102, carrying out reasoning processing on the basic facts according to a plurality of preset reasoning rules to obtain a plurality of reasoning facts about the target sentences;
optionally, before this step 102, it may include: receiving a plurality of configured reasoning rules and priorities of the reasoning rules; a plurality of inference rules and priorities of the inference rules are stored.
Specifically, the multiple inference rules in this embodiment are preconfigured by the developer, for example, the developer may configure multiple inference rules applicable to each application scenario according to each application scenario, and each inference rule may include a combination of multiple inference conditions. For example, each inference rule may link together multiple inference conditions by an and, or, operator. In practice, each inference rule may be expressed in the form of a regular expression. During specific configuration, a developer can input a plurality of configured reasoning rules into the semantic analysis device through the man-machine interface module, and meanwhile, priority is set for each reasoning rule.
Based on a plurality of preset reasoning rules, each reasoning rule is adopted to infer the basic facts, and a plurality of reasoning facts can be obtained altogether. That is, the inferred facts are inferred based on the ground facts, and can be understood as facts implicitly included in the target sentence. Referring to the types of the above-mentioned basic facts, such as the part-of-speech fact pos, the named entity class fact ner, the dependency class fact dep, and the literal facts, these facts may be the fact types built in the semantic analysis device, and the types of the inference facts may be set according to the application scenario class, for example, the facts of the service_type and the service_slot type may be set in the application scenario of the riding information service, and so on. In other application scenarios, one, two or more fact types corresponding to the scenario application can be set. In this way, when the ground facts are inferred according to a plurality of preset inference rules, various types of inference facts corresponding to the application scene can be obtained and stored.
For example, in this embodiment, in the application scenario of the riding information service, two inference facts may be inferred according to the following inference rules:
dep ($x1, "VOB", $x2) & ner ($x2, "LOC") & eq ($x1, "go") & dep ($x3, "ATT", $x1) & eq ($x3, "train ticket") - > service_type ("train ticket"), service_slot ("end_point", $x2).
Wherein: dep ($x1, "VOB", $x2) & ner ($x2, "LOC") & eq ($x1, "go") & dep ($x3, "ATT", $x1) & eq ($x3, "train ticket") are one inference rule, and service_type ("train ticket") and service_slot ("end_point", $x2) are two inference facts.
Of course, in practical application, one inference rule may be used to infer one inference fact service_type ("train ticket"), and another inference rule may be used to infer another inference fact service_slot ("end_point", $x2). Or in practical application, one inference rule can also infer the basic facts to obtain more than two inference facts, which are not described in detail herein. In addition, it should be noted that, in practical application, not every inference rule infers a basic fact, but it is necessary to infer an inference fact. In some application scenarios, there may be cases where a part of inference rules infer the ground facts, and no inference facts are obtained. In short, according to a plurality of preset reasoning rules, the ground facts are subjected to reasoning processing, so that a plurality of reasoning facts about the target sentence can be obtained.
S103, generating a semantic analysis result about the target sentence based on a plurality of reasoning facts.
In this embodiment, the ground facts are processed in an inference manner according to a plurality of preset inference rules, so that a plurality of inference facts related to the target sentence can be obtained, and based on all or part of the inference facts, a semantic analysis result corresponding to the target sentence can be generated.
For example, in the scenario of application of the riding information service, two reasoning facts of service_type ("train ticket") and service_slot ("end_point", "down hill") may be selected, and a semantic analysis result corresponding to the target sentence is generated.
For example, the semantic analysis result of the target sentence can be expressed as follows:
in practical application, under each application scenario, which types of reasoning facts are needed for generating the semantic analysis results corresponding to the target sentences can also be preset by the research personnel. For example, only n types of inference facts may be set, which all contribute to the semantic analysis result corresponding to the target sentence, and at this time, the semantic analysis result regarding the target sentence may be generated directly from the n types of inference facts. Wherein n is a positive integer. N types of reasoning facts can be set, but only m types of reasoning facts contribute to the semantic analysis result corresponding to the target sentence, n is a positive integer smaller than m, and at the moment, m types of reasoning facts can be directly used for generating the semantic analysis result related to the target sentence. Other reasoning facts may be used in other scenarios of the application, and are not described here in detail.
According to the semantic analysis method of the embodiment, a target sentence is obtained; analyzing the target sentence to obtain the basic fact about the target sentence; according to a plurality of preset reasoning rules, carrying out reasoning processing on the basic facts to obtain a plurality of reasoning facts about the sentences; based on the plurality of reasoning facts, a semantic analysis result is generated with respect to the labeled sentence. Compared with the prior art, the method has the advantages that the foundation facts corresponding to the target sentences can be effectively inferred to obtain a plurality of inference facts, and semantic analysis is performed based on the plurality of inference facts, so that the semantic analysis process is finer and more reasonable, and the accuracy of the semantic analysis result can be effectively improved.
Fig. 3 is a flowchart of a second embodiment of the semantic analysis method according to the present invention. As shown in fig. 1, the semantic analysis method of the present embodiment further describes the technical solution of the present invention in more detail on the basis of the technical solution of the embodiment shown in fig. 1. As shown in fig. 3, the semantic analysis method of the present embodiment may specifically include the following steps:
s200, acquiring a target sentence input by a user;
s201, detecting whether a target sentence is applicable to a current application scene according to a white list preset for the current application scene; if yes, go to step S202; otherwise, if not, returning the prompt message that the input can not provide the service.
In this embodiment, a preset white list in a current application scenario may be specifically used by a developer to analyze all target sentences that may be input when a user uses a service provided by the application in the application scenario, and extract all terms that may be input. For example, in a riding information service application scenario, words that may be input may include words that are bought, high-speed railway ticket, train ticket, go, where, high-speed railway, motor car, ordinary train, etc., and these words may be formed into a whitelist in the application scenario.
When the method is used, after the target sentence of the user is obtained, whether the target sentence is suitable for the current application scene or not can be detected according to the white list preset for the current application scene. In particular, when the method is implemented, whether one word in the white list is included in the target sentence of the user can be detected, if only one word in the white list corresponding to the current application scene is included, the target sentence is considered to be suitable for the current application scene, otherwise, if any word in the white list is not included in the target sentence of the user, the target sentence is considered to be unsuitable for the current application scene, for example, in the application scene of the riding information service, the user consults "what is good in the X market? At this time, according to the preset white list for the application scenario of the riding information service, it is determined that the target sentence is not suitable for the application scenario of the riding information service, and at this time, a prompt message that the service cannot be provided can be returned. Or in practical application, a prompt message like 'incapable of providing semantic analysis' or input error can be returned, and the main purpose is to inform the user that the semantic analysis service cannot be provided for the target sentence in the current application scene.
S202, analyzing a target sentence to acquire a basic fact about the target sentence; step S203 is performed;
the specific implementation manner of steps S200 and S202 in this embodiment may refer to the relevant descriptions in the embodiment shown in fig. 1, and will not be described herein.
S203, importing a plurality of preset reasoning rules into a reasoning engine; step S204 is executed;
s204, inputting the basic facts into an inference engine, and obtaining a plurality of inference facts output by the inference engine; step S205 is performed;
step S203 and step S204 of the present embodiment are one implementation manner of step S102 of the embodiment shown in fig. 1.
Specifically, in the present embodiment, reasoning is implemented by means of one reasoning engine. Before reasoning, a plurality of reasoning rules pre-configured by a developer can be imported into the reasoning engine. Then, during reasoning, the ground facts are directly input into the reasoning engine, so that the reasoning engine can reason the ground facts based on a plurality of reasoning rules, and a plurality of reasoning facts can be output.
205. Judging whether a mutually conflicting reasoning fact pair exists in the plurality of reasoning facts; if so, execute step S206; otherwise, executing S208;
s206, acquiring the priority of an inference rule adopted by each inference fact in the mutually conflicting inference facts; step S207 is performed;
S207, deleting the reasoning facts corresponding to the reasoning rules with low priority in the mutually conflicting reasoning facts based on the priorities of the reasoning rules adopted by the mutually conflicting reasoning facts, and retaining the reasoning facts corresponding to the reasoning rules with high priority; step S208 is performed;
for example, the inference engine gets two results for the same type of inference facts at the time of inference, and these two results are conflicting with each other at the time of analyzing the semantic result, so the conflict needs to be resolved in this embodiment, and one of the more favorable results is retained.
For example, for the service_slot type inference facts, two inference facts ("end_point", "down mountain") and ("end_point", "Qin island") are inferred, and two end_points are not possible in one target sentence. At this time, it is considered that ("end_point", "tangshan") and ("end_point", "Qin Royal island") are conflicting pairs of reasoning facts. It is necessary to acquire the priorities of two inference rules of ("end_point", "down mountain") and ("end_point", "Qin island") and delete the inference facts corresponding to the inference rule with low priority, while retaining the inference facts corresponding to the inference rule with high priority. For example, the priority of the inference rules for "end_point", "tangshan") is higher than the priority of the inference rules for "end_point", "Qin Huang island". The inferred facts ("end_point", "down hill") are kept at this time, and the inferred facts ("end_point", "Qin Royal island") are deleted.
S208, generating a target semantic analysis result about the target sentence according to the plurality of left reasoning facts.
Through the processing, the accuracy of the left reasoning facts can be ensured, and the accuracy of the generated target semantic analysis results can be further ensured.
By adopting the technical scheme, the semantic analysis method of the embodiment can delete unreasonable reasoning facts when the reasoning facts conflict, reserve proper reasoning facts, further conduct semantic analysis based on the reserved reasoning facts, and further improve accuracy of semantic analysis results.
Fig. 4 is a block diagram of a first embodiment of the semantic analysis device according to the present invention. As shown in fig. 4, the semantic analysis apparatus of the present embodiment includes:
the sentence acquisition module 10 is used for acquiring a target sentence;
the fact analysis module 11 is used for analyzing the target sentence acquired by the sentence acquisition module 10 and acquiring the basic fact about the target sentence;
the reasoning module 12 is configured to perform reasoning processing on the basic facts obtained by the fact analysis module 11 according to a plurality of preset reasoning rules, so as to obtain a plurality of reasoning facts about the target sentence;
the generation module 13 is configured to generate a semantic analysis result regarding the target sentence based on the plurality of inference facts obtained by the inference module 12.
The line-of-sight principle and the technical effect of the semantic analysis processing implemented by the module in the semantic analysis device in this embodiment are the same as those implemented by the related method embodiment, and detailed description of the related method embodiment may be referred to and will not be repeated here.
Fig. 5 is a block diagram of a second embodiment of the semantic analysis device according to the present invention. As shown in fig. 5, the semantic analysis device according to the present embodiment further describes the technical scheme of the present invention in more detail on the basis of the technical scheme of the embodiment shown in fig. 4.
As shown in fig. 5, in the semantic analysis device according to the present embodiment, the fact analysis module 11 includes:
the lexical analysis unit 111 is used for lexically analyzing the target sentence
The syntax analysis unit 112 is used for performing syntax analysis on the target sentence;
the fact analysis unit 113 is configured to acquire a ground fact about the target sentence based on the analysis results of the lexical analysis by the lexical analysis unit 111 and the syntactic analysis by the syntactic analysis unit 112.
Further optionally, the lexical analysis unit 111 is configured to:
word segmentation processing is carried out on the target sentence;
and marking the parts of speech and identifying the named entities of each word after word segmentation.
Further optionally, the lexical analysis unit 111 is further configured to verify the part of speech and the named entity of each word by using a dictionary, and correct for errors.
Further optionally, the syntax analysis unit 112 is configured to perform dependency syntax analysis on the target sentence, so as to obtain a sentence structure of the target sentence.
Further alternatively, in the semantic analysis apparatus of the present embodiment, the generating module 13 is configured to:
judging whether a mutually conflicting reasoning fact pair exists in the plurality of reasoning facts;
if yes, acquiring the priority of an inference rule adopted by each inference fact in the mutually conflicting inference facts;
based on the priority of the inference rule adopted by each inference fact in the mutually conflicting inference facts, deleting the inference facts corresponding to the inference rule with low priority in the mutually conflicting inference facts, and retaining the inference facts corresponding to the inference rule with high priority;
based on the plurality of reasoning facts left, a target semantic analysis result is generated with respect to the target sentence.
Further alternatively, as shown in fig. 5, the semantic analysis device according to the present embodiment further includes:
the detection module 14 is configured to detect and determine that the target sentence acquired by the sentence acquisition module 10 is suitable for the current application scenario according to a white list preset for the current application scenario.
Correspondingly, when the detection module 14 determines that the target sentence acquired by the sentence acquisition module 10 is suitable for the current application scenario, the fact analysis module 11 is triggered again to analyze the target sentence acquired by the sentence acquisition module 10, so as to acquire the ground facts about the target sentence. The trigger lexical analysis unit 111 performs lexical analysis on the target sentence acquired by the sentence acquisition module 10, and the trigger syntax analysis unit 112 performs syntax analysis on the target sentence acquired by the sentence acquisition module 10.
Further alternatively, in the semantic analysis apparatus of the present embodiment, the inference module 12 is configured to:
importing a plurality of preset reasoning rules into a reasoning engine;
the ground facts are input into an inference engine, and a plurality of inference facts output by the inference engine are acquired.
Further alternatively, as shown in fig. 5, the semantic analysis device according to the present embodiment further includes:
the receiving module 15 is configured to receive configured multiple inference rules and priorities of the inference rules;
the storage module 16 is configured to store a plurality of inference rules and priorities of the inference rules.
Correspondingly, the reasoning module 12 performs reasoning processing on the ground facts obtained by the fact analysis module 11 according to a plurality of preset reasoning rules stored by the storage module 16, so as to obtain a plurality of reasoning facts about the target sentence.
The line-of-sight principle and the technical effect of the semantic analysis processing implemented by the module in the semantic analysis device in this embodiment are the same as those implemented by the related method embodiment, and detailed description of the related method embodiment may be referred to and will not be repeated here.
FIG. 6 illustrates a schematic diagram of a computing device that may be used to implement the semantic analysis method described above according to one embodiment of the invention.
Referring to fig. 6, computing device 1000 includes memory 1010 and processor 1020. For example, the computing device 1000 of the present embodiment may be an intelligent service device provided with a semantic analysis device in a certain application scenario.
Processor 1020 may be a multi-core processor or may include multiple processors. In some embodiments, processor 1020 may comprise a general-purpose host processor and one or more special coprocessors such as, for example, a Graphics Processor (GPU), a Digital Signal Processor (DSP), etc. In some embodiments, the processor 1020 may be implemented using custom circuitry, for example, an application specific integrated circuit (ASIC, application Specific Integrated Circuit) or a field programmable gate array (FPGA, field Programmable Gate Arrays).
Memory 1010 may include various types of storage units, such as system memory, read Only Memory (ROM), and persistent storage. Where the ROM may store static data or instructions that are required by the processor 1020 or other modules of the computer. The persistent storage may be a readable and writable storage. The persistent storage may be a non-volatile memory device that does not lose stored instructions and data even after the computer is powered down. In some embodiments, the persistent storage device employs a mass storage device (e.g., magnetic or optical disk, flash memory) as the persistent storage device. In other embodiments, the persistent storage may be a removable storage device (e.g., diskette, optical drive). The system memory may be a read-write memory device or a volatile read-write memory device, such as dynamic random access memory. The system memory may store instructions and data that are required by some or all of the processors at runtime. Furthermore, memory 1010 may comprise any combination of computer-readable storage media including various types of semiconductor memory chips (DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), magnetic disks, and/or optical disks may also be employed. In some implementations, memory 1010 may include readable and/or writable removable storage devices such as Compact Discs (CDs), digital versatile discs (e.g., DVD-ROMs, dual-layer DVD-ROMs), blu-ray discs read only, super-density discs, flash memory cards (e.g., SD cards, min SD cards, micro-SD cards, etc.), magnetic floppy disks, and the like. The computer readable storage medium does not contain a carrier wave or an instantaneous electronic signal transmitted by wireless or wired transmission.
The memory 1010 has stored thereon executable code that, when processed by the processor 1020, causes the processor 1020 to perform the semantic analysis methods described above.
The semantic analysis method according to the present invention has been described above in detail with reference to the accompanying drawings.
Furthermore, the method according to the invention may also be implemented as a computer program or computer program product comprising computer program code instructions for performing the steps defined in the above-mentioned method of the invention.
Alternatively, the invention may also be embodied as a non-transitory machine-readable storage medium (or computer-readable storage medium, or machine-readable storage medium) having stored thereon executable code (or a computer program, or computer instruction code) which, when executed by a processor of an electronic device (or computing device, server, etc.), causes the processor to perform the steps of the above-described method according to the invention.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems and methods according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The foregoing description of embodiments of the invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the various embodiments described. The terminology used herein was chosen in order to best explain the principles of the embodiments, the practical application, or the improvement of technology in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

Claims (20)

1. A method of semantic analysis, the method comprising:
acquiring a target sentence;
analyzing the target sentence, and acquiring a basic fact about the target sentence, wherein the type of the basic fact comprises one or more of part-of-speech facts, named entity facts, dependency relationship facts and literal facts;
carrying out inference processing on the basic facts according to a plurality of preset inference rules to obtain a plurality of inference facts about the target sentences, wherein the inference facts are facts implicitly included in the target sentences which are inferred based on the basic facts;
and generating a semantic analysis result about the target sentence based on the reasoning facts contributing to the semantic analysis result corresponding to the target sentence among the reasoning facts.
2. The method of claim 1, wherein analyzing the target sentence to obtain a ground truth about the target sentence comprises:
performing lexical analysis and syntactic analysis on the target sentence;
based on the analysis results of the lexical analysis and the syntactic analysis, the ground truth about the target sentence is acquired.
3. The method of claim 2, wherein lexically analyzing the target sentence comprises:
word segmentation processing is carried out on the target sentence;
and marking the parts of speech and identifying the named entity for each word after the word segmentation.
4. The method of claim 3, wherein after part-of-speech tagging and named entity recognition of each word segment after the word segment processing, the method further comprises:
and checking the part of speech and named entity of each word by adopting a dictionary, and correcting errors.
5. The method of claim 2, wherein syntactically analyzing the target sentence comprises:
and performing dependency syntactic analysis on the target sentence to acquire the sentence structure of the target sentence.
6. The method of claim 1, wherein generating the semantic analysis result for the target sentence based on the inference facts that contribute to the semantic analysis result corresponding to the target sentence among the plurality of inference facts comprises:
judging whether a plurality of reasoning facts have conflicted reasoning fact pairs or not;
if yes, acquiring the priority of an inference rule adopted by each inference fact in the mutually conflicting inference fact pair;
Deleting the reasoning facts corresponding to the reasoning rules with low priority in the mutually conflicting reasoning facts pair, and retaining the reasoning facts corresponding to the reasoning rules with high priority;
and generating a semantic analysis result about the target sentence according to the left reasoning facts.
7. The method of claim 1, wherein after obtaining a target sentence, analyzing the target sentence, and before obtaining a ground truth about the target sentence, the method further comprises:
and detecting and determining that the target sentence is suitable for the current application scene according to a white list preset for the current application scene.
8. The method of claim 1, wherein performing an inference process on the ground truth according to a plurality of preset inference rules to obtain an inference facts about the target sentence comprises:
importing the preset multiple reasoning rules into a reasoning engine;
inputting the ground facts into the reasoning engine, and acquiring a plurality of reasoning facts output by the reasoning engine.
9. The method of claim 1, wherein before performing an inference process on the ground truth according to a preset plurality of inference rules to obtain a plurality of inference facts about the target sentence, the method further comprises:
Receiving a plurality of configured reasoning rules and priorities of the reasoning rules;
and storing a plurality of the inference rules and the priority of each inference rule.
10. A semantic analysis apparatus, the apparatus comprising:
the sentence acquisition module is used for acquiring a target sentence;
the fact analysis module is used for analyzing the target sentence and acquiring a basic fact related to the target sentence, wherein the type of the basic fact comprises one or more of part-of-speech facts, named entity facts, dependency relationship facts and literal facts;
the reasoning module is used for carrying out reasoning processing on the basic facts according to a plurality of preset reasoning rules to obtain a plurality of reasoning facts about the target sentence, wherein the reasoning facts are facts implicitly included in the target sentence which is deduced based on the basic facts;
the generation module is used for generating a semantic analysis result about the target sentence based on the reasoning facts contributing to the semantic analysis result corresponding to the target sentence in the reasoning facts.
11. The apparatus of claim 10, wherein the fact analysis module comprises:
A lexical analysis unit for lexically analyzing the target sentence
A syntactic analysis unit, configured to perform syntactic analysis on the target sentence;
and a fact analysis unit for acquiring the ground facts about the target sentence based on the analysis results of the lexical analysis and the syntactic analysis.
12. The apparatus of claim 11, wherein the lexical analysis unit is configured to:
word segmentation processing is carried out on the target sentence;
and marking the parts of speech and identifying the named entity for each word after the word segmentation.
13. The apparatus of claim 12, wherein the lexical analysis unit is further configured to verify the part of speech and the named entity of each of the segmented words using a dictionary and correct for errors.
14. The apparatus of claim 11, wherein the syntax analysis unit is configured to perform dependency syntax analysis on the target sentence to obtain a sentence structure of the target sentence.
15. The apparatus of claim 10, wherein the generating module is configured to:
judging whether a plurality of reasoning facts have conflicted reasoning fact pairs or not;
If yes, acquiring the priority of an inference rule adopted by each inference fact in the mutually conflicting inference fact pair;
deleting the reasoning facts corresponding to the reasoning rules with low priority in the mutually conflicting reasoning facts pair, and retaining the reasoning facts corresponding to the reasoning rules with high priority;
and generating a semantic analysis result about the target sentence according to the plurality of the left reasoning facts.
16. The apparatus of claim 10, wherein the apparatus further comprises:
the detection module is used for detecting and determining that the target sentence is suitable for the current application scene according to a white list preset for the current application scene.
17. The apparatus of claim 10, wherein the inference module is configured to:
importing the preset multiple reasoning rules into a reasoning engine;
inputting the ground facts into the reasoning engine, and acquiring a plurality of reasoning facts output by the reasoning engine.
18. The apparatus of claim 10, wherein the apparatus further comprises:
the receiving module is used for receiving the configured plurality of reasoning rules and the priority of each reasoning rule;
And the storage module is used for storing a plurality of reasoning rules and the priority of each reasoning rule.
19. A computing device, comprising:
a processor; and
a memory having executable code stored thereon, which when executed by the processor causes the processor to perform the method of any of claims 1-9.
20. A non-transitory machine-readable storage medium having stored thereon executable code, which when executed by a processor of an electronic device, causes the processor to perform the method of any of claims 1 to 9.
CN201811347302.0A 2018-11-13 2018-11-13 Semantic analysis method and device, computing device and readable medium Active CN111241841B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811347302.0A CN111241841B (en) 2018-11-13 2018-11-13 Semantic analysis method and device, computing device and readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811347302.0A CN111241841B (en) 2018-11-13 2018-11-13 Semantic analysis method and device, computing device and readable medium

Publications (2)

Publication Number Publication Date
CN111241841A CN111241841A (en) 2020-06-05
CN111241841B true CN111241841B (en) 2024-04-05

Family

ID=70865505

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811347302.0A Active CN111241841B (en) 2018-11-13 2018-11-13 Semantic analysis method and device, computing device and readable medium

Country Status (1)

Country Link
CN (1) CN111241841B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5390281A (en) * 1992-05-27 1995-02-14 Apple Computer, Inc. Method and apparatus for deducing user intent and providing computer implemented services
CN105701253A (en) * 2016-03-04 2016-06-22 南京大学 Chinese natural language interrogative sentence semantization knowledge base automatic question-answering method
CN106055536A (en) * 2016-05-19 2016-10-26 苏州大学 Method and system for united inference of Chinese events
CN106649266A (en) * 2016-11-29 2017-05-10 北京科技大学 Logical inference method for ontology knowledge

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5390281A (en) * 1992-05-27 1995-02-14 Apple Computer, Inc. Method and apparatus for deducing user intent and providing computer implemented services
CN105701253A (en) * 2016-03-04 2016-06-22 南京大学 Chinese natural language interrogative sentence semantization knowledge base automatic question-answering method
CN106055536A (en) * 2016-05-19 2016-10-26 苏州大学 Method and system for united inference of Chinese events
CN106649266A (en) * 2016-11-29 2017-05-10 北京科技大学 Logical inference method for ontology knowledge

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
张体首 等.语义搜索引擎概念模型.微电子学与计算机.2007,第24卷(第3期),第171-173、177页. *
语义搜索引擎概念模型;张体首 等;微电子学与计算机;第24卷(第3期);第171-173、177页 *

Also Published As

Publication number Publication date
CN111241841A (en) 2020-06-05

Similar Documents

Publication Publication Date Title
CN111460787B (en) Topic extraction method, topic extraction device, terminal equipment and storage medium
US10831793B2 (en) Learning thematic similarity metric from article text units
US8370275B2 (en) Detecting factual inconsistencies between a document and a fact-base
US11030411B2 (en) Methods, apparatuses, and devices for generating word vectors
US20160140026A1 (en) Systems and Methods for Selection of Test Cases for Payment Terminals
CN111339751A (en) Text keyword processing method, device and equipment
CN110705214A (en) Automatic coding method and device
WO2022142635A1 (en) Service information inputting method and apparatus, and server and storage medium
CN113434542B (en) Data relationship identification method and device, electronic equipment and storage medium
CN114418398A (en) Scene task development method, device, equipment and storage medium
CN110246063B (en) Method and device for guiding case examination and management
US11068463B2 (en) System and method for managing log data
CN111241841B (en) Semantic analysis method and device, computing device and readable medium
CN115640810B (en) Method, system and storage medium for identifying communication sensitive information of power system
Jain et al. Prigen: Towards automated translation of android applications’ code to privacy captions
US8966455B2 (en) Flow analysis in program execution
CN111061927B (en) Data processing method and device and electronic equipment
US20210089539A1 (en) Associating user-provided content items to interest nodes
CN109993190B (en) Ontology matching method and device and computer storage medium
JP2007122207A (en) Program analysis program, program analyzing device and program analyzing method
CN113703753B (en) Method and device for product development and product development system
US11423228B2 (en) Weakly supervised semantic entity recognition using general and target domain knowledge
CN115509904A (en) Assertion generation method and device of interface test case
US11503055B2 (en) Identifying siem event types
CN114510300A (en) Method and equipment for embedding target object in derived class

Legal Events

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