CN111339246A - Query statement template generation method, device, equipment and medium - Google Patents

Query statement template generation method, device, equipment and medium Download PDF

Info

Publication number
CN111339246A
CN111339246A CN202010085006.9A CN202010085006A CN111339246A CN 111339246 A CN111339246 A CN 111339246A CN 202010085006 A CN202010085006 A CN 202010085006A CN 111339246 A CN111339246 A CN 111339246A
Authority
CN
China
Prior art keywords
query
question
statement
query statement
template
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.)
Granted
Application number
CN202010085006.9A
Other languages
Chinese (zh)
Other versions
CN111339246B (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.)
Tencent Cloud Computing Beijing Co Ltd
Original Assignee
Tencent Cloud Computing Beijing 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 Tencent Cloud Computing Beijing Co Ltd filed Critical Tencent Cloud Computing Beijing Co Ltd
Priority to CN202010085006.9A priority Critical patent/CN111339246B/en
Publication of CN111339246A publication Critical patent/CN111339246A/en
Application granted granted Critical
Publication of CN111339246B publication Critical patent/CN111339246B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/36Creation of semantic tools, e.g. ontology or thesauri
    • G06F16/367Ontology

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Animal Behavior & Ethology (AREA)
  • Artificial Intelligence (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a method, a device, equipment and a medium for generating a query statement template, and relates to the field of knowledge graphs. The method comprises the following steps: acquiring a configuration file, wherein the configuration file comprises an entity type and a question mode, and the question mode is described by adopting a human-readable query description language; generating a query statement template according to the entity type and the query description language; and storing the query statement template. The query statement template is generated through the acquired configuration file, so that the corresponding query statement template can be determined according to the input statement, the query statement can be further determined, and the answer corresponding to the question is acquired from the knowledge map database.

Description

Query statement template generation method, device, equipment and medium
Technical Field
The present application relates to the field of knowledge graph, and in particular, to a method, an apparatus, a device, and a medium for generating a query statement template.
Background
In the knowledge graph in the vertical field, answers corresponding to query sentences need to be determined according to query sentence templates corresponding to different fields.
In the related art, a query sentence template of a vertical domain is set in a knowledge-graph question-answering system of the domain. When a user inputs a question in a natural language form, the question is determined as a query statement in a machine language form according to a query statement template, so that the knowledge graph question-answering system in the vertical field can acquire an answer corresponding to the question from a knowledge graph in the field. When different vertical domains are migrated, the query statement template needs to be changed. For example, in the financial field, a query statement template a exists in the knowledge-graph question-answering system in the vertical field; when the knowledge-graph question-answering system in the vertical field is applied to the music field, a manager of the knowledge-graph question-answering system in the vertical field needs to change the query sentence template a into a query sentence template b corresponding to the music field.
Based on the above situation, for the question-answering events in different vertical fields, the administrator of the knowledge-graph question-answering system in the vertical field needs to modify or rewrite the query statement template, or even modify the code, so as to obtain a proper query statement template, and the modification process is troublesome.
Disclosure of Invention
The embodiment of the application provides a method, a device, equipment and a medium for generating a query statement template, which are used for simplifying the process of changing the query statement template without modifying or rewriting the query statement template by managers in question and answer events in different fields, and do not relate to code modification of the managers, and the technical scheme is as follows:
according to an aspect of the present application, there is provided a method for generating a query statement template, the method including:
acquiring a configuration file, wherein the configuration file comprises an entity type and a question mode, and the question mode is described by adopting a human-readable query description language;
generating a query statement template according to the entity type and the query description language;
and storing the query statement template.
According to another aspect of the present application, there is provided a query statement template generation apparatus, including:
the system comprises an acquisition module, a query module and a query module, wherein the acquisition module is used for acquiring a configuration file, the configuration file comprises an entity type and a question mode, and the question mode is described by adopting a human-readable query description language;
the generating module is used for generating a query statement template according to the entity type and the query description language;
and the storage module is used for storing the query statement template.
According to another aspect of the present application, there is provided a computer device comprising a processor and a memory, the memory having stored therein at least one instruction, at least one program, set of codes, or set of instructions, which is loaded and executed by the processor to implement the method of generating a query statement template as described above.
According to another aspect of the present application, there is provided a computer-readable storage medium having at least one instruction, at least one program, a set of codes, or a set of instructions stored therein, which is loaded and executed by a processor to implement the method for generating a query statement template described above.
The beneficial effects brought by the technical scheme provided by the embodiment of the application at least comprise:
the query statement template is generated through the acquired configuration file, so that the corresponding query statement template can be determined according to the input statement, the query statement can be further determined, and the corresponding response information can be acquired from the knowledge map database.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a block diagram of a vertical domain knowledge-graph question-and-answer system according to an exemplary embodiment of the present application;
FIG. 2 is a block diagram of a computer system provided in an exemplary embodiment of the present application;
FIG. 3 is a flowchart of a method for generating a query statement template according to an exemplary embodiment of the present application;
FIG. 4 is a flowchart of a method for generating a query statement template according to another exemplary embodiment of the present application;
FIG. 5 is a schematic illustration of a configuration file provided by an exemplary embodiment of the present application;
FIG. 6 is a flowchart of a method for determining a target query statement template provided by an exemplary embodiment of the present application;
FIG. 7 is a schematic interface diagram of a vertical domain knowledge-graph question-and-answer system provided in an exemplary embodiment of the present application;
FIG. 8 is a flowchart of a method for initializing a vertical domain knowledge-graph question-answering system according to an exemplary embodiment of the present application;
FIG. 9 is a block diagram of a vertical domain knowledge-graph question-answering system according to another exemplary embodiment of the present application;
FIG. 10 is a schematic diagram of an interface of a vertical domain knowledge-graph question-answering system on a computer, provided by an exemplary embodiment of the present application;
FIG. 11 is a schematic diagram of an interface of a vertical domain knowledge-graph question-answering system on a smartphone, provided by an exemplary embodiment of the present application;
FIG. 12 is a block diagram illustrating an apparatus for generating a query statement template according to an exemplary embodiment of the present application;
FIG. 13 is a block diagram of a server provided in an exemplary embodiment of the present application;
fig. 14 is a schematic structural diagram of a computer device according to an exemplary embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
First, terms related to embodiments of the present application will be described:
knowledge Graph (Knowledge Graph): is a graph structure composed of entities and entity relations as basic units. Based on the knowledge of the graph structure, correct answers are obtained through the means of retrieval, matching or reasoning and the like in the constructed structured knowledge graph by analyzing the natural language of the user. A knowledge graph is used to describe various entities and concepts existing in the real world and relationships between them, for example, a person is an entity, the person has attributes of age, height, weight, etc. (i.e., attributes of the entity), and the relationship between the person and other people is a friend or a colleague (i.e., relationships between the entities).
Graph database: the method refers to storing data by using a graph, and belongs to a data structure mode for storing data. For example, Neo4j is a graph database, in which a graph is composed of vertices (Vertex), edges (Edge), and properties (Property), the vertices being named nodes, the edges being named relationships, and each node and relationship corresponding to one or more properties. The graph database in the embodiment of the application is a database constructed based on a knowledge graph.
Regular Expression (Regulation Expression): also named regular expressions, are used to retrieve text that conforms to the rules. Regular expressions can combine characters and combinations of characters into a regular string that is used to express a filtering logic for the string.
Natural Language Processing (NLP): the computer receives the input of the user in the form of natural language, and internally processes a series of operations such as processing, calculation and the like through an algorithm defined by the user so as to simulate the understanding of the user to the natural language and return a result expected by the user.
Query description language: is an informal language similar to the english language used to describe the structural diagrams. In the embodiment of the present application, a query description language readable by human is used to describe the question pattern in the configuration file, for example, the query description language is: p publication time, p represents the entity attribute of the questioning-related entity.
Entity (Entity): the object is distinguished from other objects in the real world, and the entity can be a specific object, such as a person, a place name, a company, a telephone, an animal, weather, a tool, a terminal and the like, or time, such as time corresponding to a basketball game. The set of entities having a common element is an entity type, such as song A, song B, and song C for which music is the corresponding entity type.
Entity attribute (attribute): the attribute is an attribute, each attribute has a value range, and the type can be integer type, character string type, for example, a student (being an entity) has attributes such as school number, age, gender, etc., and the corresponding value range is any one of character type, integer type, character string type.
The knowledge graph is generally divided into a knowledge graph in the general field and a knowledge graph in the vertical field, and the corresponding knowledge graph question-answer systems of the knowledge graph question-answer system and the knowledge graph question-answer system in the vertical field are respectively the knowledge graph question-answer system in the general field and the knowledge graph question-answer system in the vertical field. In the related art, a knowledge graph Question and answer system in a general field is used for performing Question and answer tasks on a large number of open-field public Data sets, such as a Data link Data set Question and answer system (QALD) or a standard Data set (WebQuestions) based on the knowledge graph Question and answer system, but the current mode only supports some simpler Question and answer modes, or the query result accuracy rate is lower and the query speed is slower under the condition of performing complex query, and the actual requirement cannot be met. In addition, the two types of knowledge graph question-answering systems generate Sqarql sentences, and in an actual question-answering event, various graph databases need to be used, and Cypher query sentences such as Neoj4 graph databases need to be generated. In an exemplary application process, the knowledge-graph question-answering system also needs to have multi-turn conversation capability, that is, in the case that the semantics of the query statement is unknown, the intent clarification is performed, so as to determine the response information corresponding to the query statement. In the related art, the problems are solved by a large number of customized query statement templates, and in the knowledge-graph question-answering system in the vertical field, because the professional knowledge span related to each vertical field is large, the query statement templates need to be customized in the knowledge-graph question-answering system according to different vertical fields or different application scenes to solve the problems.
The embodiment of the application provides a method for generating a query statement template, and the method can construct a knowledge-graph question-answering system (hereinafter referred to as a knowledge-graph question-answering system) of the vertical field only by providing corresponding configuration files for different vertical fields or different application scenes by a user, and the knowledge-graph question-answering system can automatically generate the query statement template corresponding to the knowledge graph suitable for the vertical field according to the configuration files. Meanwhile, the knowledge-graph question-answering system can perform multiple rounds of conversations with the user, has the understanding capability of context, and does not need the user to change the query sentence template or change the code.
Fig. 1 illustrates a vertical domain knowledge-graph question-answering system 100 provided by an exemplary embodiment of the present application, the knowledge-graph question-answering system 100 comprising: a query statement template generating module 101, a statement preprocessing and analyzing module 102, an initial answer obtaining module 103, a multi-turn dialogue management module 104 and a returned result processing module 105.
The query statement template generation module 101 reads a configuration file provided by a user, and generates a mapping relationship between the question pattern and the query statement template according to the configuration file. Alternatively, the user may be a manager of the knowledge-graph question-and-answer system 100, or a manager of a graph database, or a code writer with associated expertise, or a general user. The configuration file comprises at least a group of entity types and a question mode, wherein the question mode is described by adopting a human-readable query description language, and the query description language is informal and is similar to a language of an English structure and is used for describing a query operation performed on a structure diagram. Each set of entity types and question patterns is used to generate a query statement template.
The statement preprocessing and analyzing module 102 acquires an input statement, analyzes the input statement, and sends an analysis result to the answer initial acquisition module 103, where the analysis result includes: the method comprises the following steps of inputting entity types and question modes included in a sentence, wherein the question modes comprise at least one of the following modes: the method comprises the steps of questioning entity attributes and questioning the relationship between at least two entities.
The initial answer obtaining module 103 obtains a query statement template from the query statement template generating module 101 according to the analysis result, converts the input statement into a query statement in a machine language form according to the query statement template, and sends the query statement to the returned result processing module 105, and the returned result processing module 105 queries a corresponding answer from the knowledge graph database according to the query statement and feeds the answer back to the user.
If the statement information input by the user is incomplete, for example, the entity type is lacking, and the initial answer obtaining module 103 cannot obtain the query statement template from the query statement template generating module 101, the analysis result is sent to the multi-round dialog management module 104. The multi-turn dialogue management module 104 determines a multi-turn dialogue mode, such as a sub-picture memory mode, a sub-picture skip mode, a multi-turn question-back mode, a content supplement mode, etc., for the analysis result. The multi-turn dialogue management module 104 may obtain a corresponding query statement template through a multi-turn dialogue mode in combination with the context of the input statement, and send the obtained query statement template to the answer initial obtaining module 103. The initial answer obtaining module 103 generates a query statement according to the obtained query statement template and the analysis result, sends the query statement to the return result processing module 105, and the return result processing module 105 queries a corresponding answer from the knowledge graph database according to the query statement and feeds the answer back to the user.
Aiming at different application scenes or different vertical fields, a user only needs to submit a corresponding configuration file to the knowledge-graph question-answering system 100, the knowledge-graph question-answering system 100 can analyze statements according to the configuration file, a multi-turn dialogue management module 104 in the knowledge-graph question-answering system 100 has comprehensibility on input statements of multi-turn dialogue, the meaning of the current statement can be analyzed by combining the context of the input statements, and a corresponding query statement template is determined, so that the knowledge-graph question-answering system 100 is suitable for a question-answering interaction mode under various application scenes, and the user does not need to repeatedly modify the query statement template aiming at different application scenes.
Fig. 2 shows a schematic structural diagram of a computer system provided in an exemplary embodiment of the present application. The computer system 110 includes: a terminal 120 and a server 140.
The terminal 120 is installed and operated with a platform client supporting a knowledge-graph question-answering system, the platform client may be any one of a corresponding application program, an applet, a web page and an information interaction platform (such as a public number), the terminal 120 is a terminal used by a user, the user performs at least one round of question-answering events in the platform client of the knowledge-graph question-answering system on the terminal 120, one round of question-answering events refers to a round of interaction between the user and the platform client, starting with a question provided by the user, and counting one round of a process of giving an answer to the question by the platform client as ending the corresponding process. Schematically, the user raised the question "what are nice to have in kunming? "the answer given by the platform client is" crossing a bridge rice noodle, flower cake, bait block ", and then a round of question-answering event is finished. The user can put forward a question by inputting characters, voice, pictures, videos and the like to the platform client, and the platform client can also provide answers to the question by the characters, voice, pictures, videos and the like.
The terminal 120 is connected to the server 140 through a wireless network or a wired network.
The server 140 includes at least one of a server, a plurality of servers, a cloud computing platform, and a virtualization center. Illustratively, the server 140 includes a processor 144 and a memory 142, the memory 142 in turn including an acquisition module 1421, an analysis module 1422, and a pre-processing module 1423. The server 140 is configured to provide background services, such as a storage service of a historical query statement, a preprocessing service of an input statement, a generation service of a query statement template, and the like, for a platform client supporting the knowledge-graph question-answering system. Alternatively, the server 140 undertakes primary computational tasks and the terminal 120 undertakes secondary computational tasks; alternatively, the server 140 undertakes the secondary computing work and the terminal 120 undertakes the primary computing work; alternatively, the server 140 and the terminal 120 employ a distributed computing architecture for collaborative computing.
Optionally, the terminal 120 generally refers to one of a plurality of terminals, the number of platform clients supporting the knowledge-graph question-answering system on the terminal 120 may be one or more, this embodiment is illustrated by the terminal 120, and the device types of the terminal 120 include: at least one of a smartphone, a tablet, an e-book reader, an MP3 player, an MP4 player, a laptop portable computer, and a desktop computer. The following embodiments are illustrated with the terminal comprising a smartphone.
Those skilled in the art will appreciate that the number of terminals may be greater. Such as tens or hundreds of such terminals, or even more. The number of terminals and the type of the device are not limited in the embodiments of the present application.
Fig. 3 illustrates a method for generating a query statement template, which is provided by an exemplary embodiment of the present application and is applied in the server 140 in the computer system 100 shown in fig. 2 or in other computer systems, and the method includes the following steps:
step 301, obtaining a configuration file, where the configuration file includes an entity type and a question mode, and the question mode is described by using a human-readable query description language.
The knowledge-graph question-answering system obtains configuration files, wherein the configuration files are provided by relevant personnel for constructing the knowledge-graph question-answering system, such as management personnel, maintenance personnel, or ordinary users, or default configuration in the knowledge-graph system.
Optionally, the providing manner of the configuration file includes: the user uploads a corresponding electronic document to a platform client corresponding to the knowledge-graph question-answering system, or the user inputs related content in a configuration file at the platform client, or the user provides indicating information (such as a two-dimensional code) of the configuration file, and the computer equipment acquires the configuration file by identifying the indicating information (such as scanning the two-dimensional code). The platform client can be an application program, or an applet program running in dependence on a host program, or an information interaction platform (such as a public number), or a webpage.
An entity type is a set of entities that may appear in an input sentence, such as "how weather in Shanghai city? "Shanghai" is the entity in the input sentence, and Shanghai is a place name, and the place name is the entity type corresponding to Shanghai.
Alternatively, the user may provide the configuration file to the platform client at the prompt of the platform client, the configuration file being an electronic document including at least one of a spreadsheet and an electronic text. Illustratively, an electronic document includes a spreadsheet for writing entity types and question patterns using a human-readable query description language and electronic text for listing entities or entity types that may be present in an input sentence.
Optionally, the question mode includes at least one of an attribute question mode and a relationship question mode: the attribute questioning mode includes a questioning method for questioning attributes of entities, and the relationship questioning mode includes a method for questioning the relationship between at least two entities.
The entity attribute refers to one of a plurality of characteristics corresponding to the entity, and the question sentences for the same entity attribute can be the same or different, for example, "the age of Xiaoming is the age of several years" or "how many the birth year of Xiaoming" is to ask the age of Xiaoming, "what the sex of Xiaoming is" or "is that the baby is a girl" is to ask the sex of Xiaoming.
Relationships are relationships that characterize the relationship between different entities, for example, small a and small B belong to a colleague relationship, small ming and big ming belong to a father-son relationship, and kunming city is the province of Yunnan province.
In one example, the questioning mode includes an attribute questioning mode, such as questioning the release time (entity attribute) of music (entity type), and the profile may be written as "p belongs to the release time". The variable p is combined with the query operation, wherein "p" represents the entity type of the query and "issue time" represents the operation of the query issue time.
In another example, the questioning mode includes a relational questioning mode, such as questioning the ranking of singer A (entity type) on a music chart (relationship between entities), and the profile may be written as a Limit ranking. The variable Limit is combined with the query operation, wherein the Limit represents the relationship between at least two entities of the query, and the rank ordering represents the operation of the rank ordering of the query.
It will be appreciated that the question pattern may be self-defined by the user providing the profile, and that the user may represent the question pattern in any human-readable language. As mentioned above, to ask a question of the singer's a ranking on the music leaderboard, the configuration file can also be written as: limit singers & p rank order. "Limit singer" means querying the relationship between at least two singers and "p rankings" means querying the rankings.
Step 302, generating a query statement template by the entity type and the query description language.
Alternatively, the query statement template is typically in a human-unreadable machine language format, e.g., the query statement template is in a database query language format, and is represented in a language that is in a non-human-readable format.
In one example, the knowledge-graph question-and-answer system generates a query statement template 1 from entity type 1 and question mode 1 (asking for entity attributes); in another example, the knowledge-graph question-and-answer system generates a query statement template 2 from entity type 2 and question mode 2 (asking for relationships between entity type 1 and entity type 2).
Step 303, store the query statement template.
The knowledge-graph question-answering system stores the query statement template in a mode of associating the entity type with the query statement template, or stores the query statement template in a mode of associating the query statement template in a question mode, or associates the query statement template in a mode of associating the entity type with the question mode. In one example, the query statement template is weather corresponding to a place name, and the query statement template is stored in an associated questioning mode. When the input sentences of the user correspond to the question mode related to the weather, the knowledge-graph question-answering system calls the query sentence template.
In summary, in the method provided in this embodiment, the query statement template is generated by the obtained configuration file, so that the corresponding query statement template can be determined according to the input statement, and therefore, only the user needs to provide the corresponding configuration file in different scenarios, the query statement template can be automatically generated and question-answer interaction can be realized in different application scenarios, and the user does not need to understand the query language of the database or write the query statement template, nor needs to be familiar with the code language.
Fig. 4 is a flowchart illustrating a method for generating a query statement template according to another exemplary embodiment of the present application, which is applied in the server 140 in the computer system shown in fig. 2 or in other computer systems, and includes the following steps:
the method comprises two stages: the knowledge-graph question-answering system generates a query statement template and acquires the query statement template. Two stages will be described below.
First, the knowledge-graph question-answering system generates the inquiry sentence template.
Step 401, obtaining a configuration file, where the configuration file includes an entity type and a question mode, and the question mode is described by using a human-readable query description language.
Schematically, the configuration file is described by taking as an example a file set for a music field, and the configuration file is described with reference to (a) of fig. 5. Illustratively, the configuration file includes four fields, one for each column.
The first field is the corresponding entity type in the input sentence, such as music (song title), singer. Optionally, the first field includes one or more entity types, and the plurality of entity types are divided by a separation symbol "| |", such as music | | | rank, singer | | | rank | | | type (referring to the type to which singer belongs, such as rock, pop, and the like).
The second field is a corresponding question mode in the input sentence, the question mode refers to a mode of asking questions about entity types in the input sentence, and the question mode in the embodiment is described by a human-readable query description language. The questioning mode comprises at least one of an attribute questioning mode and an entity questioning mode, the attribute questioning mode is used for questioning the attributes of the entities, and the relationship questioning mode is used for questioning the relationship between at least two entities. Illustratively, the attribute questioning mode is to ask a question about the release time (entity attribute) of a song (entity type), and the relationship questioning mode is to ask a question about the ranking (relationship between multiple entities) of a singer a (entity type) on a ranking list.
The sentence input by the user and the question mode are divided by a separation symbol "|", the left side of the separation symbol corresponds to a phrase or a keyword contained in the input sentence of the user, the right side of the separation symbol corresponds to the question mode, and the question mode is described by a human-readable query description language.
Alternatively, in the second field, the content to the left of the separation symbol "|" may be listed in the third field.
In the above question mode, the question mode includes the following forms:
the questioning mode represented by beginning with p is to ask an entity attribute of an entity type, for example, p issue time represents an attribute questioning mode in which an issue time (attribute) of music (entity type) is asked.
The tran starts to represent the entity type that specifies the intermediate jump (the entity type is located after the "###") to assist in generating complex query statements, e.g., "tran practical # # Singer" indicates which songs (multiple entity relationships, relationships between singers and multiple songs) are sung by a Singer (entity type), requiring the specification of the intermediate jump to the Singer (entity type).
The number of entity types in the query sentence is questioned with a count beginning representation, such as "CountMusic" representing questioning the number of songs (entity types) sung by a singer (entity attributes). Optionally, when asking the number of songs sung by the Singer, the configuration file may be written as "tran countmusic # # Singer" to indicate that the number of songs (entity type) is queried, and it is necessary to specify a jump to the Singer (entity type).
The beginning of the limit represents that the entity is sorted according to certain entity attribute of the entity type, the ranking of the corresponding entity type in the input statement under the sorting is represented by 'limit music & & p heat & level', and the ranking (the relation among a plurality of entities) of the music in the heat ranking is asked.
The rank head represents an entity attribute sorted by entity type, and the top N entities (N is a positive integer) under the sorting, such as "rank music & & p popularity & sort" represents a music ranking by popularity and the music type (relationship between a plurality of entities) whose popularity is the top 10 is asked under the popularity ranking.
Sorting is carried out by taking select as a starting representative according to certain entity attributes of the entity types, M entity types (M is a positive integer) are continuously taken from the Nth entity type in the sorting (N is a positive integer), for example, the selection music & & p heat & Level represents the music sorting according to the heat of the music, and the music (the relationship among a plurality of entities) with the heat sorting from the 5 th to the 10 th names is asked.
Ordering according to certain entity attributes of the entity types is represented by beginning with extract, a certain ordering interval where the entity types are located is taken under the ordering, for example, "extract music & & p heat & Level" represents ordering according to the heat of music, and music (such as song names) in an interval (relationship between entities) with the heat value of 100-200 is asked under the heat ordering.
The third field is an optional field and is used for representing a matching mode for matching the input sentence with the question pattern. Optionally. The matching mode comprises at least one of a keyword, a regular expression and a question pattern recognition model.
In one example, the third column of the table in FIG. 5 illustrates matching the questioning patterns with a regular expression, such as: (gender is male), and when the question mode of the input sentence is in accordance with the regular expression, the question mode corresponding to the input sentence is to ask the gender (entity attribute) of the person (entity type). In another example, the question pattern may also be matched by keywords, for example, a weather-related keyword is included in the input sentence, and the question pattern of the input sentence is to question weather (attribute) of a place name (entity type). In another example, the question pattern in the input sentence can be further identified through the question pattern identification model, and if the question pattern identification model identifies the input sentence as a first type (attribute question pattern), the question pattern corresponding to the input sentence is to ask the entity attribute. The question pattern recognition model is a machine learning model with the ability of recognizing question patterns, and can be obtained by training input sentences including attribute question patterns and relation question patterns. Optionally, the input sentence is recognized by one or more question pattern recognition models, thereby determining the question pattern of the input sentence.
In the matching method, the keyword matching method may be written in the second column (second field) of the configuration file.
The fourth field is an optional field, and the fourth field represents packaging dialogs for packaging the queried answer. For example, the user queries the original singer of a song, the answer queried by the knowledge-graph question-answering system is 'Xiaoming', and the knowledge-graph question-answering system outputs 'Xiaoming' before the answer is not processed by the fourth field corresponding to the packaged dialect. The answer is packaged by a packaging language, and a packaged result is obtained, such as 'hello, the original singer of the song is Xiaoming', and in addition, the user can customize some languages, so that the query result fed back to the user is higher in quality.
The configuration file may be simplified as shown in fig. 5 (b), and the configuration file includes three columns, corresponding to three fields respectively. The first field corresponding to the first column is the entity type. The second field corresponding to the second column is a question mode, which is described in a human-readable query description language, such as the variable p in conjunction with a query operation. The third field corresponding to the third column is a matching pattern, the matching pattern can be matched by using keywords, for example, the keywords include at least one of "gender", "male" and "female", and the matching questioning pattern is to ask questions about gender (entity attributes).
It is understood that each line in the above field is a query statement template, and other symbols, such as "\\", brackets, etc., may also be used in the above field as a separation symbol, and the specific form of the separation symbol is not limited in the embodiments of the present application. The language of the above fields may be other languages besides chinese and english, and the language type used for the fields is not limited in the embodiments of the present application.
Step 402, determining a query target according to the entity type and determining a query operation according to the query description language.
The input statement comprises an entity type and a question mode, wherein the entity type is used for determining a target (a query target) to be specifically queried of the query statement template, and the question mode is used for determining content (a query operation) to be queried of the entity type (the query target) by the query statement template.
In one example, the input sentence is "what is the gender of the singer? ", the entity type in the input sentence is" singer ", and the query description language is: "p gender category". The question-answering system of the knowledge graph determines that the query target in the input sentence is singer, and the query operation is to query gender.
Step 403, converting the query target and the query operation into a query statement template in machine language.
According to the above example, the knowledge-graph question-and-answer system converts the entity types in the configuration file into a query target, converts the question mode into a query operation, and converts the query target and the query operation into a query statement template in a machine language form. For example, the knowledge-graph question-and-answer system converts entity type 1 and question mode 1 into query statement template 1.
Step 404, store the query statement template.
And the query target and the query operation are converted into a query statement template in a machine language form, and the query statement template is associated with the entity type and the question asking mode for storage. For example, the query statement template is a rank corresponding to music, and the query statement template is stored in a manner of associating an entity type (music) and a question asking mode (rank, entity relationship). When the sentence input by the user corresponds to the information related to the music and the ranking, the knowledge-graph question-answering system calls the query sentence template.
Secondly, the knowledge-graph question-answering system obtains a query statement template.
The acquisition of the query statement template by the knowledge-graph question-answering system comprises a direct acquisition mode and an indirect acquisition mode, wherein the direct acquisition mode is explained below, and the first statement feature corresponding to the input statement in the direct acquisition mode comprises a first entity and a first question mode.
Step 405, generating a mapping relation among the sentence characteristics of the input sentence, the question mode and the query sentence template, wherein the mapping relation is used for determining the question mode to which the input sentence belongs in the question and answer process.
And the knowledge-graph question-answering system generates a query statement template and a mapping relation according to the configuration file. The mapping relationship is a mapping relationship between the sentence features of the input sentence, the question pattern, and the query sentence template.
Wherein the sentence characteristics comprise at least one of the following ways: the machine recognition model comprises an entity type, keywords containing question patterns, regular expressions corresponding to the question patterns and a machine recognition model corresponding to the question patterns, and is recognized as a first type.
The following description is made in conjunction with the mapping relationship between a pair of statement features, a question mode and a query statement template in a table.
Watch 1
Figure BDA0002381726180000131
Figure BDA0002381726180000141
In one example, the input sentence is "which province is the Kunming city? "the input sentence contains a keyword" kunming ", and the query sentence template is the province where the place name is located if the question mode is determined to be that the question is asked for the position (entity attribute) corresponding to the place name (entity type). In another example, the input sentence "who is the singer of song a? "determining the questioning mode through the regular expression is to ask a singer (entity attribute) of a song (entity type), and then the query sentence template is the original singer corresponding to the song. In another example, the input sentence is "what are all sold by the third floor? And identifying that the question pattern of the input sentence belongs to a second type (asking for an entity relationship) through the question pattern identification model, wherein the query sentence template is the commodity type corresponding to the floor.
For the case that the knowledge-graph question-answering system can directly obtain the query sentence template according to the input sentence, step 405 further includes the following sub-steps:
step 4051, the received input sentence is processed to obtain a first sentence characteristic corresponding to the input sentence.
The processing of input sentences refers to the normalization of input natural language, i.e., the conversion of human language symbols (e.g., characters and language) into a language understood by a computer. Firstly, the input sentence is analyzed in at least one analysis mode of lexical analysis, syntactic analysis and semantic analysis, for example, entity types including nouns such as letters, numbers and dates in the input sentence are extracted, or the sentence has a reference relationship, and the reference relationship needs to be analyzed. And then extracting entity relations involved in the input sentences or calculating values existing in the input sentences, wherein the calculating values need to be extracted, so that the first sentence characteristics corresponding to the input sentences are obtained.
Step 4052, determining a target query statement template corresponding to the first statement feature from the at least two query statement templates according to the mapping relationship.
When the first sentence characteristic comprises an entity type and a question mode, the entity included in the input sentence can be directly extracted according to the entity type, and the question mode of the input sentence is determined to be divided into the following three conditions:
1. when the input sentence has the corresponding keyword, for example, "did it rain in the upper sea? "the input sentence includes a keyword" raining ", the question mode is determined to ask weather (entity attribute) according to the keyword, the knowledge-graph question-answering system extracts" shanghai "(place name, entity type) from the input sentence, and the target query sentence template is determined to be weather corresponding to the place name according to the entity type and the question mode.
2. When the input sentence matches the regular expression, for example, is "did the input sentence go into the sea and rain? ", the input sentence conforms to a regular expression: the method comprises the steps of (place name | city | weather | rain | snow | sunny | frost | cloudy | air temperature), determining that a question mode is to ask weather (entity attributes) according to a regular expression, extracting Shanghai (place name and entity type) from input sentences by a knowledge-graph question-answering system, and determining that a target query sentence template is weather corresponding to the place name according to the entity type and the question mode.
3. When the input sentence is recognized as the first type by the machine recognition model corresponding to the question pattern, for example, "did the input sentence rain in the sea? The query pattern recognition model recognizes the input sentence, the output result is obtained that the query pattern of the input sentence belongs to a first type (weather (entity attribute) is queried), the knowledge-graph question-answering system extracts Shanghai (place name and entity type) from the input sentence, and the target query sentence template is determined to be weather corresponding to the place name according to the entity type and the query pattern.
Alternatively, the query statement template is described in a machine language, such as a database language, or a computer readable code.
Step 4053, a query statement is generated from the input statement and the target query statement template.
And substituting the first entity in the input statement into the target query statement template to obtain the query statement. And the position of the entity type and the position of the question mode in the target query statement template are corresponding to each other, the entity type in the input statement is filled in the position of the entity type in the target query statement template, and the question mode in the input domain statement is filled in the position of the question mode in the target query statement template, so that the query statement corresponding to the input statement is obtained.
In summary, in the method provided in this embodiment, an input query target and a query operation are converted into a query statement template in a machine language form by a configuration file, and a relationship between a statement feature of the input statement, a question pattern, and the query statement template is generated, and the input statement is processed to obtain a first statement feature, and when the first statement feature includes an entity type and a question pattern, the target query statement template can be directly obtained, so as to obtain a query statement corresponding to the query statement template, and further obtain an answer corresponding to a question from a knowledge graph database.
The following describes a manner of indirectly obtaining a query statement template. This approach includes three cases:
1. a first sentence feature in the input sentence includes having a first entity but not including a first question pattern;
2. a first sentence feature in the input sentence comprises a first question pattern but does not comprise having a first entity;
3. the first sentence feature in the input sentence does not include having the first entity nor the first question pattern.
Fig. 6 is a flowchart of a method for determining a target query statement template, which is applied in the server 140 in the computer system shown in fig. 2 or in another computer system, according to an exemplary embodiment of the present application, and includes the following steps:
step 601, processing the received input sentence to obtain a first sentence characteristic corresponding to the input sentence.
This step is identical to step 4051 and will not be described further here.
Step 602, in response to that the target query statement template corresponding to the first statement feature cannot be determined according to the mapping relationship, obtaining a historical query statement template in the historical input statement.
When the knowledge-graph question-answering system cannot determine the target query statement template specifically corresponding to the first statement according to the mapping relation, the knowledge-graph question-answering system can determine the historical input statement corresponding to the statement input in the current round of question-answering events of the user and acquire the historical query statement template corresponding to the historical input statement.
The knowledge-graph question-answering system obtains at least one historical input sentence, wherein the historical input sentence is the sentence input by the user in the previous question-answering event of the current round of question-answering events, or the historical input sentence is the sentence input by the user last in the current round of question-answering events. In one example, a user may first enter "what is delightful in the Kunming" twice into the knowledge-graph question-and-answer system? ", then" big theory is entered? "or, simultaneously input" what is pleasant about Kunming? "and" Dali? ", and" what is grazing in Kunming? "the input order precedes" big theory? ". According to the user input, "big principle? "(the first sentence feature is incomplete, only entity type), the target query sentence template cannot be determined by the knowledge-graph question-answering system, so that a historical query sentence template needs to be obtained.
Step 603, obtaining a substitute query statement template corresponding to the first statement feature according to the first statement feature and the historical query statement template.
If the first sentence characteristic of the input sentence corresponds to the entity type or the question mode in the historical query sentence template, the knowledge-graph question-and-answer system can obtain a substitute query sentence template corresponding to the first sentence characteristic according to the historical query sentence template.
When the first sentence characteristic corresponding to the input sentence is incomplete, there are three cases corresponding to acquiring the alternative query sentence template, and the first case is explained below.
The first case is: a first sentence feature in the input sentence includes having a first entity but not including a first question Mode(s).
In this case, step 603 further comprises the sub-steps of:
step 6031a, in response to the first statement feature including the first entity but not the first question pattern, determines a historical query statement template that includes the first entity type as a replacement query statement template, the first entity type being the entity type that the first entity has.
In one example, the user entered statement is "what is nice to have in Kunming? Will you think of a big idea? "," what is grazing in Kunming? "is" big principle? "corresponding historical input sentence," what is nice to have in Kunming? "the second sentence characteristics in includes the second entity (place name) and the second question pattern (what gourmet is there), and the knowledge-graph question-and-answer system determines" what is delightful in the kunza? The corresponding query statement template is a gourmet corresponding to the place name.
Optionally, the manner of matching the second question pattern includes: at least one of a keyword, a regular expression, and a questioning pattern recognition model recognition.
1) By keyword matching. For example, the input sentence "what is nice to have in Kunming? "the package contains the keyword" is tasty ", the question mode is determined to be the question of the gourmet (entity attribute) according to the keyword, and the query sentence template containing the question mode to be the question of the gourmet can be matched.
2) A regular expression. For example, the input sentence "what is nice to have in Kunming? "conform to regular expression: (place name | cate | special snack | tasty), the question mode is determined to ask questions of cate (entity attribute) according to the regular expression, and a query sentence template containing the question mode to ask questions of cate can be matched.
3) And (5) identifying the questioning pattern identification model. What is the input sentence "how nice is the query pattern recognition model? The method comprises the steps of identifying, obtaining an output result that a question mode of an input sentence belongs to a first type (asking questions of gourmet (entity attributes)), and matching a query sentence template containing the question mode and asking the questions of the gourmet.
"Dali woolen? "the first sentence characteristic in the sentence includes an entity but does not include a question mode, and the knowledge-graph question-answering system cannot determine a query sentence template corresponding to the input sentence according to the first sentence characteristic and the mapping relation, so as to obtain a historical input sentence" how nice is the queen? "a corresponding historical query statement template, according to the question pattern of the historical query statement template which is accorded with the first statement feature (entity, place name), thereby determining the historical query statement template containing the first entity type as a substitute query statement template, i.e.," will you determine? The corresponding alternate query statement template is also the gourmet corresponding to the place name.
The second case will be explained below.
The second case is: the first sentence feature in the input sentence includes the first question pattern but does not include having the first question pattern An entity.
In this case, step 603 further comprises the sub-steps of:
step 6031b, in response to the first sentence characteristic including the first question pattern but not including the first entity, obtain a second entity type of the historical input sentence.
In one example, the input sentence is "what featured snacks are there? "and" what are the 5A scenic spots here? ", the former is in order prior to the latter, the former being a history input statement of the latter. "what are the 5A scenic spots here? The place referred to as "middle" here is unknown, so that the target query statement template corresponding to the input statement cannot be directly acquired. The knowledge-graph question-answering system obtains the second entity type in the historical input sentences, namely obtains the 'Kunming' (the second entity type).
Optionally, the matching the first question pattern and the second question pattern includes: at least one of a keyword, a regular expression, and a questioning pattern recognition model recognition.
1) By keyword matching. The input sentence "what featured snacks are there in Kunming? The characteristic snack contains the key word, the second question mode is determined to be the question of the gourmet (entity attribute) according to the key word, and a query statement template containing the question mode to be the question of the gourmet can be matched; "what are the 5A scenic spots here? The ' including key words ' 5A level scenic spot ', according to the key words, the first question mode can be determined to ask questions of the scenic spot (entity attribute), and the query sentence template which includes the question mode and asks questions of the scenic spot can be matched.
2) A regular expression. The input sentence "what featured snacks are there in Kunming? "conform to regular expression: (place name | cate | special snack | tasty), determining that the second question mode is to ask questions of cate (entity attribute) according to the regular expression, and matching a query statement template containing the question mode to ask questions of cate; the input sentence "which are the 5A scenic spots here? "conform to regular expression: (place name | city | province | country | scenic spot grade | scenery), the first question mode is determined to ask questions of the scenery (entity attribute) according to the regular expression, and the matchable question mode is a query statement template containing questions of the scenic spot.
3) And (5) identifying the questioning pattern identification model. Is the question pattern recognition model applied to the input sentence "what featured snacks are there in Kunming? "identify, obtain output result this input statement second question mode belong to first type (ask questions to the food (entity attribute)), can match ask question mode to contain inquire statement template to the food ask question; the question pattern recognition model recognizes an input sentence, namely a 5A scenic spot, and obtains an output result that the first question pattern of the input sentence belongs to a first type (question is asked for the scenic spot (entity attribute)), and the matchable question pattern is a query sentence template containing a question for the scenery.
Step 6032b, determining a second query statement template corresponding to the first question mode and the second entity type from the at least two query statement templates according to the mapping relationship.
The knowledge-graph question-and-answer system also acquires a historical query statement template corresponding to a historical input statement, and is based on which characteristic snacks (question patterns) are in the knowledge-graph question-and-answer system according to the' Kunming (entity type)? "the contained second sentence characteristics (the second entity type and the second question mode) determine that the corresponding historical query sentence template is a food corresponding to the place name. "what are the 5A scenic spots here (question patterns)? "lack entity type, have a first questioning mode. Therefore, a corresponding second query statement template is determined according to the first question mode and the second entity type, and the second query statement template is a scenic spot corresponding to the place name.
Step 6033b, the second query statement template is determined to be a replacement query statement template.
The second query statement template is the alternative query statement template determined after the second entity type is reserved, the first question mode is modified (the gourmet question is modified to the scenic spot question), and the modified second query statement template is determined.
The third case will be explained below.
The third case is: the first sentence feature in the input sentence does not include having the first entity nor the first mention Asking about the mode.
Step 6031c, the received input sentence is processed to obtain a first sentence characteristic corresponding to the input sentence.
This step is identical to step 4051 and will not be described further here.
Step 6032c, in response to that the target query statement template corresponding to the first statement feature cannot be determined according to the mapping relationship, outputting the query statement according to the first statement feature, and acquiring a supplementary answer corresponding to the query statement.
The third case will be described with reference to fig. 7, taking an application program supporting the knowledge-graph question-answering system as an example, where a sentence input by the user 701 and a sentence output by the small assistant 702 are displayed on the interface 70. The user 701 inputs "building 1 of museum three", because the first sentence feature in the input sentence only includes an entity, the knowledge-graph question-answering system performs intention clarification on the input sentence, that is, obtains a question mode corresponding to the input sentence, and needs to output a question sentence to the user, and feeds back the question mode related to the first sentence feature to the user, for example, the question sentence output by the small assistant 702 is: the aspects found to be understandable for user 701 include "business category," merchant list, "" number of merchants, "" number of categories.
The user 701 continues to input "what is business category (question mode)" according to the question statement, so that the knowledge base map question-answering system obtains the supplementary answer corresponding to the question statement.
Step 6033c, extract the third sentence feature in the supplemental answer.
The third sentence feature extracted from the "business category what" by the small assistant 701 includes a questioning pattern.
Step 6034c, determining a third query statement template corresponding to the first statement feature and the third statement feature from the at least two query statement templates according to the mapping relationship.
The knowledge-graph question-answering system combines 'No. 1 building' with 'business category is good', and determines a third query statement template corresponding to the two input statements from at least two query statement templates according to the mapping relation between the query statement templates and the statement features as a business category corresponding to the place. Therefore, the query statement is determined according to the third query statement template, and the answer corresponding to the query statement is fed back to the user 701, for example, the assistant 702 finds the business category corresponding to the building 1 of the third restaurant, such as ' women's dress ', ' life general merchandise ', ' special snack ', etc., for the user 701.
The three modes can be implemented independently or in combination, and need to be implemented in combination with a sentence input by a user.
Step 604, substituting the first entity in the input statement into the target query statement template to obtain the query statement.
Illustratively, the input sentence is "what gouges are in principle? "the target query statement template is a gourmet corresponding to the place name," big theory "is substituted into the position corresponding to the entity type in the target query statement template to obtain a query statement for inquiring the" big theory gourmet ".
In summary, in the method provided in this embodiment, when the input sentence lacks necessary sentence features, the alternative query sentence template is determined by obtaining the historical input sentence and replacing or modifying part of the content in the query sentence template corresponding to the historical input sentence; or when the semantics of the input sentence is unknown, outputting a question mode related to the input sentence to the user in a reverse question mode, and determining a substitute query sentence template by combining the context after the user supplements the input sentence. Therefore, the query statement is determined according to the alternative query statement template, the answer corresponding to the question is obtained from the knowledge map database, the query statement template can be obtained under different application scenes and question-answer interaction can be realized only by providing the corresponding configuration file by the user, and the user does not need to understand the query language of the database or write the query statement template or is familiar with the code language.
The following describes the initialization workflow and the question-answering process of the knowledge-map question-answering system with reference to the structure diagram of the knowledge-map question-answering system.
FIG. 8 is a flowchart illustrating initialization of a vertical domain knowledge-graph question-answering system according to an exemplary embodiment of the present application. The method is applied to a server 140 in a computer system shown in fig. 2 or other computer systems, and comprises the following steps:
step 1, reading a configuration file.
Optionally, the configuration file is a configuration file provided by a user, or a configuration file is set by default for different fields in the knowledge-graph question-answering system. Optionally, the knowledge-graph question-answering system may provide a template or prompt information for the user to create the configuration file, and the user may complete creation of the configuration file only by filling or modifying information in the corresponding template, or the user may gradually complete the configuration file according to the prompt information displayed on the computer.
Alternatively, the configuration file of one field may be one or more. Optionally, the knowledge-graph question-and-answer system receives an input electronic document, the electronic document comprising at least one of a spreadsheet and text, and obtains a configuration file from the electronic document.
Optionally, the configuration file further includes template expression words, and the knowledge-graph question-answering system expresses the words according to the template to generate an answer word template corresponding to the question mode. In one example, the configuration file includes template expression words that are: record company, the answer text template corresponding to the generated question mode is: record company.
In the related technology, the knowledge-graph question-answering system can meet the question-answering requirement in the travel industry or the commercial real estate industry without a large number of query statement templates (not more than 30), most of the knowledge-graph question-answering systems are simple question-answering processes, the Questions are answered in a common question answering (FAQ) system, generally, tens of thousands of question-answer pairs are required to be manually configured, and each question-answer pair needs to be prepared with 10 or more than 10 similar Questions, so that the construction mode of the knowledge-graph question-answering system is complex.
The embodiment of the application provides a method for generating query statement templates, which can generate query statement templates in different fields and realize question-answer interaction with users only by replacing corresponding configuration files for different fields and not configuring question-answer pairs and similar questions.
And when the knowledge-graph question-answering system is initialized, setting and generating a query statement template according to fields in the configuration file. The configuration file can be made without the user having to know the database query language or familiar code language.
And 2, generating a mapping relation among the query statement template, the question mode and the statement features according to the configuration file.
After the knowledge-graph question-answering system reads the configuration file, an inquiry statement template is automatically generated, and a mapping relation between the inquiry statement template and the statement characteristics and question modes of the input statement is generated. And establishing a mapping relation between the keywords and the query statement template by taking the entities contained in the statement features and extracting the face value of the input statement as a keyword (key). In the multi-turn dialogue mode, the knowledge-graph question-answering system also jumps among various question-answering modes (such as a question-answer mode and a question-answer clarification mode) according to the mapping relation to obtain the corresponding query statement template.
And 3, reading the special dictionary if no entity recognition model exists.
A general knowledge-graph question-answering system needs to recognize entities in input sentences (i.e., natural language), and usually uses a large amount of data to train an entity recognition model, which is used to recognize the entities in the sentences. Under the condition of no entity recognition model, some fields correspond to a special dictionary of the field, such as a financial field, a tourism field, a real estate field and the like, and the entity in the input sentence can be matched with the words in the special dictionary so as to achieve the aim of recognizing the entity.
And 4, reading other matching modes if no machine identification model corresponding to the questioning mode exists.
A general knowledge graph question-answering system needs to identify face values in input sentences, usually uses a large amount of data to train a question pattern identification model, scores or classifies the input sentences by using the question pattern identification model, and determines whether to extract the face values or whether to perform a relevant dialect clarification question-answering mode according to the scores (the knowledge graph question-answering system outputs question sentences to a user and determines questions that the input sentences of the user want to ask questions); and determining the question mode corresponding to the input sentence according to the type of the question mode in the recognized input sentence. Under the condition of no question pattern recognition model, matching the question patterns corresponding to the input sentences according to the related regular expressions or keywords, such as extracting the face values in the input sentences according to the regular expressions or judging whether to perform a language clarification question-back mode.
And 5, initializing some global memory sets and then starting question answering service.
The knowledge-graph question-answering system is provided with a universal algorithm, and a corresponding query statement template can be generated according to different configuration files. The knowledge-graph question-answering system has a context correlation capability multi-turn dialogue system, and can store historical dialogue and statement analysis information through a data structure. After the knowledge map question-answering system is initialized, question-answering service can be carried out.
The following describes a process of performing question-answering service by the knowledge-graph question-answering system in combination with the structure of the knowledge-graph question-answering system, as shown in fig. 9.
The knowledge-graph question-and-answer system initializes context variables including: at least one of a complex inference and query meta-sentence mapping, a priority list, an entity type mapping, a question-back clarification mapping, a historical entity category memory, an abstract entity memory, an entity value list, an output control state, a multi-turn dialog control state, and a graph data. The query meta-statement can customize complex reasoning and query by initializing context variables, and optionally, the query statement template generation module 90 can generate the query meta-statement through a configuration file, wherein the query meta-statement refers to a statement composed of languages describing the query statement.
The query statement template generating module 90 reads the configuration file and generates a mapping relationship between the query statement template, the statement feature and the query statement template.
At this time, the user inputs a sentence into the question-answering system, and the sentence preprocessing module 91 (i.e., the natural language analysis module) preprocesses the received sentence to obtain an analysis result of the input sentence, where the analysis result includes: the corresponding entities, entity relationships, question patterns (asking for entity attributes, asking for relationships between at least two entities) in the input sentence, other information (reasoning nodes) available from the entities, question-answer pattern extraction (such as a question-answer pattern, a question-answer clarification pattern, etc.). Optionally, the statement preprocessing module 91 may construct an entity relationship list, and determine the relationship between the entity and the entity in the statement according to the entity relationship list.
The sentence preprocessing module 91 sends the analysis result to the initial answer obtaining module 92, and the initial answer obtaining module 92 obtains the target query sentence template from the query sentence template generating module 90 according to the analysis result.
When the initial answer obtaining module 92 successfully obtains the target query statement template, the target query statement template is sent to the query statement constructing module 921, the query statement constructing module 921 constructs a query statement according to the target query statement template, and sends the query statement to the returned result processing module 94, and the returned result processing module 94 queries a corresponding answer from the graph database 95 and outputs response information to the user. Optionally, the graph database is Neo4 j. Optionally, the returned result processing module 94 performs a packaging jargon processing on the queried answer before outputting the response message, for example, the queried answer is "rice noodles and flower cakes", and after the packaging jargon processing, the response message is "hello", and the special snack in Yunnan is rice noodles and flower cakes ".
When the initial answer obtaining module 92 does not successfully obtain the target query statement template, the initial answer obtaining module 92 sends the analysis result to the multi-turn dialogue judging module 922, and the multi-turn dialogue judging module 922 judges whether to enter a multi-turn dialogue mode according to history memory (history input statements and corresponding history query statement templates) and statements input in the current turn of question and answer events, wherein the multi-turn dialogue mode comprises a subgraph memory mode, a subgraph skip mode, a multi-turn question-answer mode and a content supplement mode. Wherein the multi-turn question-back mode and the content supplement mode operate cooperatively. When entering any mode, the multi-turn dialogue determining module 922 sends the history memory and the sentences input in the current turn of question-answering events to the multi-turn dialogue managing module 923.
The subgraph memory mode means that the target query statement template is the same as the query statement template of the previous round of question-answering events, and the entities in the query statement template of the previous round of question-answering events are replaced by the entities in the statements input in the current round of question-answering events.
In one example, the sentence currently input by the user is "big will? "because the semantic meaning of the sentence is not clear enough, the multi-turn dialog management block 93 judges that the sentence belongs to the subgraph memory mode according to the query sentence of the last turn of question-answering event. The sentence entered in the previous round of question-answering events is "what is delightful about Kunming? The query statement template corresponding to the query statement template is a gourmet corresponding to the place name, so the multi-round dialog management module 923 replaces the entity corresponding to the query statement template with the entity in the statement input in the current round of question and answer events, that is, "kunming" with "theory". Therefore, the question corresponding to the input sentence of this round is "what is nice for the greater reason? ", the query sentence template is the gourmet corresponding to the place name.
The subgraph jump mode refers to that the query statement template of the previous round of question-answering events is deleted and added to form a target query statement template according to the statements input in the current round of question-answering events.
In one example, the sentence entered by the user in the current round of question-and-answer events is "what are the 5A scenic spots here? "since the place indicated by" here "in the input sentence is unknown, the multi-turn dialog determination module 922 determines that the sentence belongs to the sub-graph memory mode according to the query sentence of the previous turn of the question-answering event. The sentence inputted in the previous round of question-answering event is "what special snacks are there in Kunming? "the corresponding query sentence template is gourmet corresponding to the place name", so the multi-turn dialog management module 93 determines that the place "here" is "kunming" according to the sentences input in the question and answer event of the current turn, and modifies the query sentence template into the scenic spot corresponding to the place name, so the question corresponding to the input sentence of the current turn is "what is a 5A scenic spot of kunming? ".
The multi-turn question-back mode means that the input statement does not meet a subgraph memory mode and a subgraph jump mode, meets the question-back condition, asks the statements which are not well described back, and clarifies the intention of the input statement through asking the statements back. And the content supplement mode refers to that the last round of question and answer events accord with the multi-round question and answer mode, the input sentences of the round are used as supplement answers, and the supplement answers and the multi-round question and answer mode work cooperatively to generate the target query sentence template.
In one example, the sentence input by the user is "kunming" (entity), the query intention of the input sentence is not clear, the multi-turn dialog determination module 922 determines that the sentence belongs to the multi-turn question-back mode, the multi-turn dialog management module 93 asks the query sentence related to the entity to the user, the user will receive the question-back sentence "content asked for you," the assistant finds the following contents "weather", "food", "landscape", "traffic", "shopping", ask you to select ", when the user inputs a new sentence, such as "food", the multi-turn dialog determination module 922 determines that the input sentence belongs to the supplemental answer mode, the multi-turn dialog management module 93 supplements the "food" as the question mode, in combination with the previous input sentence, the weather corresponding to the place name is the template of the target query sentence, and thus the question corresponding to the sentence input by the user is "how much weather is there? ".
After the target query statement template is obtained through the above mode, the multi-round dialog management module 93 sends the target query statement template to the query statement construction module 921, the query statement construction module 921 generates a query statement according to the target query statement template, and the subsequent process is directly consistent with the process in which the answer primary obtaining module 92 obtains the target query statement template, which is not described herein again.
Optionally, in the knowledge-graph question-answering system, the multi-turn dialogue management module 93 may also obtain the corresponding query statement from the statement mapping relationship, the multi-turn dialogue management module 93 may also obtain the corresponding query statement from the question-back clarifying mapping relationship, and the expression form of the question-back clarifying mapping relationship may be a question-back clarifying mapping relationship list.
Optionally, the initial answer obtaining module 92 may obtain the query meta-statement from the statement mapping relationship, where the expression of the statement mapping relationship may be a statement mapping relationship list.
In summary, the knowledge-graph question-answering system provided by the embodiment reduces the access threshold of the knowledge-graph question-answering system, and enables the knowledge-graph question-answering system to have a certain context-associated multi-turn question-answering capability. Aiming at different users, the knowledge-graph question-answering system can be realized only by setting configuration files according to related formats without deep understanding, knowledge-graph question-answering, semantic analysis and other related knowledge of a graph database.
Fig. 10 and 11 are schematic diagrams respectively showing interfaces of the vertical domain knowledge-graph question-answering system on different platform clients.
The question-answering system is applied to the travel industry, the question input by the user corresponds to the question input by the user in the figure, and the question is represented by an inclined font. Alternatively, the question and the answer may be distinguished by different colors, and the form of distinguishing the question and the answer is not limited in the present application. Alternatively, the user input problem is that the user inputs the input into the computer through an external access device such as a keyboard or a mouse, or the user input problem is that the computer obtains the input through a voice collecting device such as a microphone, and the computer converts the voice into text or voice to be displayed on the interface shown in fig. 10. Schematically, in fig. 10 (a), the user inputs "what are delightful? "the corresponding answer is" the food recommended by the city is: rice noodles, fresh flower cakes and baked bait blocks. In fig. 10 (b), the user inputs "several funny scenic spots like" and the answer to this question is "the common scenic spots in kunming: 33 "; the user inputs 'which scenes are', and according to the context, the question corresponding to the input sentence of the user is 'which scenes are in 33 scenes in Kunming City', and the answer corresponding to the question is which scenes are in detail in the Kunming City.
Fig. 11 is a schematic diagram illustrating an interface of a knowledge-graph question-answering system provided by an exemplary embodiment of the present application on a smartphone.
Taking the application of the question-answering system to commercial properties as an example, in fig. 11 (a), a question-answering conversation between the user 801 and the small assistant 802 is displayed on the interface 80, and the user 801 inputs "what suit is. The small assistant 802 searches merchants of the women's clothing operation category for the user 801, the user 801 inputs' building 2 of the third shop ', the small assistant 802 automatically associates what the user 801 wants to inquire about is' the women's clothing of the building 2 of the third shop', and searches for corresponding answers for the user 801. Similarly, in fig. 11 (b), a question-and-answer conversation between the user 811 and the small assistant 812 is displayed on the interface 81, and in fig. 11 (c), a question-and-answer conversation between the user 821 and the small assistant 822 is displayed on the interface 82. FIG. 11 illustrates the contextual understanding of the knowledge-graph question-answering system, which can correlate historical input sentences and determine answers to questions.
Fig. 12 is a block diagram illustrating a device for generating a query statement template according to an exemplary embodiment of the present application. The generation apparatus includes:
an obtaining module 1210, configured to obtain a configuration file, where the configuration file includes an entity type and a question mode, and the question mode is described by using a human-readable query description language;
a generating module 1220, configured to generate a query statement template according to the entity type and the query description language;
a storage module 1230, configured to store the query statement template.
In an alternative embodiment, the processing module 1240 is used for determining a query target according to the entity type and determining a query operation according to the query description language; and converting the query target and the query operation into a query statement template in a machine language form.
In an alternative embodiment, the questioning mode includes: at least one of an attribute questioning mode and a relationship questioning mode; the attribute questioning mode is used for questioning the attribute of the entity; the relationship questioning mode is used to query the relationship between at least two entities.
In an optional embodiment, the generating module 1220 is configured to generate a mapping relationship among the sentence features of the input sentence, the question pattern, and the query sentence template, where the mapping relationship is used to determine a relationship of the question pattern to which the input sentence belongs in the question and answer process; the sentence features comprise at least one of entities containing entity types, keywords containing question patterns, regular expressions corresponding to the question patterns and machine identification models corresponding to the question patterns, wherein the entities contain the entity types, the keywords contain the question patterns, and the machine identification models are identified to be of the first type.
In an alternative embodiment, the query statement templates are at least two; the apparatus includes a receiving module 1250;
the receiving module 1250 is configured to process the received input sentence to obtain a first sentence characteristic corresponding to the input sentence;
the processing module 1240 is configured to determine, according to the mapping relationship, a target query statement template corresponding to the first statement feature from the at least two query statement templates;
the generating module 1220 is configured to generate a query statement according to the input statement and the target query statement template.
In an alternative embodiment, the query statement templates are at least two;
the receiving module 1250 is configured to process the received input sentence to obtain a first sentence characteristic corresponding to the input sentence;
the obtaining module 1210 is configured to obtain a historical query statement template in the historical input statement in response to that the target query statement template corresponding to the first statement feature cannot be determined according to the mapping relationship;
the processing module 1240 is configured to obtain a substitute query statement template corresponding to the first statement feature according to the first statement feature and the historical query statement template.
In an alternative embodiment, the processing module 1240 is configured to determine, as the alternative query statement template, the historical query statement template having the first entity type in response to the first statement feature including the first entity but not the first question pattern, where the first entity type is the entity type that the first entity has.
In an optional embodiment, the generating module 1220 is configured to substitute a first entity in the input statement into the target query statement template to obtain the query statement.
In an alternative embodiment, the obtaining module 1210 is configured to obtain a second entity type of the historical input statement in response to the first statement feature including the first question pattern but not including the first entity;
the processing module 1240 is configured to determine, according to the mapping relationship, a second query statement template corresponding to the first question asking mode and the second entity type from the at least two query statement templates; and determining the second statement query template as a substitute query statement template.
In an optional embodiment, the receiving module 1250 is configured to process the received input sentence to obtain a first sentence characteristic corresponding to the input sentence;
the obtaining module 1210 is configured to, in response to that the target query statement template corresponding to the first statement feature cannot be determined according to the mapping relationship, output a query statement according to the first statement feature, and obtain a supplemental answer corresponding to the query statement;
the processing module 1240 is used for extracting a third sentence characteristic in the supplementary answer; and determining a third query statement template corresponding to the first statement feature and the third statement feature from the at least two query statement templates according to the mapping relation.
In an optional embodiment, the configuration file further includes: expressing the characters by using the template; the generating module 1220 is configured to generate an answer text template corresponding to the question pattern according to the template expression text.
Fig. 13 shows a schematic structural diagram of a server according to an exemplary embodiment of the present application. The server may be a server in the background server cluster 140. Specifically, the method comprises the following steps:
the server 1300 includes a Central Processing Unit (CPU) 1301, a system Memory 1304 including a Random Access Memory (RAM) 1302 and a Read Only Memory (ROM) 1303, and a system bus 1305 connecting the system Memory 1304 and the Central Processing Unit 1301. The server 1300 also includes a basic Input/Output System (I/O System)1306 for facilitating information transfer between devices within the computer, and a mass storage device 1307 for storing an operating System 1303, application programs 1314, and other program modules 1315.
The basic input/output system 1306 includes a display 1308 for displaying information and an input device 1309, such as a mouse, keyboard, etc., for user input of information. Wherein a display 1308 and an input device 1309 are connected to the central processing unit 1301 through an input-output controller 1310 connected to the system bus 1305. The basic input/output system 1306 may also include an input/output controller 1310 for receiving and processing input from a number of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, input-output controller 1310 also provides output to a display screen, a printer, or other type of output device.
The mass storage device 1307 is connected to the central processing unit 1301 through a mass storage controller (not shown) connected to the system bus 1305. The mass storage device 1307 and its associated computer-readable media provide non-volatile storage for the server 1300. That is, the mass storage device 1307 may include a computer-readable medium (not shown) such as a hard disk or Compact disk Read Only Memory (CD-ROM) drive.
Computer-readable media may include computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes RAM, ROM, Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), flash Memory or other Solid State Memory technology, CD-ROM, Digital Versatile Disks (DVD), or Solid State Drives (SSD), other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage, or other magnetic storage devices. The Random Access Memory may include a resistive Random Access Memory (ReRAM) and a Dynamic Random Access Memory (DRAM). Of course, those skilled in the art will appreciate that computer storage media is not limited to the foregoing. The system memory 1304 and mass storage device 1307 described above may be collectively referred to as memory.
According to various embodiments of the present application, server 1300 may also operate as a remote computer connected to a network via a network, such as the Internet. That is, the server 1300 may be connected to the network 1312 through the network interface unit 1311, which is connected to the system bus 1305, or may be connected to other types of networks or remote computer systems (not shown) using the network interface unit 1311.
The memory further includes one or more programs, and the one or more programs are stored in the memory and configured to be executed by the CPU.
In an alternative embodiment, there is provided a computer device comprising a processor and a memory, the memory having stored therein at least one instruction, at least one program, set of codes, or set of instructions, the at least one instruction, at least one program, set of codes, or set of instructions being loaded and executed by the processor to implement the method of generating a query statement template as described above.
In an alternative embodiment, there is provided a computer readable storage medium having stored therein at least one instruction, at least one program, set of codes, or set of instructions, which is loaded and executed by a processor to implement the method of generating a query statement template as described above.
Referring to fig. 14, a block diagram of a computer device 1400 according to an exemplary embodiment of the present application is shown. The computer device 1400 may be a portable mobile terminal, such as: smart phones, tablet computers, MP3 players (Moving Picture Experts Group Audio Layer III, motion video Experts compression standard Audio Layer 3), MP4 players (Moving Picture Experts Group Audio Layer IV, motion video Experts compression standard Audio Layer 4). Computer device 1400 may also be referred to by other names such as user equipment, portable terminal, and the like.
Generally, computer device 1400 includes: a processor 1401, and a memory 1402.
Processor 1401 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so forth. The processor 1401 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1401 may also include a main processor and a coprocessor, where the main processor is a processor for processing data in an awake state, and is also referred to as a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 1401 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing content that the display screen needs to display. In some embodiments, processor 1401 may further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
Memory 1402 may include one or more computer-readable storage media, which may be tangible and non-transitory. Memory 1402 may also include high speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in memory 1402 is used to store at least one instruction for execution by processor 1401 to implement the method of generating a query statement template provided herein.
In some embodiments, computer device 1400 may also optionally include: a peripheral device interface 1403 and at least one peripheral device. Specifically, the peripheral device includes: at least one of radio frequency circuitry 1404, a touch display 1405, a camera 1406, audio circuitry 1407, a positioning component 1408, and a power supply 1409.
The peripheral device interface 1403 can be used to connect at least one peripheral device related to I/O (Input/Output) to the processor 1401 and the memory 1402. In some embodiments, the processor 1401, memory 1402, and peripheral interface 1403 are integrated on the same chip or circuit board; in some other embodiments, any one or both of the processor 1401, the memory 1402, and the peripheral device interface 1403 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
The Radio Frequency circuit 1404 is used for receiving and transmitting RF (Radio Frequency) signals, also called electromagnetic signals. The radio frequency circuitry 1404 communicates with communication networks and other communication devices via electromagnetic signals. The rf circuit 1404 converts an electrical signal into an electromagnetic signal to transmit, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1404 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and so forth. The radio frequency circuit 1404 may communicate with other terminals via at least one wireless communication protocol. The wireless communication protocols include, but are not limited to: the world wide web, metropolitan area networks, intranets, generations of mobile communication networks (2G, 3G, 4G, and 5G), Wireless local area networks, and/or WiFi (Wireless Fidelity) networks. In some embodiments, the radio frequency circuit 1404 may further include NFC (Near Field Communication) related circuits, which are not limited in this application.
The touch display 1405 is used to display a UI (User Interface). The UI may include graphics, text, icons, video, and any combination thereof. The touch display 1405 also has the ability to capture touch signals at or above the surface of the touch display 1405. The touch signal may be input to the processor 1401 for processing as a control signal. The touch display 1405 is used to provide virtual buttons and/or virtual keyboards, also referred to as soft buttons and/or soft keyboards. In some embodiments, the touch display 1405 may be one, providing the front panel of the computer device 1400; in other embodiments, the touch display 1405 can be at least two, respectively disposed on different surfaces of the computer device 1400 or in a folded design; in still other embodiments, the touch display 1405 may be a flexible display disposed on a curved surface or on a folded surface of the computer device 1400. Even the touch display 1405 can be arranged in a non-rectangular irregular figure, i.e., a shaped screen. The touch Display 1405 can be made of LCD (Liquid Crystal Display), OLED (organic light-Emitting Diode), and the like.
The camera assembly 1406 is used to capture images or video. Optionally, camera assembly 1406 includes a front camera and a rear camera. Generally, a front camera is used for realizing video call or self-shooting, and a rear camera is used for realizing shooting of pictures or videos. In some embodiments, the number of the rear cameras is at least two, and each of the rear cameras is any one of a main camera, a depth-of-field camera and a wide-angle camera, so that the main camera and the depth-of-field camera are fused to realize a background blurring function, and the main camera and the wide-angle camera are fused to realize a panoramic shooting function and a VR (Virtual Reality) shooting function. In some embodiments, camera assembly 1406 may also include a flash. The flash lamp can be a monochrome temperature flash lamp or a bicolor temperature flash lamp. The double-color-temperature flash lamp is a combination of a warm-light flash lamp and a cold-light flash lamp, and can be used for light compensation at different color temperatures.
Audio circuitry 1407 is used to provide an audio interface between a user and computer device 1400. The audio circuit 1407 may include a microphone and a speaker. The microphone is used for collecting sound waves of a user and the environment, converting the sound waves into electric signals, and inputting the electric signals to the processor 1401 for processing or inputting the electric signals to the radio frequency circuit 1404 to realize voice communication. For stereo capture or noise reduction purposes, the microphones may be multiple and located at different locations on the computer device 1400. The microphone may also be an array microphone or an omni-directional pick-up microphone. The speaker is then used to convert electrical signals from the processor 1401 or the radio frequency circuit 1404 into sound waves. The loudspeaker can be a traditional film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, the speaker can be used for purposes such as converting an electric signal into a sound wave audible to a human being, or converting an electric signal into a sound wave inaudible to a human being to measure a distance. In some embodiments, the audio circuit 1407 may also include a headphone jack.
The Location component 1408 is operable to locate a current geographic Location of the computer device 1400 for navigation or LBS (Location Based Service). The Positioning component 1408 may be based on the Positioning component of the GPS (Global Positioning System) in the united states, the beidou System in china, or the galileo System in russia.
The power supply 1409 is used to power the various components of the computer device 1400. The power source 1409 may be alternating current, direct current, disposable or rechargeable. When the power source 1409 comprises a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. The wired rechargeable battery is a battery charged through a wired line, and the wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery may also be used to support fast charge technology.
In some embodiments, computer device 1400 also includes one or more sensors 1410. The one or more sensors 1410 include, but are not limited to: acceleration sensor 1411 gyroscope sensor 1412, pressure sensor 1413 fingerprint sensor 1414 optical sensor 1415 and proximity sensor 1416.
The acceleration sensor 1411 detects the magnitude of acceleration on three coordinate axes of a coordinate system established with the computer apparatus 1400. For example, the acceleration sensor 1411 is used to detect the components of the gravitational acceleration in three coordinate axes. The processor 1401 can control the touch display 1405 to display a user interface in a landscape view or a portrait view according to the gravitational acceleration signal of the acceleration sensor 1411 set. The acceleration sensor 1411 may be used for acquisition of motion data of a game or a user.
The gyro sensor 1412 may detect a body direction and a rotation angle of the computer device 1400, and the gyro sensor 1412 and the acceleration sensor 1411 may collect a 3D motion of the user on the computer device 1400. The processor 1401 can realize the following functions according to the data collected by the gyro sensor 1412: motion sensing (such as changing the UI according to a user's tilting operation), image stabilization at the time of photographing, game control, and inertial navigation.
The pressure sensors 1413 may be disposed on the side bezel of the computer device 1400 and/or underneath the touch display 1405. When the pressure sensor 1413 is disposed on the side frame of the computer device 1400, a user's holding signal to the computer device 1400 can be detected, and left-right hand recognition or shortcut operation can be performed according to the holding signal. When the pressure sensor 1413 is disposed at the lower layer of the touch display screen 1405, it is possible to control an operability control on the UI interface according to a pressure operation of the user on the touch display screen 1405. The operability control comprises at least one of a button control, a scroll bar control, an icon control and a menu control.
The fingerprint sensor 1414 is used for collecting a fingerprint of a user to identify the identity of the user based on the collected fingerprint. Upon recognizing that the user's identity is a trusted identity, processor 1401 authorizes the user to perform relevant sensitive operations including unlocking the screen, viewing encrypted information, downloading software, paying for, and changing settings, etc. The fingerprint sensor 1414 may be disposed on the front, back, or side of the computer device 1400. When a physical key or vendor Logo is provided on the computer device 1400, the fingerprint sensor 1414 may be integrated with the physical key or vendor Logo.
The optical sensor 1415 is used to collect ambient light intensity. In one embodiment, processor 1401 can control the display brightness of touch display 1405 based on the ambient light intensity collected by optical sensor 1415. Specifically, when the ambient light intensity is high, the display luminance of the touch display 1405 is increased; when the ambient light intensity is low, the display brightness of the touch display 1405 is turned down. In another embodiment, the processor 1401 can also dynamically adjust the shooting parameters of the camera assembly 1406 according to the intensity of the ambient light collected by the optical sensor 1415.
Proximity sensors 1416, also known as distance sensors, are typically provided on the front side of the computer device 1400. The proximity sensor 1416 is used to capture the distance between the user and the front of the computer device 1400. In one embodiment, the touch display 1405 is controlled by the processor 1401 to switch from a bright screen state to a dark screen state when the proximity sensor 1416 detects that the distance between the user and the front of the computer device 1400 is gradually decreasing; when the proximity sensor 1416 detects that the distance between the user and the front of the computer device 1400 is gradually increasing, the processor 1401 controls the touch display 1405 to switch from the breath-screen state to the bright-screen state.
Those skilled in the art will appreciate that the architecture shown in FIG. 14 is not intended to be limiting of the computer device 1400, and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only exemplary of the present application and should not be taken as limiting, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (15)

1. A method for generating a query statement template, the method comprising:
acquiring a configuration file, wherein the configuration file comprises an entity type and a question mode, and the question mode is described by adopting a human-readable query description language;
generating a query statement template according to the entity type and the query description language;
and storing the query statement template.
2. The method of claim 1, wherein generating a query statement template from the entity type and the query description language comprises:
determining a query target according to the entity type and determining a query operation according to the query description language;
and converting the query target and the query operation into a query statement template in a machine language form.
3. The method of claim 1, wherein the questioning mode comprises: at least one of an attribute questioning mode and a relationship questioning mode;
the attribute questioning mode comprises a questioning mode for questioning the attributes of the entity;
the relationship questioning mode includes a query for a relationship between at least two entities.
4. The method of any of claims 1 to 3, further comprising:
generating a mapping relation among the sentence characteristics of the input sentences, the question mode and the query sentence template, wherein the mapping relation is used for determining the question mode to which the input sentences belong in the question and answer process;
the sentence features comprise at least one of entities containing the entity types, keywords containing the question patterns, regular expressions corresponding to the question patterns and machine identification models corresponding to the question patterns, wherein the first type of the regular expressions is identified by the machine identification models.
5. The method of claim 4, wherein the query statement templates are at least two; the method further comprises the following steps:
processing the received input statement to obtain a first statement feature corresponding to the input statement;
determining a target query statement template corresponding to the first statement feature from the at least two query statement templates according to the mapping relation;
and generating a query statement according to the input statement and the target query statement template.
6. The method of claim 4, wherein the query statement templates are at least two; the method further comprises the following steps:
processing the received input statement to obtain a first statement feature corresponding to the input statement;
responding to the fact that the target query statement template corresponding to the first statement feature cannot be determined according to the mapping relation, and obtaining a historical query statement template in a historical input statement;
and obtaining a substitute query statement template corresponding to the first statement feature according to the first statement feature and the historical query statement template.
7. The method of claim 6, wherein the obtaining an alternative query statement template corresponding to the first statement feature from the first statement feature and the historical query statement template comprises:
in response to the first statement feature including the first entity but not the first question pattern, determining a historical query statement template that includes a first entity type as the alternate query statement template, the first entity type being an entity type that the first entity has.
8. The method of claim 5, wherein generating a query statement from the input statement and the target query statement template comprises:
and substituting the first entity in the input statement into the target query statement template to obtain the query statement.
9. The method of claim 6, wherein the obtaining an alternative query statement template corresponding to the first statement feature from the first statement feature and the historical query statement template comprises:
when the first sentence characteristic comprises a first question mode but does not comprise a first entity, acquiring a second entity type of the historical input sentence;
determining a second query statement template corresponding to the first question mode and the second entity type from the at least two query statement templates according to the mapping relation;
and determining the second query statement template as the alternative query statement template.
10. The method of claim 4, wherein the query statement templates are at least two; the method further comprises the following steps:
processing the received input statement to obtain a first statement feature corresponding to the input statement;
responding to the situation that a target query statement template corresponding to the first statement feature cannot be determined according to the mapping relation, outputting a query statement according to the first statement feature, and acquiring a supplementary answer corresponding to the query statement;
extracting a third sentence characteristic in the supplementary answer;
and determining a third query statement template corresponding to the first statement feature and the third statement feature from the at least two query statement templates according to the mapping relation.
11. The method according to any one of claims 1 to 3, wherein the configuration file further comprises: the template expresses words, and the method further comprises the following steps:
and expressing characters according to the template, and generating an answer character template corresponding to the question mode.
12. The method according to any one of claims 1 to 3, wherein the obtaining the configuration file comprises:
receiving an input electronic document, the electronic document including at least one of a spreadsheet and a spreadsheet;
and acquiring the configuration file according to the electronic document.
13. An apparatus for generating a query statement template, the apparatus comprising:
the system comprises an acquisition module, a query module and a query module, wherein the acquisition module is used for acquiring a configuration file, the configuration file comprises an entity type and a question mode, and the question mode is described by adopting a human-readable query description language;
the generating module is used for generating a query statement template according to the entity type and the query description language;
and the storage module is used for storing the query statement template.
14. A computer device comprising a processor and a memory, the memory having stored therein at least one instruction, at least one program, set of codes, or set of instructions, which is loaded and executed by the processor to implement the method of generating a query statement template as claimed in any one of claims 1 to 12.
15. A computer-readable storage medium, wherein at least one instruction, at least one program, a set of codes, or a set of instructions is stored in the storage medium, and the at least one instruction, the at least one program, the set of codes, or the set of instructions is loaded and executed by a processor to implement the method for generating a query statement template according to any one of claims 1 to 12.
CN202010085006.9A 2020-02-10 2020-02-10 Query statement template generation method, device, equipment and medium Active CN111339246B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010085006.9A CN111339246B (en) 2020-02-10 2020-02-10 Query statement template generation method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010085006.9A CN111339246B (en) 2020-02-10 2020-02-10 Query statement template generation method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN111339246A true CN111339246A (en) 2020-06-26
CN111339246B CN111339246B (en) 2023-03-21

Family

ID=71181529

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010085006.9A Active CN111339246B (en) 2020-02-10 2020-02-10 Query statement template generation method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN111339246B (en)

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767381A (en) * 2020-06-30 2020-10-13 北京百度网讯科技有限公司 Automatic question answering method and device
CN111897840A (en) * 2020-08-14 2020-11-06 北京字节跳动网络技术有限公司 Data searching method and device, electronic equipment and storage medium
CN111931091A (en) * 2020-07-06 2020-11-13 广东技术师范大学 Page content display method and device, computer equipment and storage medium
CN111949782A (en) * 2020-08-07 2020-11-17 海信视像科技股份有限公司 Information recommendation method and service equipment
CN112052395A (en) * 2020-09-16 2020-12-08 北京搜狗科技发展有限公司 Data processing method and device
CN112256853A (en) * 2020-10-30 2021-01-22 深圳壹账通智能科技有限公司 Question generation method, device, equipment and computer readable storage medium
CN112269864A (en) * 2020-10-15 2021-01-26 北京百度网讯科技有限公司 Method, device and equipment for generating broadcast voice and computer storage medium
CN112581955A (en) * 2020-11-30 2021-03-30 广州橙行智动汽车科技有限公司 Voice control method, server, voice control system and readable storage medium
CN113127617A (en) * 2021-04-09 2021-07-16 厦门渊亭信息科技有限公司 Knowledge question answering method of general domain knowledge graph, terminal equipment and storage medium
CN113239009A (en) * 2021-04-08 2021-08-10 大唐软件技术股份有限公司 Database operation method, device, equipment and storage medium
CN113486151A (en) * 2021-07-13 2021-10-08 盛景智能科技(嘉兴)有限公司 Fault repair knowledge point query method and device, electronic equipment and storage medium
CN113641805A (en) * 2021-07-19 2021-11-12 北京百度网讯科技有限公司 Acquisition method of structured question-answering model, question-answering method and corresponding device
TWI800124B (en) * 2021-11-26 2023-04-21 輔仁大學學校財團法人輔仁大學 A virtual reality interactive system that uses virtual reality to simulate children's daily life training
CN117251473A (en) * 2023-11-20 2023-12-19 摩斯智联科技有限公司 Vehicle data query analysis method, system, device and storage medium
CN117708304A (en) * 2024-02-01 2024-03-15 浙江大华技术股份有限公司 Database question-answering method, equipment and storage medium
CN113641805B (en) * 2021-07-19 2024-05-24 北京百度网讯科技有限公司 Method for acquiring structured question-answering model, question-answering method and corresponding device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107918634A (en) * 2017-06-27 2018-04-17 上海壹账通金融科技有限公司 Intelligent answer method, apparatus and computer-readable recording medium
CN109492077A (en) * 2018-09-29 2019-03-19 北明智通(北京)科技有限公司 The petrochemical field answering method and system of knowledge based map
CN109684448A (en) * 2018-12-17 2019-04-26 北京北大软件工程股份有限公司 A kind of intelligent answer method
CN110349463A (en) * 2019-07-10 2019-10-18 南京硅基智能科技有限公司 A kind of reverse tutoring system and method
CN110659366A (en) * 2019-09-24 2020-01-07 Oppo广东移动通信有限公司 Semantic analysis method and device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107918634A (en) * 2017-06-27 2018-04-17 上海壹账通金融科技有限公司 Intelligent answer method, apparatus and computer-readable recording medium
CN109492077A (en) * 2018-09-29 2019-03-19 北明智通(北京)科技有限公司 The petrochemical field answering method and system of knowledge based map
CN109684448A (en) * 2018-12-17 2019-04-26 北京北大软件工程股份有限公司 A kind of intelligent answer method
CN110349463A (en) * 2019-07-10 2019-10-18 南京硅基智能科技有限公司 A kind of reverse tutoring system and method
CN110659366A (en) * 2019-09-24 2020-01-07 Oppo广东移动通信有限公司 Semantic analysis method and device, electronic equipment and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
康海燕 等: "基于问句表征的web智能问答系统" *
曾帅 等: "面向知识自动化的自动问答研究进展" *
谭刚 等: "融合领域特征知识图谱的电网客服问答系统" *

Cited By (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767381A (en) * 2020-06-30 2020-10-13 北京百度网讯科技有限公司 Automatic question answering method and device
CN111931091A (en) * 2020-07-06 2020-11-13 广东技术师范大学 Page content display method and device, computer equipment and storage medium
CN111949782A (en) * 2020-08-07 2020-11-17 海信视像科技股份有限公司 Information recommendation method and service equipment
CN111897840A (en) * 2020-08-14 2020-11-06 北京字节跳动网络技术有限公司 Data searching method and device, electronic equipment and storage medium
CN112052395A (en) * 2020-09-16 2020-12-08 北京搜狗科技发展有限公司 Data processing method and device
CN112052395B (en) * 2020-09-16 2024-03-22 北京搜狗科技发展有限公司 Data processing method and device
CN112269864A (en) * 2020-10-15 2021-01-26 北京百度网讯科技有限公司 Method, device and equipment for generating broadcast voice and computer storage medium
CN112269864B (en) * 2020-10-15 2023-06-23 北京百度网讯科技有限公司 Method, device, equipment and computer storage medium for generating broadcast voice
CN112256853A (en) * 2020-10-30 2021-01-22 深圳壹账通智能科技有限公司 Question generation method, device, equipment and computer readable storage medium
CN112581955A (en) * 2020-11-30 2021-03-30 广州橙行智动汽车科技有限公司 Voice control method, server, voice control system and readable storage medium
CN112581955B (en) * 2020-11-30 2024-03-08 广州橙行智动汽车科技有限公司 Voice control method, server, voice control system, and readable storage medium
CN113239009A (en) * 2021-04-08 2021-08-10 大唐软件技术股份有限公司 Database operation method, device, equipment and storage medium
CN113127617A (en) * 2021-04-09 2021-07-16 厦门渊亭信息科技有限公司 Knowledge question answering method of general domain knowledge graph, terminal equipment and storage medium
CN113127617B (en) * 2021-04-09 2022-09-23 厦门渊亭信息科技有限公司 Knowledge question answering method of general domain knowledge graph, terminal equipment and storage medium
CN113486151A (en) * 2021-07-13 2021-10-08 盛景智能科技(嘉兴)有限公司 Fault repair knowledge point query method and device, electronic equipment and storage medium
CN113641805A (en) * 2021-07-19 2021-11-12 北京百度网讯科技有限公司 Acquisition method of structured question-answering model, question-answering method and corresponding device
CN113641805B (en) * 2021-07-19 2024-05-24 北京百度网讯科技有限公司 Method for acquiring structured question-answering model, question-answering method and corresponding device
TWI800124B (en) * 2021-11-26 2023-04-21 輔仁大學學校財團法人輔仁大學 A virtual reality interactive system that uses virtual reality to simulate children's daily life training
CN117251473A (en) * 2023-11-20 2023-12-19 摩斯智联科技有限公司 Vehicle data query analysis method, system, device and storage medium
CN117251473B (en) * 2023-11-20 2024-03-15 摩斯智联科技有限公司 Vehicle data query analysis method, system, device and storage medium
CN117708304A (en) * 2024-02-01 2024-03-15 浙江大华技术股份有限公司 Database question-answering method, equipment and storage medium
CN117708304B (en) * 2024-02-01 2024-05-28 浙江大华技术股份有限公司 Database question-answering method, equipment and storage medium

Also Published As

Publication number Publication date
CN111339246B (en) 2023-03-21

Similar Documents

Publication Publication Date Title
CN111339246B (en) Query statement template generation method, device, equipment and medium
CN111652678B (en) Method, device, terminal, server and readable storage medium for displaying article information
CN111277706B (en) Application recommendation method and device, storage medium and electronic equipment
CN109189879B (en) Electronic book display method and device
US9411830B2 (en) Interactive multi-modal image search
CN110852100B (en) Keyword extraction method and device, electronic equipment and medium
CN110162604B (en) Statement generation method, device, equipment and storage medium
CN108270794B (en) Content distribution method, device and readable medium
CN111985240A (en) Training method of named entity recognition model, named entity recognition method and device
CN111339737B (en) Entity linking method, device, equipment and storage medium
US20200051559A1 (en) Electronic device and method for providing one or more items in response to user speech
CN113515942A (en) Text processing method and device, computer equipment and storage medium
CN111897996A (en) Topic label recommendation method, device, equipment and storage medium
US20180349820A1 (en) Topic-based place of interest discovery feed
CN110555102A (en) media title recognition method, device and storage medium
CN114281956A (en) Text processing method and device, computer equipment and storage medium
WO2023197648A1 (en) Screenshot processing method and apparatus, electronic device, and computer readable medium
CN111428522B (en) Translation corpus generation method, device, computer equipment and storage medium
CN113763931B (en) Waveform feature extraction method, waveform feature extraction device, computer equipment and storage medium
WO2021147421A1 (en) Automatic question answering method and apparatus for man-machine interaction, and intelligent device
CN112165627A (en) Information processing method, device, storage medium, terminal and system
CN111553163A (en) Text relevance determining method and device, storage medium and electronic equipment
CN116580707A (en) Method and device for generating action video based on voice
CN113486260B (en) Method and device for generating interactive information, computer equipment and storage medium
US20220326846A1 (en) Electronic device and method to provide sticker based on content input

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40024422

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant