# US 2021/0342348 A1 · Method for parsing query, electronic device and readable storage medium

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0342348 A1
- Document ID: US20210342348A1
- Status: Published application
- Kind: A1
- Application number: 16/950,066
- Filed: 2020-11-17
- Published: 2021-11-04
- Earliest claimed: 2020-04-29
- Assignees: Baidu Online Network Technology (Beijing) Co., Ltd.
- Applicants: Baidu Online Network Technology (Beijing) Co., Ltd
- Inventors: Xiaonan HE; Qiang JU; Jian XIE
- Web page: https://patentgrep.com/patent/US20210342348A1

## CPC

- G06F 16/24522: {Translation of natural language queries to structured queries}
- G06F 16/2246: {Trees, e.g. B+trees}
- G06F 16/243: {Natural language query formulation}
- G06F 16/287: {Visualization; Browsing}
- G06F 16/288: {Entity relationship models}
- Y02D 10/00: Energy efficient computing, e.g. low power processors, power management or thermal management
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- Y02D: CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE

## Abstract

A method for parsing a query, an electronic device and a readable storage medium, which relate to the field of natural language processing technologies, are disclosed. According to some embodiments, the method includes: acquiring the query input by a user; constructing a syntactic dependency tree of the query; matching the syntactic dependency tree of the query with syntactic dependency trees of preset templates, and determining a target template according to the matching result; and marking a slot operator of a slot in the query using the target template, and the marked slot operator represents a logical relationship applied to the slot in the query. With the technical solution, the logical relationship applied to the slot in the query may be acquired, and the accuracy of query parse may be improved.

## Claims

### Claim 1

A method for parsing a query, comprising:
acquiring the query input by a user;
constructing a syntactic dependency tree of the query;
matching the syntactic dependency tree of the query with syntactic dependency trees of preset templates, and determining a target template according to the matching result; and
marking a slot operator of a slot in the query using the target template, wherein the marked slot operator represents a logical relationship applied to the slot in the query.

### Claim 2 (depends on 1)

The method according to claim 1, further comprising: before the syntactic dependency tree of the query is constructed,
determining whether the query meets a preset requirement; and
in response to determining that the query meets the preset requirement, continuing to execute the operation of constructing the syntactic dependency tree of the query, and
in response to determining that the query does not meet the preset requirement, parsing the query directly.

### Claim 3 (depends on 1)

The method according to claim 1, wherein the constructing a syntactic dependency tree of the query comprises:
performing word segmentation on the query to acquire semantic elements in the query and the part of speech of each semantic element;
performing syntactic dependency analysis on the semantic elements in the query to determine the dependency relationships between the semantic elements; and
constructing the syntactic dependency tree of the query according to the semantic elements in the query, the part of speech of each semantic element and the dependency relationships between the semantic elements.

### Claim 4 (depends on 1)

The method according to claim 1, wherein the matching the syntactic dependency tree of the query with syntactic dependency trees of preset templates and determining a target template according to the matching result comprises:
acquiring a query tree diagram according to the syntactic dependency tree of the query, and acquiring a template tree diagram of each template according to the syntactic dependency tree of each preset template; and
after the template tree diagram identical to the query tree diagram is determined, using the preset template corresponding to the determined template tree diagram as the target template.

### Claim 5 (depends on 4)

The method according to claim 4, wherein the acquired query tree diagram comprises at least one of: an overall tree diagram of the syntactic dependency tree corresponding to the query, or a subtree diagram of a subtree in the syntactic dependency tree corresponding to the query.

### Claim 6 (depends on 1)

The method according to claim 1, further comprising: after the target template is determined according to the matching result,
ranking the target templates with the same names according to the confidence thereof; and
according to the ranking result, reserving the first target templates under different names.

### Claim 7 (depends on 1)

The method according to claim 1, wherein the marking a slot operator of a slot in the query using the target template comprises:
making nodes and sides between the nodes in the syntactic dependency tree of the target template to correspond respectively to nodes and sides between the nodes in the syntactic dependency tree of the query; and
acquiring an operator of each node in the syntactic dependency tree of the target template as the slot operator of the slot corresponding to the same node in the syntactic dependency tree of the query.

### Claim 8

An electronic device, comprising:
at least one processor; and
a memory connected with the at least one processor communicatively;
wherein the memory stores instructions executable by the at least one processor to cause the at least one processor to perform a method for parsing a query, which comprises:
acquiring the query input by a user;
constructing a syntactic dependency tree of the query;
matching the syntactic dependency tree of the query with syntactic dependency trees of preset templates, and determining a target template according to the matching result; and
marking a slot operator of a slot in the query using the target template, wherein the marked slot operator represents a logical relationship applied to the slot in the query.

### Claim 9 (depends on 8)

The electronic device according to claim 8, wherein the method further comprises: before the syntactic dependency tree of the query is constructed,
determining whether the query meets a preset requirement; and
in response to determining that the query meets the preset requirement, continuing to execute the operation of constructing the syntactic dependency tree of the query, and
in response to determining that the query does not meet the preset requirement, parsing the query directly.

### Claim 10 (depends on 8)

The electronic device according to claim 8, wherein the constructing a syntactic dependency tree of the query comprises:
performing word segmentation on the query to acquire semantic elements in the query and the part of speech of each semantic element;
performing syntactic dependency analysis on the semantic elements in the query to determine the dependency relationships between the semantic elements; and
constructing the syntactic dependency tree of the query according to the semantic elements in the query, the part of speech of each semantic element and the dependency relationships between the semantic elements.

### Claim 11 (depends on 8)

The electronic device according to claim 8, wherein the matching the syntactic dependency tree of the query with syntactic dependency trees of preset templates and determining a target template according to the matching result comprises:
acquiring a query tree diagram according to the syntactic dependency tree of the query, and acquiring a template tree diagram of each template according to the syntactic dependency tree of each preset template; and
after the template tree diagram identical to the query tree diagram is determined, using the preset template corresponding to the determined template tree diagram as the target template.

### Claim 12 (depends on 11)

The electronic device according to claim 11, wherein the acquired query tree diagram comprises at least one of: an overall tree diagram of the syntactic dependency tree corresponding to the query, or a subtree diagram of a subtree in the syntactic dependency tree corresponding to the query.

### Claim 13 (depends on 8)

The electronic device according to claim 8, wherein the method further comprises: after the target template is determined according to the matching result,
ranking the target templates with the same names according to the confidence thereof; and
according to the ranking result, reserving the first target templates under different names.

### Claim 14 (depends on 1)

The electronic device according to claim 1, wherein the marking a slot operator of a slot in the query using the target template comprises:
making nodes and sides between the nodes in the syntactic dependency tree of the target template to correspond respectively to nodes and sides between the nodes in the syntactic dependency tree of the query; and
acquiring an operator of each node in the syntactic dependency tree of the target template as the slot operator of the slot corresponding to the same node in the syntactic dependency tree of the query.

### Claim 15

A non-transitory computer readable storage medium with computer instructions stored thereon, wherein the computer instructions are used for causing a computer to perform a method for parsing a query, which comprises:
acquiring the query input by a user;
constructing a syntactic dependency tree of the query;
matching the syntactic dependency tree of the query with syntactic dependency trees of preset templates, and determining a target template according to the matching result; and
marking a slot operator of a slot in the query using the target template, wherein the marked slot operator represents a logical relationship applied to the slot in the query.

### Claim 16 (depends on 15)

The non-transitory computer readable storage medium according to claim 15, wherein the method further comprises: before the syntactic dependency tree of the query is constructed,
determining whether the query meets a preset requirement; and
in response to determining that the query meets the preset requirement, continuing to execute the operation of constructing the syntactic dependency tree of the query, and
in response to determining that the query does not meet the preset requirement, parsing the query directly.

### Claim 17 (depends on 15)

The non-transitory computer readable storage medium according to claim 15, wherein the constructing a syntactic dependency tree of the query comprises:
performing word segmentation on the query to acquire semantic elements in the query and the part of speech of each semantic element;
performing syntactic dependency analysis on the semantic elements in the query to determine the dependency relationships between the semantic elements; and
constructing the syntactic dependency tree of the query according to the semantic elements in the query, the part of speech of each semantic element and the dependency relationships between the semantic elements.

### Claim 18 (depends on 15)

The non-transitory computer readable storage medium according to claim 15, wherein the matching the syntactic dependency tree of the query with syntactic dependency trees of preset templates and determining a target template according to the matching result comprises:
acquiring a query tree diagram according to the syntactic dependency tree of the query, and acquiring a template tree diagram of each template according to the syntactic dependency tree of each preset template; and
after the template tree diagram identical to the query tree diagram is determined, using the preset template corresponding to the determined template tree diagram as the target template.

### Claim 19 (depends on 18)

The non-transitory computer readable storage medium according to claim 18, wherein the acquired query tree diagram comprises at least one of: an overall tree diagram of the syntactic dependency tree corresponding to the query, or a subtree diagram of a subtree in the syntactic dependency tree corresponding to the query.

### Claim 20 (depends on 15)

The non-transitory computer readable storage medium according to claim 15, wherein the method further comprises: after the target template is determined according to the matching result,
ranking the target templates with the same names according to the confidence thereof; and
according to the ranking result, reserving the first target templates under different names.
