A semantic analysis method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202211186769.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-27
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2042-09-27
AI Technical Summary
[0006]为解决上述技术问题,本申请示出了一种语义分析方法、装置、电子设备及存储介质,以至少解决相关技术中基于语法句法的依存标注无法与图谱信息进行关联,难以实现在图谱中的查询的问题
[0061]获取待分析语句;对待分析语句进行命名实体识别,得到多个待分析语段;利用依存分析模型,对待分析语句进行语义依存分析,确定待分析语段所依存的目标待分析语段及对应的依存关系标签,以实现对待分析语句的语义分析,其中,依存分析模型基于对训练数据的语义依存分析得到,训练数据预先根据依存关系标签进行标注。
Smart Images

Figure CN115563984B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a semantic analysis method, apparatus, electronic device, and storage medium. Background Technology
[0002] In some scenarios, data can be stored in the form of graphs, which are a knowledge storage structure containing basic elements such as entities, relations, attributes, and ontology. The basic structure of a graph is a triple, which has two forms: "entity-attribute-attribute value" and "entity-relationship-entity".
[0003] When querying data in the graph, it is necessary to perform semantic analysis on the user's input question, establish the association between the question and the elements in the graph, and then obtain the corresponding elements from the graph as the query results for the question.
[0004] In existing technologies, syntactic dependency parsing is usually used to perform semantic analysis on questions. In this method, the sentence is first segmented into words, and then the grammatical dependency relationships between the words are analyzed. The relation type labels are all grammatical relations such as "subject-verb-object-adjective-adverb-complement".
[0005] However, this kind of dependency annotation based on syntax cannot be associated with graph information, making it difficult to query within the graph. Summary of the Invention
[0006] To address the aforementioned technical problems, this application discloses a semantic analysis method, apparatus, electronic device, and storage medium, to at least resolve the issue in related technologies where dependency annotation based on syntax and grammar cannot be associated with graph information, making it difficult to perform queries within the graph. The technical solution disclosed herein is as follows:
[0007] In a first aspect, this application discloses a semantic analysis method, the method comprising:
[0008] Obtain the statement to be analyzed;
[0009] Named entity recognition is performed on the statement to be analyzed to obtain multiple segments to be analyzed.
[0010] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed to determine the target statement to be analyzed and the corresponding dependency relation labels, so as to realize the semantic analysis of the statement to be analyzed. The dependency parsing model is obtained based on the semantic dependency analysis of the training data, and the training data is pre-labeled according to the dependency relation labels.
[0011] Optionally, the dependency relationship tags include, but are not limited to:
[0012] Root, attribute relationship, constraint value, constraint type, logical relationship, ontology constraint, judgment value, aggregate function, order, and meaningless.
[0013] Optionally, the segment to be analyzed includes a root segment. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes:
[0014] Add the root segment before the statement to be analyzed to obtain the target statement;
[0015] The target statement is input into the dependency parsing model, and semantic dependency parsing is performed on the target statement;
[0016] The main entity segment is used as the target segment to be analyzed on which the root segment depends, and the root is used as the dependency relation label corresponding to the root segment; or, the root segment is used as the target segment to be analyzed on which the main entity segment depends, and the root is used as the dependency relation label corresponding to the main entity segment.
[0017] If there is no main entity segment in the target statement, the root segment itself is taken as the target segment to be analyzed, and the root is taken as the dependency relation label corresponding to the root segment.
[0018] Optionally, the segment to be analyzed includes attribute relation segments. The step of using a dependency parsing model to perform semantic dependency analysis on the statement to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes:
[0019] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0020] The entity segment associated with the attribute relation segment is taken as the target segment to be analyzed, and the attribute relation is determined as the dependency relation label corresponding to the attribute relation segment.
[0021] Optionally, the segment to be analyzed includes a constraint value segment. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation labels, includes:
[0022] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0023] The attribute relation segment constrained by the constraint value segment is taken as the target segment to be analyzed on which the constraint value segment depends.
[0024] In the absence of an attribute relation segment constrained by the constraint value segment, the entity segment constrained by the constraint value segment is taken as the target segment to be analyzed on which the constraint value segment depends.
[0025] The constraint value is used as the dependency label corresponding to the constraint value segment.
[0026] Optionally, the segment to be analyzed includes constraint-type word segments. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation labels, includes:
[0027] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0028] The constraint value segment associated with the constraint type word segment is taken as the target segment to be analyzed on which the constraint type word segment depends;
[0029] The constraint type is used as the dependency label corresponding to the constraint value segment.
[0030] Optionally, the segment to be analyzed includes logical relation segments. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes:
[0031] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0032] Any segment to be analyzed that is defined by the logical relation segment is taken as the target segment to be analyzed on which the logical relation segment depends.
[0033] The logical relationship is used as the dependency relationship label corresponding to the logical relationship word segment.
[0034] Optionally, the segment to be analyzed includes entity type segments. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes:
[0035] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0036] The entity segment constrained by the entity type segment is taken as the target segment to be analyzed on which the entity type segment depends.
[0037] The ontology constraint is used as the dependency relation label corresponding to the entity type segment.
[0038] Optionally, the segment to be analyzed includes an entity segment to be judged. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes:
[0039] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0040] The attribute relation segment that needs to be judged for the entity segment to be judged is taken as the target segment to be analyzed on which the entity segment to be judged depends, and the judgment value is taken as the dependency relation label corresponding to the entity segment to be judged.
[0041] In the absence of the attribute relation segment, the entity segment to be judged is taken as the target segment to be analyzed on which the judgment value segment to be judged depends, and the judgment value is taken as the dependency relation tag corresponding to the judgment value segment.
[0042] Optionally, the segment to be analyzed includes aggregator segments. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes:
[0043] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0044] The attribute relation word segment constrained by the aggregated word segment is taken as the target segment to be analyzed on which the aggregated word segment depends;
[0045] The aggregation function is used as the dependency label corresponding to the aggregation term segment.
[0046] Optionally, the segment to be analyzed includes multiple entity segments with a sequential order. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes:
[0047] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0048] The entity segment that ranks first in the order of the target entity segment is taken as the target segment to be analyzed, on which the target entity segment depends.
[0049] The order is used as the dependency relation label corresponding to the target entity segment.
[0050] Optionally, the segment to be analyzed includes meaningless segments. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes:
[0051] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0052] The meaningless segment itself is taken as the target segment to be analyzed, upon which the meaningless segment depends.
[0053] The meaninglessness is used as the dependency relation label corresponding to the meaningless segment.
[0054] According to a second aspect of the present disclosure, a semantic analysis apparatus is provided, comprising:
[0055] The acquisition unit is configured to execute the acquisition of statements to be analyzed.
[0056] The identification unit is configured to perform named entity recognition on the statement to be analyzed, thereby obtaining multiple segments to be analyzed.
[0057] The analysis unit is configured to perform semantic dependency analysis on the statement to be analyzed using a dependency parsing model, and determine the target statement to be analyzed and the corresponding dependency relation labels on which the statement to be analyzed depends, so as to realize the semantic analysis of the statement to be analyzed. The dependency parsing model is obtained based on the semantic dependency analysis of the training data, and the training data is pre-labeled according to the dependency relation labels.
[0058] According to a third aspect of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the semantic analysis method as described in any of the preceding claims.
[0059] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the semantic analysis method described in any of the preceding claims.
[0060] Compared with the prior art, this application has the following advantages:
[0061] The process involves: acquiring the statement to be analyzed; performing named entity recognition on the statement to be analyzed to obtain multiple segments to be analyzed; and using a dependency parsing model to perform semantic dependency analysis on the statement to be analyzed, determining the target segments to be analyzed and their corresponding dependency relation labels, thereby achieving semantic analysis of the statement to be analyzed. The dependency parsing model is based on the semantic dependency analysis of the training data, which is pre-labeled according to the dependency relation labels.
[0062] In this way, based on the preset dependency relationship labels, the dependency relationships of the segments to be analyzed in the statement to be analyzed can be analyzed, thereby determining the dependency relationships between each segment to be analyzed. The dependency relationship labels can be designed for complex questions. Thus, the semantic analysis method provided by this solution can perform semantic dependency analysis on complex questions, and further, it can realize the query in the graph based on complex questions. Attached Figure Description
[0063] Figure 1 This is a flowchart of the steps of a semantic analysis method according to this application;
[0064] Figure 2 This is a logical diagram illustrating a semantic dependency analysis process according to this application;
[0065] Figure 3 This is a structural block diagram of a semantic analysis device according to this application;
[0066] Figure 4 This is a schematic diagram of an electronic device according to this application. Detailed Implementation
[0067] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0068] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0069] Reference Figure 1 The flowchart of a semantic analysis method according to this application is shown, which may specifically include the following steps:
[0070] In step S11, the statement to be analyzed is obtained.
[0071] In some scenarios, it is necessary to perform semantic analysis on the statement to be analyzed, which analyzes the semantic relationships between words in the statement. The semantic analysis process includes semantic dependency analysis, which analyzes the semantic relationships between words in the statement to be analyzed, and analyzes the dependency relationships between meaningful words. Words that are not related to other words can be marked as meaningless in dependency analysis.
[0072] For example, such as Figure 2 The diagram illustrates the semantic dependency analysis of the statement "Does the Forbidden City offer student tickets on weekends?". Here, "Forbidden City," "weekend," "student," and "ticket" are all meaningful words, while "yes" and "maybe" are meaningless words. "ROOT" is the newly added root node for the statement during semantic dependency analysis. "Forbidden City" is the governing word of the statement, "ticket" is the main relation word dependent on "Forbidden City," and "weekend" and "student" are relation constraints dependent on "ticket." It's understandable that this semantic dependency analysis scheme requires annotation of meaningless words like "yes" and "maybe," which is more cumbersome and only allows for basic entity, relation, and constraint annotation, making it unsuitable for more complex statements.
[0073] In this application, the statement to be analyzed can be text information input by the user, or text information obtained after normalization processing, or text information obtained based on text recognition of input speech, etc., and there is no specific limitation.
[0074] In step S12, named entity recognition is performed on the statement to be analyzed to obtain multiple segments to be analyzed.
[0075] In this step, named entity recognition can be performed on the statement to be analyzed. Named entity recognition refers to identifying entities with specific meanings in the statement to be analyzed, including but not limited to names of people, places, organizations, and proper nouns. In the field of graphs, named entities can include information from the graph or some intent information. The identified named entities can be used as the segment to be analyzed for subsequent processing.
[0076] Among them, rule-based named entity recognition algorithms, statistical named entity recognition algorithms, or conditional random field-based named entity recognition algorithms can be used, etc., without any specific limitations.
[0077] In step S13, the dependency parsing model is used to perform semantic dependency analysis on the statement to be analyzed, and to determine the target statement to be analyzed and the corresponding dependency relation labels on which the statement to be analyzed depends, so as to realize the semantic analysis of the statement to be analyzed. The dependency parsing model is obtained based on the semantic dependency analysis of the training data, and the training data is pre-labeled according to the dependency relation labels.
[0078] In this step, dependency parsing mainly includes two aspects: first, the dependency relations of the segment to be analyzed, which indicate which target segment the segment to be analyzed depends on; and second, the dependency relation labels corresponding to the segment to be analyzed, which are predefined. The basic rules of dependency parsing are that a segment can only depend on one segment, cannot point to multiple segments, and each dependency relation can only define one type of relation label. The dependency parsing model can be a neural network model, a machine learning model, etc., without specific limitations.
[0079] Dependency relation tags include, but are not limited to: root, attribute relation, constraint value, constraint type, logical relation, ontology constraint, judgment value, aggregate function, order, and meaningless. Different dependency relation tags can indicate different dependency relation types between different segments, thus facilitating semantic analysis of the statements to be analyzed.
[0080] In one implementation, the segment to be analyzed includes a root segment. Therefore, the steps of performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model to determine the target segment to be analyzed and its corresponding dependency relation labels can include:
[0081] Add a root segment before the statement to be analyzed to obtain the target statement; input the target statement into the dependency parsing model to perform semantic dependency parsing; use the main entity segment as the target statement to be analyzed on which the root segment depends, and use the root as the dependency relation label corresponding to the root segment; or, use the root segment as the target statement to be analyzed on which the main entity segment depends, and use the root as the dependency relation label corresponding to the main entity segment; if there is no main entity segment in the target statement, use the root segment itself as the target statement to be analyzed on which the root segment depends, and use the root as the dependency relation label corresponding to the root segment.
[0082] In this context, the root segment corresponds to the root node when generating the dependency tree. During dependency parsing, a root segment is first added before the statement to be analyzed. Then, when the dependency parsing model processes the data, the main entity segment is used as the target statement to be analyzed on which the root segment depends, and the root is used as the dependency relation label corresponding to the root segment. That is, the main entity is pointed to ROOT, or ROOT is pointed to the main entity. For example, in the statement "Who is Zhang San's wife?", "Zhang San" is the main entity and associated with ROOT.
[0083] If there is no main entity segment, it means that there is no main entity in the statement to be analyzed. In this case, ROOT can represent the unknown main entity. For example, if the statement to be analyzed is "Who are the people who are under 30 years old", there is no main entity in the statement to be analyzed. ROOT does not point to other segments, but points to ROOT itself.
[0084] In one implementation, the segment to be analyzed includes attribute relation segments. The steps of performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model to determine the target segment to be analyzed and its corresponding dependency relation label include: performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model; using the entity segment associated with the attribute relation segment as the target segment to be analyzed, or, if no entity segment is associated with the attribute relation segment, using the root segment as the target segment to be analyzed; and determining the attribute relation as the dependency relation label corresponding to the attribute relation segment.
[0085] In other words, attribute relation words point to the associated entity, or the unknown entity represented by the ROOT. For example, if the statement to be analyzed is "Who is Zhang San's wife?", then "wife" is an attribute relation word segment that points to the main entity segment "Zhang San". Or, if the statement to be analyzed is "Who are the people under 30 years old?", then "age" is an attribute relation word segment. If there is no entity segment associated with "age" in the statement to be analyzed, then "age" can point to an unknown entity, i.e., the ROOT segment.
[0086] In one implementation, the segment to be analyzed includes a constraint value segment. The steps of performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model to determine the target segment to be analyzed and its corresponding dependency relation label include: performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model; using the attribute relation segment constrained by the constraint value segment as the target segment to be analyzed on which the constraint value segment depends; if no attribute relation segment is constrained by the constraint value segment, using the entity segment constrained by the constraint value segment as the target segment to be analyzed on which the constraint value segment depends; and using the constraint value as the dependency relation label corresponding to the constraint value segment.
[0087] In other words, the semantics of the statement to be analyzed, which serves as the constraint value, points to the constrained attribute relation word. If there is no corresponding attribute relation word, the constraint value directly points to the constrained entity. For example, if the statement to be analyzed is "Who is under 30 years old?", then "30 years old" as the constraint value statement points to the attribute relation word "age". Or, if the statement to be analyzed is "Who is under 30 years old?", and there is no attribute relation word corresponding to "30 years old" in the statement to be analyzed, then "30 years old" will point to the constrained entity. Since there is no corresponding entity in the statement to be analyzed, "30 years old" points to the ROOT statement representing the unknown entity. Or, if the statement to be analyzed is "Who is the youngest in a certain department?", then "youngest" as the constraint value statement should point to the attribute relation word "age".
[0088] In one implementation, the segment to be analyzed includes constraint-type word segments. The steps of performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model to determine the target segment to be analyzed and its corresponding dependency relation label include: performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model; using constraint-type word segments associated with constraint-type word segments as the target segment to be analyzed on which the constraint-type word segments depend; in the case where no constraint-type word segments are associated with constraint-type word segments, using attribute relation word segments associated with constraint-type word segments as the target segment to be analyzed on which the constraint-type word segments depend; and using constraint types as the dependency relation labels corresponding to the constraint-value segments.
[0089] In other words, constraint type words point to the corresponding constraint values. Constraint types generally include semantics such as greater than, less than, equal to, not equal to, include, belong to, etc. For example, if the statement to be analyzed is "Who are the people who are less than 30 years old", then "less than" as a constraint type word segment points to the constraint value segment "30 years old"; or, if the statement to be analyzed is "Who is the youngest person in a certain department", then "youngest" as a constraint type word segment points to the attribute relation word segment "age".
[0090] In one implementation, the segment to be analyzed includes logical relation segments. The steps of performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model to determine the target segment to be analyzed and its corresponding dependency relation label include: performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model; taking any segment to be analyzed defined by the logical relation segment as the target segment to be analyzed on which the logical relation segment depends; and taking the logical relation as the dependency relation label corresponding to the logical relation segment.
[0091] Among them, logical relationships mainly refer to AND and OR relationships. That is to say, when this type of word appears in the statement to be analyzed, it is marked. To determine which entities have logical relationships, the logical relation word can be pointed to any one of the entities. For example, if the statement to be analyzed is "How many students have excellent or good grades", the logical relation word "OR" is a logical relationship between the condition values "excellent" and "good", so "OR" can be pointed to either "excellent" or "good". If the statement to be analyzed is "Who are the students with excellent grades or who are 1.7 meters tall", the logical relation word "OR" is a logical relationship between the two conditions "excellent grades" or "1.7 meters tall", so "OR" can be pointed to either "excellent grades" or "1.7 meters tall".
[0092] In one implementation, the segment to be analyzed includes entity type segments. The steps of performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model to determine the target segment to be analyzed and its corresponding dependency relation labels include: performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model; using entity type segment constraints as the target segment to be analyzed on which the entity type segment depends; and using ontology constraints as the dependency relation labels corresponding to the entity type segment.
[0093] In the statement to be analyzed, each entity can have a different entity type. For example, names like Li, Wang, and Zhao can be different entity types, and the entities they constrain are all people. In other words, the entity type segment in the statement to be analyzed points to the entity segment it constrains. For example, if the statement to be analyzed is "What department is responsible for performance appraisal?", then "department" as an entity type segment can depend on the unknown entity ROOT that it constrains.
[0094] In one implementation, the segment to be analyzed includes an entity segment to be judged. The steps of performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model to determine the target segment to be analyzed and its corresponding dependency relation label include: performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model; taking the attribute relation segment to be judged as the target segment to be analyzed, and the judgment value as the dependency relation label corresponding to the entity segment to be judged; in the absence of an attribute relation segment, taking the entity segment to be judged as the target segment to be analyzed, and the judgment value as the dependency relation label corresponding to the judgment value segment.
[0095] In other words, the entity segment to be judged in the statement to be analyzed points to the attribute relation segment to be judged. For example, if the statement to be analyzed is "Is Zhang San's wife Li Si?", the entity segment to be judged, "Li Si", as a person entity to be judged, points to the attribute relation segment "wife". Alternatively, if there is no attribute relation segment in the statement to be analyzed, the judgment value segment points to the entity segment to be judged. For example, if the statement to be analyzed is "Is so-and-so 30 years old?", and there is no attribute relation segment like "age", then the judgment value segment "30 years old" directly points to the entity segment to be judged, "so-and-so".
[0096] In one implementation, the segment to be analyzed includes an aggregate term segment. The steps of performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model to determine the target segment to be analyzed and its corresponding dependency relation labels include: performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model; using the attribute relation term segments constrained by the aggregate term segment as the target segment to be analyzed on which the aggregate term segment depends; and using the aggregate function as the dependency relation label corresponding to the aggregate term segment.
[0097] Aggregate functions aggregate the returned answers, including various aggregation methods such as summation, counting, finding maximum / minimum values, and averaging. Aggregate terms point to the attribute relation terms that the aggregate function is aggregating. For example, if the statement to be analyzed is "The youngest employee in a certain department is how old they are," then "youngest" is the aggregate term, pointing to the attribute relation term "age." It can be understood that, unlike constraint values, aggregate functions act as dependency relation labels. The attribute relation term "age" is not a constraint condition on a specific constraint value, but rather the answer that the aggregate function is returning. Therefore, "youngest" is labeled as an aggregate term, not a constraint value term.
[0098] In one implementation, the segment to be analyzed includes multiple entity segments with a sequential order. The steps of performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model to determine the target segment to be analyzed and its corresponding dependency relation labels include: performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model; identifying the entity segment preceding the target entity segment as the target segment to be analyzed; and using the sequence as the dependency relation label corresponding to the target entity segment.
[0099] In other words, when the entities in the statement to be analyzed have a sequential order, the later entity points to the earlier entity to indicate the sequential relationship. For example, if the statement to be analyzed is "Li is how many years older than Zhao", then the age of "Li" is less than the age of "Zhao", that is, "Li" is in the order of "Zhao", so "Zhao" points to "Li".
[0100] In one implementation, the segment to be analyzed includes a meaningless segment. Then, using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed to determine the target segment to be analyzed and its corresponding dependency relation label. This includes: performing semantic dependency analysis on the statement to be analyzed using a dependency parsing model; treating the meaningless segment itself as the target segment to be analyzed on which the meaningless segment depends; and using "meaningless" as the dependency relation label corresponding to the meaningless segment.
[0101] In other words, meaningless words are those that are identified and labeled by entity recognition but have no real meaning. In this embodiment of the application, such words can be assigned to themselves and labeled as meaningless. For example, if the statement to be analyzed is "Who is the youngest in the company", the word "company" has no meaning, so it can be assigned to itself and labeled as meaningless.
[0102] After determining the target segment to be analyzed and its corresponding dependency label, the semantic dependency relationship between each segment in the sentence to be analyzed can be determined. Then, based on the semantic dependency relationship, the semantic analysis of the sentence to be analyzed can be further realized.
[0103] As can be seen from the above, the technical solution provided by the embodiments of this disclosure can perform dependency relationship analysis on the segments to be analyzed in the statement to be analyzed based on preset dependency relationship tags, thereby determining the dependency relationship between each segment to be analyzed. The dependency relationship tags can be designed for complex questions. In this way, the semantic analysis method provided by this solution can perform semantic dependency analysis on complex questions, and thus, can realize querying in the graph based on complex questions.
[0104] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions involved are not necessarily required by this application.
[0105] Reference Figure 3 The diagram shows a structural block diagram of a semantic analysis device according to this application. The device may specifically include the following modules:
[0106] Unit 201 is configured to execute the statement to be analyzed.
[0107] The identification unit 202 is configured to perform named entity recognition on the statement to be analyzed to obtain multiple segments to be analyzed;
[0108] Analysis unit 203 is configured to perform semantic dependency analysis on the statement to be analyzed using a dependency parsing model, determine the target statement to be analyzed and the corresponding dependency relation labels on which the statement to be analyzed depends, so as to realize the semantic analysis of the statement to be analyzed. The dependency parsing model is obtained based on the semantic dependency analysis of training data, and the training data is pre-labeled according to the dependency relation labels.
[0109] Optionally, the dependency relationship tags include, but are not limited to:
[0110] Root, attribute relationship, constraint value, constraint type, logical relationship, ontology constraint, judgment value, aggregate function, order, and meaningless.
[0111] Optionally, the segment to be analyzed includes a root segment, and the analysis unit 203 is specifically configured to execute:
[0112] Add the root segment before the statement to be analyzed to obtain the target statement;
[0113] The target statement is input into the dependency parsing model, and semantic dependency parsing is performed on the target statement;
[0114] The main entity segment is used as the target segment to be analyzed on which the root segment depends, and the root is used as the dependency relation label corresponding to the root segment; or, the root segment is used as the target segment to be analyzed on which the main entity segment depends, and the root is used as the dependency relation label corresponding to the main entity segment.
[0115] If there is no main entity segment in the target statement, the root segment itself is taken as the target segment to be analyzed, and the root is taken as the dependency relation label corresponding to the root segment.
[0116] Optionally, the segment to be analyzed includes attribute relation segments, and the analysis unit 203 is specifically configured to execute:
[0117] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0118] The entity segment associated with the attribute relation segment is taken as the target segment to be analyzed, and the attribute relation is determined as the dependency relation label corresponding to the attribute relation segment.
[0119] Optionally, the segment to be analyzed includes a constraint value segment, and the analysis unit 203 is specifically configured to execute:
[0120] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0121] The attribute relation segment constrained by the constraint value segment is taken as the target segment to be analyzed on which the constraint value segment depends.
[0122] In the absence of an attribute relation segment constrained by the constraint value segment, the entity segment constrained by the constraint value segment is taken as the target segment to be analyzed on which the constraint value segment depends.
[0123] The constraint value is used as the dependency label corresponding to the constraint value segment.
[0124] Optionally, the segment to be analyzed includes constraint-type word segments, and the analysis unit 203 is specifically configured to execute:
[0125] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0126] The constraint value segment associated with the constraint type word segment is taken as the target segment to be analyzed on which the constraint type word segment depends;
[0127] The constraint type is used as the dependency label corresponding to the constraint value segment.
[0128] Optionally, the segment to be analyzed includes logical relation segments, and the analysis unit 203 is specifically configured to execute:
[0129] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0130] Any segment to be analyzed that is defined by the logical relation segment is taken as the target segment to be analyzed on which the logical relation segment depends.
[0131] The logical relationship is used as the dependency relationship label corresponding to the logical relationship word segment.
[0132] Optionally, the segment to be analyzed includes an entity type segment, and the analysis unit 203 is specifically configured to execute:
[0133] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0134] The entity segment constrained by the entity type segment is taken as the target segment to be analyzed on which the entity type segment depends.
[0135] The ontology constraint is used as the dependency relation label corresponding to the entity type segment.
[0136] Optionally, the segment to be analyzed includes an entity segment to be judged, and the analysis unit 203 is specifically configured to execute:
[0137] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0138] The attribute relation segment that needs to be judged for the entity segment to be judged is taken as the target segment to be analyzed on which the entity segment to be judged depends, and the judgment value is taken as the dependency relation label corresponding to the entity segment to be judged.
[0139] In the absence of the attribute relation segment, the entity segment to be judged is taken as the target segment to be analyzed on which the judgment value segment to be judged depends, and the judgment value is taken as the dependency relation tag corresponding to the judgment value segment.
[0140] Optionally, the segment to be analyzed includes aggregated word segments, and the analysis unit 203 is specifically configured to execute:
[0141] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0142] The attribute relation word segment constrained by the aggregated word segment is taken as the target segment to be analyzed on which the aggregated word segment depends;
[0143] The aggregation function is used as the dependency label corresponding to the aggregation term segment.
[0144] Optionally, the segment to be analyzed includes multiple entity segments with a sequential order, and the analysis unit 203 is specifically configured to execute:
[0145] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0146] The entity segment that ranks first in the order of the target entity segment is taken as the target segment to be analyzed, on which the target entity segment depends.
[0147] The order is used as the dependency relation label corresponding to the target entity segment.
[0148] Optionally, the segment to be analyzed may include meaningless segments, and the analysis unit 203 is specifically configured to execute:
[0149] Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed;
[0150] The meaningless segment itself is taken as the target segment to be analyzed, upon which the meaningless segment depends.
[0151] The meaninglessness is used as the dependency relation label corresponding to the meaningless segment.
[0152] As can be seen from the above, the technical solution provided by the embodiments of this disclosure can perform dependency relationship analysis on the segments to be analyzed in the statement to be analyzed based on preset dependency relationship tags, thereby determining the dependency relationship between each segment to be analyzed. The dependency relationship tags can be designed for complex questions. In this way, the semantic analysis method provided by this solution can perform semantic dependency analysis on complex questions, and thus, can realize querying in the graph based on complex questions.
[0153] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0154] Figure 4 This is a block diagram illustrating an electronic device according to an exemplary embodiment.
[0155] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions that can be executed by a processor of an electronic device to perform the above-described method. Optionally, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical audio playback device, etc.
[0156] In an exemplary embodiment, a computer program product is also provided that, when run on a computer, enables the computer to perform the above-described semantic analysis method.
[0157] As can be seen from the above, the technical solution provided by the embodiments of this disclosure can perform dependency relationship analysis on the segments to be analyzed in the statement to be analyzed based on preset dependency relationship tags, thereby determining the dependency relationship between each segment to be analyzed. The dependency relationship tags can be designed for complex questions. In this way, the semantic analysis method provided by this solution can perform semantic dependency analysis on complex questions, and thus, can realize querying in the graph based on complex questions.
[0158] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0159] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0160] This application is described with reference to flowchart illustrations and / or block diagrams of the method, terminal device (system), and computer program product according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0161] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0162] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0163] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0164] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0165] The semantic analysis method, apparatus, electronic device, and storage medium provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A semantic analysis method, characterized in that, include: Obtain the statement to be analyzed; Named entity recognition is performed on the statement to be analyzed to obtain multiple segments to be analyzed. Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed to determine the target statement to be analyzed and the corresponding dependency relation labels, so as to realize the semantic analysis of the statement to be analyzed. The dependency parsing model is obtained based on the semantic dependency analysis of the training data, and the training data is pre-labeled according to the dependency relation labels. The dependency relationship tags include any one or more of the following: Root, attribute relationship, constraint value, constraint type, logical relationship, ontology constraint, judgment value, aggregate function, order, and meaningless; The step of using a dependency parsing model to perform semantic dependency analysis on the statement to be analyzed, and determining the target statement to be analyzed and its corresponding dependency relation tags, includes: Add a root segment before the statement to be analyzed to obtain the target statement; The target statement is input into the dependency parsing model, and semantic dependency parsing is performed on the target statement; The main entity segment is used as the target segment to be analyzed on which the root segment depends, and the root is used as the dependency relation label corresponding to the root segment; or, the root segment is used as the target segment to be analyzed on which the main entity segment depends, and the root is used as the dependency relation label corresponding to the main entity segment. If there is no main entity segment in the target statement, the root segment itself is taken as the target segment to be analyzed, and the root is taken as the dependency relation label corresponding to the root segment. Among them, the attribute relationship points to the associated entity, or the root acts as an unknown entity.
2. The method according to claim 1, characterized in that, The segment to be analyzed includes attribute relation segments. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes: Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed; The entity segment associated with the attribute relation segment is taken as the target segment to be analyzed on which the attribute relation segment depends. In the absence of an entity segment associated with the attribute relation segment, the root segment is taken as the target segment to be analyzed on which the attribute relation segment depends. The attribute relationship is determined as the dependency relationship label corresponding to the attribute relationship term segment.
3. The method according to claim 1, characterized in that, The segment to be analyzed includes a constraint value segment. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation labels, includes: Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed; The attribute relation segment constrained by the constraint value segment is taken as the target segment to be analyzed on which the constraint value segment depends. In the absence of an attribute relation segment constrained by the constraint value segment, the entity segment constrained by the constraint value segment is taken as the target segment to be analyzed on which the constraint value segment depends. The constraint value is used as the dependency label corresponding to the constraint value segment.
4. The method according to claim 1, characterized in that, The segment to be analyzed includes constraint-type word segments. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation labels, includes: Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed; The constraint value segment associated with the constraint type word segment is taken as the target segment to be analyzed on which the constraint type word segment depends; In the absence of a constraint value segment associated with the constraint type segment, the attribute relation segment associated with the constraint type segment is taken as the target segment to be analyzed on which the constraint type segment depends. The constraint type is used as the dependency label corresponding to the constraint value segment.
5. The method according to claim 1, characterized in that, The segment to be analyzed includes logical relation segments. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes: Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed; Any segment to be analyzed that is defined by the logical relation segment is taken as the target segment to be analyzed on which the logical relation segment depends. The logical relationship is used as the dependency relationship label corresponding to the logical relationship word segment.
6. The method according to claim 1, characterized in that, The segment to be analyzed includes entity type segments. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes: Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed; The entity segment constrained by the entity type segment is taken as the target segment to be analyzed on which the entity type segment depends. The ontology constraint is used as the dependency relation label corresponding to the entity type segment.
7. The method according to claim 1, characterized in that, The segment to be analyzed includes an entity segment to be judged. The step of using a dependency parsing model to perform semantic dependency analysis on the segment to be analyzed, and determining the target segment to be analyzed and its corresponding dependency relation tags, includes: Using a dependency parsing model, semantic dependency analysis is performed on the statement to be analyzed; The attribute relation segment that needs to be judged for the entity segment to be judged is taken as the target segment to be analyzed on which the entity segment to be judged depends, and the judgment value is taken as the dependency relation label corresponding to the entity segment to be judged. In the absence of the attribute relation segment, the entity segment to be judged is taken as the target segment to be analyzed on which the judgment value segment to be judged depends, and the judgment value is taken as the dependency relation tag corresponding to the judgment value segment.
8. A semantic analysis device, characterized in that, include: The acquisition unit is configured to execute the acquisition of statements to be analyzed. The identification unit is configured to perform named entity recognition on the statement to be analyzed, thereby obtaining multiple segments to be analyzed. The analysis unit is configured to perform semantic dependency analysis on the statement to be analyzed using a dependency parsing model, and determine the target statement to be analyzed and the corresponding dependency relation labels on which the statement to be analyzed depends, so as to realize the semantic analysis of the statement to be analyzed. The dependency parsing model is obtained based on the semantic dependency analysis of the training data, and the training data is pre-labeled according to the dependency relation labels. The dependency relationship tags include, but are not limited to: Root, attribute relationship, constraint value, constraint type, logical relationship, ontology constraint, judgment value, aggregate function, order, and meaningless; The segment to be analyzed includes a root segment, and the analysis unit is specifically configured to execute: Add a root segment before the statement to be analyzed to obtain the target statement; The target statement is input into the dependency parsing model, and semantic dependency parsing is performed on the target statement; The main entity segment is used as the target segment to be analyzed on which the root segment depends, and the root is used as the dependency relation label corresponding to the root segment; or, the root segment is used as the target segment to be analyzed on which the main entity segment depends, and the root is used as the dependency relation label corresponding to the main entity segment. If there is no main entity segment in the target statement, the root segment itself is taken as the target segment to be analyzed, and the root is taken as the dependency relation label corresponding to the root segment. Among them, the attribute relation words point to the associated entity, or the unknown entity that the root acts as.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the semantic analysis method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Answer providing method and apparatus
CN106919655A