WO2021143299A1 - 语义纠错方法、电子设备及存储介质 - Google Patents

语义纠错方法、电子设备及存储介质 Download PDF

Info

Publication number
WO2021143299A1
WO2021143299A1 PCT/CN2020/126494 CN2020126494W WO2021143299A1 WO 2021143299 A1 WO2021143299 A1 WO 2021143299A1 CN 2020126494 W CN2020126494 W CN 2020126494W WO 2021143299 A1 WO2021143299 A1 WO 2021143299A1
Authority
WO
WIPO (PCT)
Prior art keywords
entity
corrected
text data
knowledge graph
word
Prior art date
Application number
PCT/CN2020/126494
Other languages
English (en)
French (fr)
Inventor
陆江
张文
张荣斐
谢光剑
陈浩
陆世民
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2021143299A1 publication Critical patent/WO2021143299A1/zh

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/36Creation of semantic tools, e.g. ontology or thesauri
    • G06F16/367Ontology

Definitions

  • This application relates to the field of computer technology, and in particular to a semantic error correction method based on artificial intelligence (AI), electronic equipment and storage media.
  • AI artificial intelligence
  • Hot word matching methods Existing text recognition methods generally use hot word matching methods to determine user intentions. Because hot words are time-sensitive, hot word matching methods cannot correct errors in time when the text data input by the user is wrong.
  • the embodiments of the present application provide a semantic error correction method, an electronic device, and a storage medium, which can perform error correction on acquired text data with errors.
  • an embodiment of the present application provides a semantic error correction method, including: acquiring text data; extracting a first entity and a second entity in the text data, and being used to associate the first entity with the first entity; Relation words of two entities; determine the entity to be corrected from the first entity and the second entity according to the preset knowledge graph and the relationship word and the corrected entity corresponding to the entity to be corrected Entity; Determine the corrected text data according to the entity to be corrected and the entity after correction.
  • the first entity, the second entity, and the relation words used to associate the first entity and the second entity in the text data are extracted from the first entity according to the preset knowledge graph and relation words. Determine the entity to be corrected and the entity after correction corresponding to the entity to be corrected in the second entity. Since the knowledge graph includes the associated information between entities, and the associated information is relatively accurate and comprehensive, the entities to be corrected based on the knowledge graph and relation words and the entities after correction are more accurate.
  • the corrected entity and the corrected entity determine the corrected text data, so that when the text data is wrong, it can be corrected in time to identify the real intention of the user.
  • the entity to be corrected is determined from the first entity and the second entity according to the preset knowledge graph and the relation word, and the entity to be corrected is related to the entity to be corrected.
  • the corrected entity corresponds to the corrected entity, including:
  • the first entity and the third entity are related by relation words in the knowledge graph
  • the second entity and the fourth entity are related by relation words in the knowledge graph, that is, the entities and relation words extracted from the text data are compared with the knowledge graph
  • the determining the entity to be error-corrected and the entity after error correction corresponding to the entity to be error-corrected according to the third entity and the fourth entity include:
  • the first degree of similarity is greater than the second degree of similarity, that is, the degree of similarity between the first entity and the fourth entity is relatively high, it indicates that the first entity has made an error, and the first entity and the fourth entity are respectively regarded as to be corrected Entity and entity after error correction;
  • the second degree of similarity is greater than the first degree of similarity, that is, the degree of similarity between the second entity and the third entity is relatively high, it indicates that the second entity has made an error, and the second entity and the third entity are respectively regarded as to be corrected Entity and the entity after error correction.
  • the determining a third entity associated with the first entity in the knowledge graph according to the relation word, and determining that the third entity in the knowledge graph is related to the first entity The fourth entity associated with the second entity, including:
  • the synonym corresponding to the relation word is obtained from a preset synonym dictionary, and the third entity associated with the first entity in the knowledge graph is determined according to the synonym.
  • the entity, and the fourth entity associated with the second entity in the knowledge graph is determined, thereby expanding the scope of application of semantic error correction and improving the accuracy of semantic error correction.
  • the first entity is located before the relation word in the text data
  • the second entity is located after the relation word in the text data
  • the third entity associated with the first entity in the knowledge graph is determined according to the relation word, and the third entity associated with the first entity in the knowledge graph is determined according to the reverse relation word.
  • the word direction determines the fourth entity associated with the second entity in the knowledge graph, so as to improve the efficiency of semantic error correction.
  • the method before the extracting the first entity, the second entity, and the relation word used to associate the first entity and the second entity in the text data, the method also includes:
  • the extracting the first entity, the second entity, and the relation word used to associate the first entity and the second entity in the text data includes:
  • the first entity, the second entity, and the relation word used to associate the first entity and the second entity in the text data are extracted to identify the first entity and the second entity
  • the user’s intention can be determined based on the corrected text data and the user experience can be improved.
  • an embodiment of the present application provides a semantic error correction device, including:
  • An extraction module for extracting a first entity, a second entity, and relation words used to associate the first entity with the second entity in the text data
  • the determining module is configured to determine the entity to be corrected and the corrected entity corresponding to the entity to be corrected from the first entity and the second entity according to the preset knowledge graph and the relation word entity;
  • the error correction module is configured to determine the text data after error correction according to the entity to be corrected and the entity after correction.
  • the determining module includes:
  • a first determining unit configured to determine a third entity associated with the first entity in the knowledge graph according to the relationship word, and determine a fourth entity associated with the second entity in the knowledge graph;
  • the second determining unit is configured to determine, according to the third entity and the fourth entity, the entity to be corrected and the entity after correction corresponding to the entity to be corrected.
  • the determining unit is specifically configured to:
  • first degree of similarity is greater than the second degree of similarity, use the first entity and the fourth entity as the entity to be corrected and the entity after correction, respectively;
  • the second entity and the third entity are respectively regarded as the entity to be corrected and the entity after correction.
  • the determining unit is further configured to:
  • the first similarity is calculated according to the edit distance between the first entity and the fourth entity
  • the second similarity is calculated according to the edit distance between the second entity and the third entity.
  • the first determining unit is specifically configured to:
  • a third entity associated with the first entity in the knowledge graph is determined, and a fourth entity associated with the second entity in the knowledge graph is determined.
  • the first determining unit is further configured to:
  • the third entity associated with the first entity in the knowledge graph is determined according to the relation word, and the third entity associated with the first entity in the knowledge graph is determined according to the reverse relation word.
  • the word direction determines a fourth entity associated with the second entity in the knowledge graph.
  • the semantic error correction device further includes an identification module
  • the recognition module is used to perform semantic recognition on the text data
  • the extraction module is specifically used for:
  • the error correction module is further configured to:
  • the user's intention is determined according to the corrected text data.
  • an embodiment of the present application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and running on the processor, and the processor executes the computer program Time to implement the semantic error correction method as described in the first aspect above.
  • an embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the semantic correction as described in the first aspect is realized. Wrong way.
  • the embodiments of the present application provide a computer program product, which when the computer program product runs on a terminal device, causes the terminal device to execute the semantic error correction method described in the first aspect.
  • Fig. 1 is a schematic diagram of an application scenario provided by an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a semantic error correction method provided by an embodiment of the present application
  • Fig. 3 is a schematic diagram of a knowledge graph provided by an embodiment of the present application.
  • Fig. 4 is a schematic diagram of a knowledge graph provided by another embodiment of the present application.
  • FIG. 5 is a schematic flowchart of sub-steps of a semantic error correction method provided by an embodiment of the present application.
  • Fig. 6 is a schematic diagram of a knowledge graph provided by another embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of a semantic error correction device provided by an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the term “if” can be construed as “when” or “once” or “in response to determination” or “in response to detecting “.
  • the phrase “if determined” or “if detected [described condition or event]” can be interpreted as meaning “once determined” or “in response to determination” or “once detected [described condition or event]” depending on the context ]” or “in response to detection of [condition or event described]”.
  • the semantic error correction method provided by the embodiments of this application is applied to electronic devices, which can be mobile phones, tablets, wearable devices, vehicle-mounted devices, augmented reality (AR)/virtual reality (VR) devices, Notebook computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDAs), smart speakers and other terminal devices.
  • the electronic device can also be a server, and the server can be a server. Or a server cluster composed of several servers, or a cloud computing service center.
  • the embodiments of the present application do not impose any restrictions on the specific types of electronic devices.
  • the semantic error correction methods provided in the embodiments of the present application are all executed on the server 1.
  • the server 1 communicates with a terminal device 2 (such as a mobile phone), and the terminal device 2 obtains user input.
  • the voice data is sent to the server 1, and the server 1 converts the voice data into text data and recognizes the semantics of the text data. If there are semantic errors in the text data, the server 1 extracts the first entity, the second entity, and the relation words used to associate the first entity and the second entity in the text data.
  • the server 1 stores a knowledge graph, and according to the knowledge graph and relation words Determine the entity to be corrected from the first entity and the second entity and the entity to be corrected corresponding to the entity to be corrected.
  • the knowledge graph Since the knowledge graph has a high accuracy, the knowledge graph and the relation words are used to determine the entity to be corrected The accuracy of the wrong entity and the corrected entity is higher. Then, the corrected text data is determined according to the corrected entity, so that the wrong text data can be corrected in time, the user's intention can be recognized according to the corrected text data, and the corresponding operation can be performed.
  • the semantic error correction method provided in the embodiments of the present application may also be executed entirely on the terminal device, or partly executed on the server and partly executed on the terminal device.
  • the knowledge graph is stored on a terminal device, and the terminal device converts voice data into text data, determines the text data after error correction, and performs corresponding operations based on the text data after error correction.
  • the knowledge graph is stored on the server, and the terminal device converts the voice data into text data.
  • the server After extracting the first entity, the second entity and the relational words in the text data, the server will correspond to the first entity, the second entity and the relational words Send the knowledge graph of the to the terminal device, and the terminal device determines the text data after the error correction according to the knowledge graph, and executes the corresponding operation according to the text data after the error correction.
  • the semantic error correction method provided by the embodiment of the present application is all executed on the server as an example, and the semantic error correction method provided by the embodiment of the present application will be described in detail.
  • the semantic error correction method provided by the embodiment of the present application includes:
  • the text data can be input by the user into the terminal device and sent by the terminal device to the server; or the terminal device can collect voice data, send the voice data to the server, and the server converts the voice data into text data.
  • the server obtains the voice data sent by the terminal device, it performs noise reduction processing on the voice data, then extracts the voice features of the voice data, inputs the voice features into a preset voice recognition model, and then recognizes the text data.
  • S102 Perform semantic recognition on the text data.
  • the server performs semantic recognition on the text data according to a preset semantic recognition model, recognizes the user's intention corresponding to the text data, and executes the corresponding operation according to the user's intention. For example, if the recognized text data is "What news is there today", after the server searches for the news, it sends the news to the terminal device, and the terminal device plays the corresponding news.
  • the first entity, the second entity, and the relation word are extracted from the text data with the semantic error, where one relation word is associated with one A first entity and a second entity.
  • the text data is segmented first, each word in the text data is segmented, and the first entity, the second entity, and the relation word are extracted according to the part of speech of each word.
  • the subject and object in each segmented word are used as entities, or the names of persons, articles, organizations, place names, song names, or other proper nouns in the segmented words are used as entities, and then the associated words
  • the words of one entity and the second entity are regarded as the relational words.
  • the nouns between the first entity and the second entity are regarded as the relational words.
  • the relationship between the second entities determines the relationship word.
  • the entity before the relation words in the text data is defined as the first entity
  • the entity after the relation words is defined as the second entity.
  • the text data is "play song Y of singer Z”
  • the server cannot find the song Y corresponding to singer Z according to the recognized semantics, determines that there is a semantic error in the text data, and performs word segmentation on the text data to obtain "singer Z" as the name of the person , "Song Y” is the name of the song, the first entity is “Singer Z”, and the second entity is "Song Y”.
  • the relative word is determined as "sing” or "performance”.
  • the text data is "Song C sung by celebrity B, the host of program A”, the server cannot find the corresponding song based on the recognized semantics, determines that there is a semantic error in the text data, and performs word segmentation on the text data
  • "Program A "Is the name of the program
  • "work celebrity B” is the name of the person
  • "song C” is the name of the song
  • "host” and "singing” are related words
  • the related word "host” the first entity is "program A”
  • the second entity is "work celebrity B”; for the relation word “sing”, the first entity is "work celebrity B", and the second entity is "song C”.
  • the text data is input into a preset entity extraction model, and the entities and relation words in the text data are extracted.
  • the preset entity extraction model uses the text data and the text data corresponding to the first entity, second entity, and relationship words as training samples, and uses machine learning or deep learning algorithms to train the classification model.
  • the entity The extraction model can extract the first entity, the second entity and the relational words in the text data according to the input text data. For example, the text data recognized by the terminal device according to the voice is "what programs did the host and celebrity B have hosted for the program A?" According to the recognized semantics, no corresponding results are returned, and it is determined that the text data has semantic errors. Then the first entity extracted according to the entity extraction model is "program A", the second entity extracted is "work celebrity B", and the relation word is "host”.
  • S104 Determine, from the first entity and the second entity, the entity to be corrected and the entity after correction corresponding to the entity to be corrected according to the preset knowledge graph and the relation word.
  • the knowledge graph is a pre-established relationship graph used to describe the association between entities.
  • knowledge graphs for different fields.
  • it is the knowledge graph of "work celebrity L”
  • Figure 4 shows the knowledge map of "Guangdong province”.
  • the two words at both ends of each line segment are entities, and the words that associate each two entities are related words.
  • "work celebrity L” , "Actor, singer” is the entity
  • occupation” is the relative term
  • "work celebrity L” and “work celebrity Q” are the entity
  • “wife” is the relative term.
  • the first entity and the second entity extracted from the text data are compared with the entities in the knowledge graph, and the entities in the first entity and the second entity that need to be corrected are determined, and the corresponding error correction is determined from the knowledge graph Entity.
  • S104 includes S201 and S202.
  • S201 Determine a third entity associated with the first entity in the knowledge graph according to the relationship word, and determine a fourth entity associated with the second entity in the knowledge graph.
  • search for entities in the knowledge graph that are the same as the first entity and the second entity and determine the third entity in the knowledge graph corresponding to the first entity and the relation word, and the fourth entity corresponding to the second entity and the relation word, namely
  • the first entity and the third entity are located at both ends of a line segment, and the first entity and the third entity are related by relation words;
  • the second entity and the fourth entity are located at both ends of a line segment, The second entity and the fourth entity are related by a relation word.
  • the recognized text data is "what programs have been hosted by the host of program A and celebrity B", there is a semantic error, the extracted first entity is “program A”, and the second entity is "work celebrity B”.
  • the relative word is "host”.
  • the knowledge graph shown in Figure 6 has the same entity as the first entity, namely "program A”.
  • the third entity corresponding to the first entity "program A” and the relation word “host” in the knowledge graph is "work celebrity” D".
  • the fourth entity corresponding to the second entity "work celebrity B” and the relation word "host” in the knowledge graph is determined to be "program L".
  • the synonym corresponding to the relational word is obtained from the preset synonym dictionary.
  • the synonym dictionary in the thesaurus, “wife”, “wife”, and “lady” are synonyms, and “father” and “daddy” are synonyms.
  • the recognized text data is "Wang E's Dad Wang G's News”.
  • the text data has a speech error, and no corresponding result is returned. Extract the entities in the text data with semantic errors. The first entity extracted is " ⁇ E”, the second entity is " ⁇ G”, and the relation word is "Dad”.
  • a reverse word corresponding to the relation word exists in the preset reverse relation word database, it is determined according to the relation word that the knowledge graph is associated with the first entity
  • the reverse relation word database “father”, “dad” and “son” are reverse relation words, and "wife” and “husband” are reverse relation words.
  • the recognized text data is “Wang E’s Dad Wang G’s News”, and no corresponding results are returned according to the recognized semantics.
  • the extracted first entity is “Wang E” and the second entity is “Wang G”.
  • the relative word is "dad”.
  • the third entity and the fourth entity can be determined according to the subgraph matching method. For example, select the entity and relationship word with the highest similarity to the first entity and relationship word from the knowledge graph, and use another entity associated with the selected entity through the relationship word as the third entity; The entity and the relation word with the highest similarity between the second entity and the relation word use another entity associated with the selected entity through the relation word as the fourth entity.
  • S202 Determine, according to the third entity and the fourth entity, an entity to be error-corrected and an error-corrected entity corresponding to the entity to be error-corrected.
  • the entity to be corrected in the first entity and the second entity is determined. If the first entity is the entity to be corrected, the fourth entity is the entity after the correction, If the second entity is the entity to be corrected, the third entity is the entity after correction.
  • the first similarity between the first entity and the fourth entity, and the second similarity between the second entity and the third entity are calculated; if the first similarity is The degree of similarity is greater than the second degree of similarity, that is, the degree of similarity between the first entity and the fourth entity is higher, indicating that the user’s intention may be the fourth entity, but the first entity is entered by mistake.
  • the entities are respectively the entity to be corrected and the entity after correction; if the second similarity is greater than the first similarity, that is, the second entity and the third entity have a higher similarity, indicating that the user's intention may be the first Three entities, but input the second entity by mistake, and regard the second entity and the third entity as the entity to be corrected and the entity after the correction, respectively.
  • the first degree of similarity and the second degree of similarity are calculated according to the edit distance, and the edit distance is a variable used to represent the difference between two character strings.
  • the recognized text data is "what programs have been hosted by the host of program A and celebrity B", the extracted first entity is “program A”, the second entity is “work celebrity B”, and the related word is " host”.
  • the third entity is "work celebrity D” and the fourth entity is "program L”.
  • the third entity "Work Celebrity D” is regarded as the entity after correction.
  • the recognized text data is "What is the population of Shenzhen in the Special Economic Zone of Guangzhou"
  • the extracted first entity is “Guangzhou”
  • the second entity is “Shenzhen”
  • the related word is "Special Economic Zone”.
  • the edit distance between the first entity “Guangzhou” and the fourth entity “Guangdong” is greater than the edit distance between the second entity “Shenzhen” and the third entity “nonexistent", that is, the first similarity is greater than the second similarity
  • the first The entity “Guangzhou” is the entity to be corrected
  • the fourth entity “Guangdong” is the entity after the correction.
  • the recognized text data is "What's the climate of Los Angeles, the capital of the United States”, the extracted first entity is “United States”, the second entity is “Los Angeles”, and the relation word is "capital”.
  • the capital of the United States is Washington, and the second largest city in the United States is Los Angeles. Therefore, according to the knowledge graph, it is determined that the third entity corresponding to the first entity "United States” and the relational word "capital” is "Washington”, and the fourth entity corresponding to the second entity "Los Angeles” and the relational word "capital” is determined to be "does not exist".
  • S105 Determine text data after error correction according to the entity to be corrected and the entity after correction.
  • the entity to be corrected is replaced with the entity to be corrected to obtain the corrected text data, and the user's intention is determined according to the corrected text data.
  • the recognized text data is "what programs have been hosted by the host of program A and celebrity B”
  • the second entity "work celebrity B” is the entity to be corrected
  • the third entity "work celebrity D” is the error correction
  • the corrected text data is "what programs have been hosted by the host of program A and celebrity D”.
  • the server searches for the corresponding program based on the text data and sends it to the terminal device.
  • the terminal device outputs the corresponding search results in voice or text.
  • the recognized text data is "What is the population of Shenzhen in the Special Economic Zone of Guangzhou"
  • the first entity “Guangzhou” is the entity to be corrected
  • the fourth entity “Guangdong” is the entity after the correction.
  • the latter text data is "What is the population of Shenzhen, a special economic zone in Guangdong,” and the server searches for corresponding results based on the text data and sends the search results to the terminal device.
  • the entity to be corrected and the corrected entity are determined according to the knowledge graph and relational words The accuracy of the entity is high.
  • the corrected text data is determined according to the entity to be corrected and the corrected entity, so that the wrong text data input by the user can be corrected in time, and the user's intention can be accurately recognized.
  • FIG. 7 shows a structural block diagram of a semantic error correction device provided in an embodiment of the present application. For ease of description, only the parts related to the embodiment of the present application are shown.
  • the device includes:
  • the obtaining module 10 is used to obtain text data
  • the extraction module 20 is configured to extract a first entity, a second entity, and a relation word used to associate the first entity and the second entity in the text data;
  • the determining module 30 is configured to determine, from the first entity and the second entity, the entity to be corrected and the corrected entity corresponding to the entity to be corrected according to the preset knowledge graph and the relation word Entity
  • the error correction module 40 is configured to determine the text data after error correction according to the entity to be corrected and the entity after correction.
  • the determining module 30 includes:
  • a first determining unit configured to determine a third entity associated with the first entity in the knowledge graph and a fourth entity associated with the second entity in the knowledge graph according to the relationship word;
  • the second determining unit is configured to determine, according to the third entity and the fourth entity, the entity to be corrected and the entity after correction corresponding to the entity to be corrected.
  • the determining unit is specifically configured to:
  • first degree of similarity is greater than the second degree of similarity, taking the first entity and the fourth entity as the entity to be corrected and the entity after correction, respectively;
  • the second degree of similarity is greater than the first degree of similarity, the second entity and the third entity are used as the entity to be corrected and the entity after the correction, respectively.
  • the determining unit is further configured to:
  • the first similarity is calculated according to the edit distance between the first entity and the fourth entity
  • the second similarity is calculated according to the edit distance between the second entity and the third entity.
  • the first determining unit is specifically configured to:
  • a third entity associated with the first entity in the knowledge graph is determined, and a fourth entity associated with the second entity in the knowledge graph is determined.
  • the first determining unit is further configured to:
  • the third entity associated with the first entity in the knowledge graph is determined according to the relation word, and the third entity associated with the first entity in the knowledge graph is determined according to the reverse relation word.
  • the word direction determines a fourth entity associated with the second entity in the knowledge graph.
  • the semantic error correction device further includes an identification module
  • the recognition module is used to perform semantic recognition on the text data
  • the extraction module 20 is specifically configured to:
  • the error correction module 40 is also used to:
  • the user's intention is determined according to the corrected text data.
  • FIG. 8 is a schematic structural diagram of an electronic device provided by an embodiment of the application.
  • the electronic device of this embodiment includes: a processor 11 (only one processor is shown in FIG. 8), a memory 12, and a memory 12 that is stored in the memory 12 and can run on the processor 11.
  • the computer program 13 implements the steps in the above embodiment of the semantic error correction method when the processor 11 executes the computer program 13, for example, steps S101 to S105 shown in FIG. 2.
  • the functions of the modules/units in the foregoing device embodiments are implemented, for example, the functions of the acquisition module 10 to the error correction module 40 shown in FIG. 7.
  • the computer program 13 may be divided into one or more modules/units, and the one or more modules/units are stored in the memory 12 and executed by the processor 11 to complete This application.
  • the one or more modules/units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 13 in the terminal device.
  • FIG. 8 is only an example of an electronic device, and does not constitute a limitation on the electronic device. It may include more or less components than those shown in the figure, or a combination of certain components, or different components, such as
  • the electronic device may also include input and output devices, network access devices, buses, and the like.
  • the processor 11 may be a central processing unit (Central Processing Unit, CPU), other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the memory 12 may be an internal storage unit of the terminal device, such as a hard disk or memory of the terminal device.
  • the memory 12 may also be an external storage device of the terminal device, such as a plug-in hard disk equipped on the terminal device, a smart memory card (Smart Media Card, SMC), or a Secure Digital (SD) card, Flash Card, etc. Further, the memory 12 may also include both an internal storage unit of the terminal device and an external storage device.
  • the memory 12 is used to store the computer program and other programs and data required by the terminal device.
  • the memory 12 can also be used to temporarily store data that has been output or will be output.
  • the disclosed device/terminal device and method may be implemented in other ways.
  • the device/terminal device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units.
  • components can be combined or integrated into another system, or some features can be omitted or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the integrated module/unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • this application implements all or part of the processes in the above-mentioned embodiments and methods, and can also be completed by instructing relevant hardware through a computer program.
  • the computer program can be stored in a computer-readable storage medium. When the program is executed by the processor, it can implement the steps of the foregoing method embodiments.
  • the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file, or some intermediate forms.
  • the computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory) , Random Access Memory (RAM, Random Access Memory), electrical carrier signal, telecommunications signal, and software distribution media, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Animal Behavior & Ethology (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Machine Translation (AREA)

Abstract

一种基于人工智能的语义纠错方法、电子设备及存储介质,其中,语义纠错方法包括:获取文本数据,提取文本数据中的第一实体、第二实体以及用于关联第一实体和第二实体的关系词,根据预设的知识图谱和关系词从第一实体和第二实体中确定待纠错的实体以及与待纠错的实体对应的纠错后的实体,根据待纠错的实体和纠错后的实体确定纠错后的文本数据,从而实现文本数据的纠错,获取文本数据的正确语义,确定用户意图。

Description

语义纠错方法、电子设备及存储介质
本申请要求于2020年01月17日提交国家知识产权局、申请号为202010053957.8、申请名称为“语义纠错方法、电子设备及存储介质”的中国专利申请,以及于2020年05月27日提交国家知识产权局、申请号为202010461387.6、申请名称为“语义纠错方法、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及基于人工智能(Artificial Intelligence,AI)的语义纠错方法、电子设备及存储介质。
背景技术
现有的文本识别方法一般是通过热词匹配的方法来确定用户意图,由于热词具有时效性,因此通过热词匹配的方法,在用户输入的文本数据出错时不能及时纠错。
发明内容
本申请实施例提供了语义纠错方法、电子设备及存储介质,可以对获取到的出错的文本数据进行纠错。
第一方面,本申请实施例提供了一种语义纠错方法,包括:获取文本数据;提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词;根据预设的知识图谱和所述关系词从所述第一实体和所述第二实体中确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体;根据所述待纠错的实体和所述纠错后的实体确定纠错后的文本数据。
上述实施例中,通过获取文本数据,提取文本数据中的第一实体、第二实体以及用于关联第一实体和第二实体的关系词,根据预设的知识图谱和关系词从第一实体和第二实体中确定待纠错的实体以及与待纠错的实体对应的纠错后的实体。由于知识图谱包括了各实体之间的关联信息,且关联信息比较准确全面,因此根据知识图谱和关系词确定出的待纠错的实体以及纠错后的实体的准确度较高,再根据待纠错的实体和纠错后的实体确定纠错后的文本数据,从而在文本数据出错时可以及时纠正,以识别用户的真实意图。
在第一方面的一种可能的实现方式中,所述根据预设的知识图谱和所述关系词从所述第一实体和所述第二实体中确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体,包括:
根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体;根据所述第三实体和所述第四实体确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体。
其中,第一实体和第三实体在知识图谱中通过关系词关联,第二实体和第四实体在知识图谱中通过关系词关联,即将文本数据中提取的实体和关系词与知识图谱进行 对比,确定出待纠错的实体以及与待纠错的实体对应的纠错后的实体,提高了确定出的待纠错的实体以及纠错后的实体的准确度。
在第一方面的一种可能的实现方式中,所述根据所述第三实体和所述第四实体确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体,包括:
计算所述第一实体与所述第四实体的第一相似度、所述第二实体与所述第三实体的第二相似度。其中,根据所述第一实体与所述第四实体的编辑距离计算所述第一相似度,根据所述第二实体与所述第三实体的编辑距离计算所述第二相似度。
若所述第一相似度大于第二相似度,即第一实体与第四实体的相似度较高,说明第一实体出错,将所述第一实体和所述第四实体分别作为待纠错的实体以及纠错后的实体;
若所述第二相似度大于第一相似度,即第二实体与第三实体的相似度较高,说明第二实体出错,将所述第二实体和所述第三实体分别作为待纠错的实体以及纠错后的实体。
在第一方面的一种可能的实现方式中,所述根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体,包括:
若所述知识图谱中不存在所述关系词,从预设的同义词词库获取与所述关系词对应的同义词,根据所述同义词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体,从而扩大语义纠错的适用范围,提高语义纠错的准确率。
在第一方面的一种可能的实现方式中,所述第一实体在所述文本数据中位于所述关系词之前,所述第二实体在所述文本数据中位于所述关系词之后,所述根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,确定所述知识图谱中与所述第二实体关联的第四实体,包括:
若预设的反向关系词词库中存在与所述关系词对应的反向词,根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,根据所述反向词确定所述知识图谱中与所述第二实体关联的第四实体,以提高语义纠错的效率。
在第一方面的一种可能的实现方式中,在所述提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词之前,所述方法还包括:
对所述文本数据进行语义识别;
对应地,所述提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词,包括:
若所述文本数据存在语义错误,提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词。
上述实施例中,在文本数据存在语义错误时,提取文本数据中的第一实体、第二实体以及用于关联第一实体和第二实体的关系词,以识别出第一实体和第二实体中错误的实体,从而纠正存在语义错误的文本数据,以根据纠错后的文本数据确定用户意图,提高用户体验。
第二方面,本申请实施例提供了一种语义纠错装置,包括:
获取模块,用于获取文本数据;
提取模块,用于提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词;
确定模块,用于根据预设的知识图谱和所述关系词从所述第一实体和所述第二实体中确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体;
纠错模块,用于根据所述待纠错的实体和所述纠错后的实体确定纠错后的文本数据。
在第二方面的一种可能的实现方式中,所述确定模块包括:
第一确定单元,用于根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体;
第二确定单元,用于根据所述第三实体和所述第四实体确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体。
在第二方面的一种可能的实现方式中,所述确定单元具体用于:
计算所述第一实体与所述第四实体的第一相似度、所述第二实体与所述第三实体的第二相似度;
若所述第一相似度大于第二相似度,将所述第一实体和所述第四实体分别作为待纠错的实体以及纠错后的实体;
若所述第二相似度大于第一相似度,将所述第二实体和所述第三实体分别作为待纠错的实体以及纠错后的实体。
在第二方面的一种可能的实现方式中,所述确定单元还用于:
根据所述第一实体与所述第四实体的编辑距离计算所述第一相似度,根据所述第二实体与所述第三实体的编辑距离计算所述第二相似度。
在第二方面的一种可能的实现方式中,所述第一确定单元具体用于:
若所述知识图谱中不存在所述关系词,从预设的同义词词库获取与所述关系词对应的同义词;
根据所述同义词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体。
在第二方面的一种可能的实现方式中,所述第一确定单元还用于:
若预设的反向关系词词库中存在与所述关系词对应的反向词,根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,根据所述反向词确定所述知识图谱中与所述第二实体关联的第四实体。
在第二方面的一种可能的实现方式中,所述语义纠错装置还包括识别模块,
所述识别模块用于对所述文本数据进行语义识别;
对应地,所述提取模块具体用于:
若所述文本数据存在语义错误,提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词。
在第二方面的一种可能的实现方式中,所述纠错模块还用于:
根据所述纠错后的文本数据确定用户意图。
第三方面,本申请实施例提供了一种电子设备,包括:存储器、处理器以及存储 在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上述第一方面所述的语义纠错方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现如上述第一方面所述的语义纠错方法。
第五方面,本申请实施例提供了一种计算机程序产品,当计算机程序产品在终端设备上运行时,使得终端设备执行上述第一方面所述的语义纠错方法。
可以理解的是,上述第二方面至第五方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。
附图说明
图1是本申请一实施例提供的应用场景示意图;
图2是本申请实施例提供的语义纠错方法的流程示意图;
图3是本申请一实施例提供的知识图谱的示意图;
图4是本申请另一实施例提供的知识图谱的示意图;
图5是本申请实施例提供的语义纠错方法的子步骤的流程示意图;
图6是本申请又一实施例提供的知识图谱的示意图;
图7是本申请实施例提供的语义纠错装置的结构示意图;
图8是本申请实施例提供的电子设备的结构示意图。
具体实施方式
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。
应当理解,当在本申请说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。
还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
如在本申请说明书和所附权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。类似地,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述条件或事件]”或“响应于检测到[所描述条件或事件]”。
在本申请说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。
另外,在本申请说明书和所附权利要求书的描述中,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。
本申请实施例提供的语义纠错方法应用于电子设备,电子设备可以是手机、平板 电脑、可穿戴设备、车载设备、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)、智能音箱等终端设备,电子设备也可以是服务器,服务器可以是一台服务器,或者由若干台服务器组成的服务器集群,或者是一个云计算服务中心。本申请实施例对电子设备的具体类型不作任何限制。
如图1所示,在一种可能的实现方式中,本申请实施例提供的语义纠错方法全部执行于服务器1,服务器1与终端设备2(例如手机)通讯连接,终端设备2获取用户输入的语音数据,将语音数据发送至服务器1,服务器1将语音数据转换为文本数据,并识别文本数据的语义。若文本数据存在语义错误,服务器1提取文本数据中的第一实体、第二实体以及用于关联第一实体和第二实体的关系词,服务器1上存储有知识图谱,根据知识图谱和关系词从第一实体和第二实体中确定待纠错的实体以及与待纠错的实体对应的纠错后的实体,由于知识图谱的准确度较高,根据知识图谱和关系词确定出的待纠错的实体以及纠错后的实体的准确度较高。再根据纠错后的实体确定纠错后的文本数据,从而可以及时纠正出错的文本数据,根据纠错后的文本数据识别用户意图,执行对应的操作。
需要说明的是,在其它可能的实现方式中,本申请实施例提供的语义纠错方法也可以全部执行于终端设备,或者部分执行于服务器,部分执行于终端设备。例如,知识图谱存储于终端设备上,终端设备将语音数据转化为文本数据,确定纠错后的文本数据,根据纠错后的文本数据执行对应的操作。或者,知识图谱存储于服务器上,终端设备将语音数据转化为文本数据,提取文本数据中的第一实体、第二实体以及关系词后,服务器根据第一实体、第二实体以及关系词将对应的知识图谱发送至终端设备,终端设备根据知识图谱确定出纠错后的文本数据,根据纠错后的文本数据执行对应的操作。
下面以本申请实施例提供的语义纠错方法全部执行于服务器为例,对本申请实施例提供的语义纠错方法进行详细描述。
如图2所示,本申请实施例提供的语义纠错方法包括:
S101:获取文本数据。
其中,文本数据可以是由用户输入终端设备,并由终端设备发送至服务器;也可以是由终端设备采集语音数据,将语音数据发送至服务器,服务器再将语音数据转换为文本数据。具体地,服务器获取终端设备发送的语音数据后,对语音数据进行降噪处理,再提取语音数据的语音特征,将语音特征输入预设的语音识别模型中,进而识别出文本数据。
S102:对所述文本数据进行语义识别。
具体的,服务器根据预设的语义识别模型对文本数据进行语义识别,识别出文本数据对应的用户意图,根据用户意图执行对应的操作。例如,若识别出的文本数据为“今天有什么新闻”,服务器搜索新闻后,将新闻发送至终端设备,终端设备播放对应的新闻。
S103:若所述文本数据存在语义错误,提取所述文本数据中的第一实体、第二实 体以及用于关联所述第一实体和所述第二实体的关系词。
具体地,若文本数据存在语义错误,即根据识别出的语义无法执行对应的操作,从存在语义错误的文本数据中提取出第一实体、第二实体及关系词,其中,一个关系词关联一个第一实体和一个第二实体。
在一种可能的实现方式中,若文本数据存在语义错误,首先对文本数据进行分词,分割出文本数据中的各个词语,根据每个词语的词性提取第一实体、第二实体及关系词。示例性地,将分割出的各个词语中的主语、宾语作为实体,或者将分割出的词语中的人名、物品名、机构名、地名、歌曲名或其它专有名词作为实体,再将关联第一实体和第二实体的词语作为关系词,示例性地,将第一实体和第二实体之间的名词作为关系词,若第一实体和第二实体之间没有名词,根据第一实体和第二实体之间的关系确定关系词。提取关系词和实体后,将文本数据中位于关系词之前的实体定义为第一实体,位于关系词之后的实体定义为第二实体。例如,文本数据为“播放歌手Z演唱的歌曲Y”,服务器根据识别出的语义无法找到歌手Z对应的歌曲Y,确定文本数据存在语义错误,对文本数据进行分词,得到“歌手Z”为人名,“歌曲Y”为歌曲名,第一实体为“歌手Z”,第二实体为“歌曲Y”,关系词为“演唱”。又例如,文本数据为“播放歌手Z的歌曲Y”,服务器根据识别出的语义无法找到歌手Z对应的歌曲Y,确定文本数据存在语义错误,对文本数据进行分词,得到“歌手Z”为人名,“歌曲Y”为歌曲名,第一实体为“歌手Z”,第二实体为“歌曲Y”,根据人名和歌曲名确定出关系词为“演唱”或者“表演”。又例如,文本数据为“播放节目A的主持人工作名人B演唱的歌曲C”,服务器根据识别出的语义无法找到对应的歌曲,确定文本数据存在语义错误,对文本数据进行分词,“节目A”为节目名称,“工作名人B”为人名,“歌曲C”为歌曲名,“主持人”、“演唱”为关系词,对于关系词“主持人”,第一实体为“节目A”,第二实体为“工作名人B”;对于关系词“演唱”,第一实体为“工作名人B”,第二实体为“歌曲C”。
在另一种可能的实现方式中,若文本数据存在语义错误,将文本数据输入预设的实体提取模型中,提取出文本数据中的实体和关系词。其中,预设的实体提取模型是以文本数据和文本数据对应的第一实体、第二实体、关系词为训练样本,采用机器学习或者深度学习的算法,对分类模型进行训练后得到的,实体提取模型根据输入的文本数据可以提取出文本数据中的第一实体、第二实体和关系词。例如,终端设备根据语音识别出的文本数据为“节目A的主持人工作名人B还主持过哪些节目”,根据识别出的语义,没有对应的结果返回,确定文本数据存在语义错误。则根据实体提取模型提取出的第一实体为“节目A”,提取出的第二实体为“工作名人B”,关系词为“主持人”。
S104:根据预设的知识图谱和所述关系词从所述第一实体和所述第二实体中确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体。
其中,知识图谱是预先建立的用于描述各实体之间的关联的关系图,对于不同的领域有不同的知识图谱,例如,如图3所示,为“工作名人L”的知识图谱,如图4所示,为“广东省”的知识图谱,知识图谱中每条线段两端的两个词语为实体,关联每两个实体的词语为关系词,例如,图3中,“工作名人L”、“演员、歌星”为实体,“职业”为关系词,“工作名人L”、“工作名人Q”为实体,“妻子”为关系词。图4中,“广东省”、“广州”为实体,“省会”为关系词,“广东省”、“深圳”为实体,“经济特区”为关系词。需 要说明的是,图3和图4仅为知识图谱的一部分。
将文本数据中提取出的第一实体和第二实体与知识图谱中的实体进行对比,确定出第一实体和第二实体中需要纠错的实体,从知识图谱中确定出对应的纠错后的实体。
在一种可能的实现方式中,如图5所示,S104包括S201和S202。
S201:根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体。
具体地,搜索知识图谱中与第一实体和第二实体相同的实体,确定知识图谱中与第一实体和关系词对应的第三实体,与第二实体和关系词对应的第四实体,即在知识图谱中,第一实体和第三实体位于一条线段的两端,第一实体和第三实体通过关系词关联;在知识图谱中,第二实体和第四实体位于一条线段的两端,第二实体和第四实体通过关系词关联。
例如,识别出的文本数据为“节目A的主持人工作名人B还主持过哪些节目”,存在语义错误,提取出的第一实体为“节目A”,第二实体为“工作名人B”,关系词为“主持人”。图6所示的知识图谱中存在与第一实体相同的实体,即“节目A”,第一实体“节目A”和关系词“主持人”在知识图谱中对应的第三实体为“工作名人D”。同理,确定第二实体“工作名人B”和关系词“主持人”在知识图谱中对应的第四实体为“节目L”。
在一种可能的实现方式中,若知识图谱中不存在与文本数据中相同的关系词,从预设的同义词词库获取与关系词对应的同义词。示例性的,同义词库中“妻子”、“老婆”、“夫人”为同义词,“父亲”、“爸爸”为同义词。例如,识别出的文本数据为“王E的爸爸王G的新闻”,根据识别出的语义,文本数据存在语音错误,没有对应的结果返回。提取存在语义错误的文本数据中的实体,提取出的第一实体为“王E”,第二实体为“王G”,关系词为“爸爸”,搜索出知识图谱中与第一实体相同的实体“王E”,“王E”对应的关系词中不存在“爸爸”,同义词库中存在“爸爸”的同义词“父亲”,则将“爸爸”替换为同义词“父亲”,根据第一实体“王E”和关系词“父亲”在知识图谱中确定出的第三实体为“王H”。
在一种可能的实现方式中,若预设的反向关系词词库中存在与所述关系词对应的反向词,根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,根据所述反向词确定所述知识图谱中与所述第二实体关联的第四实体。示例性地,反向关系词库中,“父亲”、“爸爸”与“儿子”为反向关系词,“妻子”与“丈夫”为反向关系词。例如,识别出的文本数据为“王E的爸爸王G的新闻”,根据识别出的语义,没有对应的结果返回,提取出的第一实体为“王E”,第二实体为“王G”,关系词为“爸爸”。反向关系词词库中,存在与“爸爸”对应的反向词“儿子”,根据第一实体“王E”和关系词“爸爸”从知识图谱中确定出的第三实体为“王H”,根据第二实体“王G”和反向词“儿子”从知识图谱中确定出的第四实体为“王T”。
在其它可能的实现方式中,若从文本数据中提取的第一实体、第二实体不存在于知识图谱中,可以根据子图匹配的方法确定第三实体和第四实体。例如,从知识图谱中选择出与第一实体和关系词相似度最高的实体和关系词,将与选择出的实体通过关系词关联的另一个实体作为第三实体;从知识图谱汇总选择出与第二实体和关系词相似度最高的实体和关系词,将与选择出的实体通过关系词关联的另一个实体作为第四 实体。
S202:根据所述第三实体和所述第四实体确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体。
具体地,根据第三实体和第四实体,确定出第一实体和第二实体中待纠错的实体,若第一实体为待纠错的实体,则第四实体为纠错后的实体,若第二实体为待纠错的实体,则第三实体为纠错后的实体。
在一种可能的实现方式中,计算所述第一实体与所述第四实体的第一相似度、所述第二实体与所述第三实体的第二相似度;若所述第一相似度大于第二相似度,即第一实体与第四实体的相似度较高,说明用户的意图有可能是第四实体,却误输入第一实体,将所述第一实体和所述第四实体分别作为待纠错的实体以及纠错后的实体;若所述第二相似度大于第一相似度,即第二实体与第三实体的相似度较高,说明用户的意图有可能是第三实体,却误输入第二实体,将所述第二实体和所述第三实体分别作为待纠错的实体以及纠错后的实体。其中,第一相似度和第二相似度是根据编辑距离来进行计算的,编辑距离是用于表示两个字符串之间的差异的变量。
例如,识别出的文本数据为“节目A的主持人工作名人B还主持过哪些节目”,提取出的第一实体为“节目A”,第二实体为“工作名人B”,关系词为“主持人”。若根据知识图谱,第三实体为“工作名人D”,第四实体为“节目L”。计算第一实体“节目A”和第四实体“节目L”的编辑距离,第二实体“工作名人B”和第三实体“工作名人D”的编辑距离。若字符串“工作名人B”和字符串“工作名人D”之间的差异,大于字符串“节目A”和字符串“节目L”之间的差异,则第二实体“工作名人B”和第三实体“工作名人D”的编辑距离大于第一实体“节目A”和第四实体“节目L”的编辑距离,即第二相似度大于第一相似度,将第二实体“工作名人B”作为待纠错的实体,将第三实体“工作名人D”作为纠错后的实体。
又例如,识别出的文本数据为“广州的经济特区深圳的人口数量是多少”,提取出的第一实体为“广州”,第二实体为“深圳”,关系词为“经济特区”,在知识图谱中没有与第一实体“广州”和关系词“经济特区”对应的实体,即确定出的第三实体为“空”或者“不存在”,根据第二实体“深圳”和关系词“经济特区”确定出的第四实体为“广东”。由于第一实体“广州”和第四实体“广东”的编辑距离大于第二实体“深圳”和第三实体“不存在”的编辑距离,即第一相似度大于第二相似度,将第一实体“广州”作为待纠错的实体,将第四实体“广东”作为纠错后的实体。
又例如,识别出的文本数据为“美国的首都洛杉矶的气候怎样”,提取出的第一实体为“美国”,第二实体为“洛杉矶”,关系词为“首都”。知识图谱中,美国的首都是华盛顿,美国第二大的城市是洛杉矶。因此,根据知识图谱,确定出与第一实体“美国”和关系词“首都”对应的第三实体为“华盛顿”,与第二实体“洛杉矶”和关系词“首都”对应的第四实体为“不存在”。由于第一实体“美国”和第四实体为“不存在”的编辑距离小于第二实体“洛杉矶”和第三实体为“华盛顿”的编辑距离,即第一相似度小于第二相似度,将第二实体“洛杉矶”作为待纠错的实体,将第三实体“华盛顿”作为纠错后的实体。
S105:根据所述待纠错的实体和所述纠错后的实体确定纠错后的文本数据。
具体地,用纠错后的实体替换待纠错的实体,得到纠错后的文本数据,根据纠错后的文本数据确定用户意图。例如,识别出的文本数据为“节目A的主持人工作名人B还主持过哪些节目”,第二实体“工作名人B”为待纠错的实体,第三实体“工作名人D”为纠错后的实体,则纠错后的文本数据为“节目A的主持人工作名人D还主持过哪些节目”,服务器根据文本数据搜索对应的节目,并发送至终端设备。终端设备以语音或文本的方式输出对应的搜索结果。又例如,识别出的文本数据为“广州的经济特区深圳的人口数量是多少”,第一实体“广州”为待纠错的实体,第四实体“广东”作为纠错后的实体,纠错后的文本数据为“广东的经济特区深圳的人口数量是多少”,服务器根据文本数据搜索对应的结果,并将搜索结果发送至终端设备。
上述实施例中,通过提取文本数据中的第一实体、第二实体以及用于关联第一实体和第二实体的关系词,根据预设的知识图谱和关系词从第一实体和第二实体中确定待纠错的实体以及与待纠错的实体对应的纠错后的实体,由于知识图谱的准确度较高,根据知识图谱和关系词确定出的待纠错的实体以及纠错后的实体的准确度较高。再根据待纠错的实体和纠错后的实体确定纠错后的文本数据,从而可以及时纠正用户输入的错误的文本数据,准确识别出用户意图。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
对应于上文实施例所述的语义纠错方法,图7示出了本申请实施例提供的语义纠错装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。
参照图7,该装置包括:
获取模块10,用于获取文本数据;
提取模块20,用于提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词;
确定模块30,用于根据预设的知识图谱和所述关系词从所述第一实体和所述第二实体中确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体;
纠错模块40,用于根据所述待纠错的实体和所述纠错后的实体确定纠错后的文本数据。
在一种可能的实现方式中,所述确定模块30包括:
第一确定单元,用于根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体;
第二确定单元,用于根据所述第三实体和所述第四实体确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体。
在一种可能的实现方式中,所述确定单元具体用于:
计算所述第一实体与所述第四实体的第一相似度、所述第二实体与所述第三实体的第二相似度;
若所述第一相似度大于第二相似度,将所述第一实体和所述第四实体分别作为待纠错的实体以及纠错后的实体;
若所述第二相似度大于第一相似度,将所述第二实体和所述第三实体分别作为待 纠错的实体以及纠错后的实体。
在一种可能的实现方式中,所述确定单元还用于:
根据所述第一实体与所述第四实体的编辑距离计算所述第一相似度,根据所述第二实体与所述第三实体的编辑距离计算所述第二相似度。
在一种可能的实现方式中,所述第一确定单元具体用于:
若所述知识图谱中不存在所述关系词,从预设的同义词词库获取与所述关系词对应的同义词;
根据所述同义词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体。
在一种可能的实现方式中,所述第一确定单元还用于:
若预设的反向关系词词库中存在与所述关系词对应的反向词,根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,根据所述反向词确定所述知识图谱中与所述第二实体关联的第四实体。
在一种可能的实现方式中,所述语义纠错装置还包括识别模块,
所述识别模块用于对所述文本数据进行语义识别;
对应地,所述提取模块20具体用于:
若所述文本数据存在语义错误,提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词。
在一种可能的实现方式中,所述纠错模块40还用于:
根据所述纠错后的文本数据确定用户意图。
需要说明的是,上述装置/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。
图8为本申请一实施例提供的电子设备的结构示意图。如图8所示,该实施例的电子设备包括:处理器11(图8中仅示出一个处理器)、存储器12以及存储在所述存储器12中并可在所述处理器11上运行的计算机程序13,所述处理器11执行所述计算机程序13时实现上述语义纠错方法实施例中的步骤,例如图2所示的步骤S101至S105。或者,所述处理器11执行所述计算机程序13时实现上述各装置实施例中各模块/单元的功能,例如图7所示获取模块10至纠错模块40的功能。
示例性的,所述计算机程序13可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器12中,并由所述处理器11执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序13在所述终端设备中的执行过程。
本领域技术人员可以理解,图8仅仅是电子设备的示例,并不构成对电子设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述电子设备还可以包括输入输出设备、网络接入设备、总线等。
所述处理器11可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable  Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
所述存储器12可以是所述终端设备的内部存储单元,例如终端设备的硬盘或内存。所述存储器12也可以是所述终端设备的外部存储设备,例如所述终端设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器12还可以既包括所述终端设备的内部存储单元也包括外部存储设备。所述存储器12用于存储所述计算机程序以及所述终端设备所需的其他程序和数据。所述存储器12还可以用于暂时地存储已经输出或者将要输出的数据。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
在本申请所提供的实施例中,应该理解到,所揭露的装置/终端设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/终端设备实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。

Claims (10)

  1. 一种语义纠错方法,其特征在于,包括:
    获取文本数据;
    提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词;
    根据预设的知识图谱和所述关系词从所述第一实体和所述第二实体中确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体;
    根据所述待纠错的实体和所述纠错后的实体确定纠错后的文本数据。
  2. 如权利要求1所述的语义纠错方法,其特征在于,所述根据预设的知识图谱和所述关系词从所述第一实体和所述第二实体中确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体,包括:
    根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体;
    根据所述第三实体和所述第四实体确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体。
  3. 如权利要求2所述的语义纠错方法,其特征在于,所述根据所述第三实体和所述第四实体确定待纠错的实体以及与所述待纠错的实体对应的纠错后的实体,包括:
    计算所述第一实体与所述第四实体的第一相似度、所述第二实体与所述第三实体的第二相似度;
    若所述第一相似度大于所述第二相似度,将所述第一实体和所述第四实体分别作为待纠错的实体以及纠错后的实体;
    若所述第二相似度大于所述第一相似度,将所述第二实体和所述第三实体分别作为待纠错的实体以及纠错后的实体。
  4. 如权利要求3所述的语义纠错方法,其特征在于,所述计算所述第一实体与所述第四实体的第一相似度、所述第二实体与所述第三实体的第二相似度,包括:
    根据所述第一实体与所述第四实体的编辑距离计算所述第一相似度,根据所述第二实体与所述第三实体的编辑距离计算所述第二相似度。
  5. 如权利要求2至4任一项所述的语义纠错方法,其特征在于,所述根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体,包括:
    若所述知识图谱中不存在所述关系词,从预设的同义词词库获取与所述关系词对应的同义词;
    根据所述同义词确定所述知识图谱中与所述第一实体关联的第三实体,以及,确定所述知识图谱中与所述第二实体关联的第四实体。
  6. 如权利要求2所述的语义纠错方法,其特征在于,所述第一实体在所述文本数据中位于所述关系词之前,所述第二实体在所述文本数据中位于所述关系词之后,所述根据所述关系词确定所述知识图谱中与所述第一实体关联的第三实体,确定所述知识图谱中与所述第二实体关联的第四实体,包括:
    若预设的反向关系词词库中存在与所述关系词对应的反向词,根据所述关系词确 定所述知识图谱中与所述第一实体关联的第三实体,根据所述反向词确定所述知识图谱中与所述第二实体关联的第四实体。
  7. 如权利要求1至6任一项所述的语义纠错方法,其特征在于,在所述提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词之前,所述方法还包括:
    对所述文本数据进行语义识别;
    对应地,所述提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词,包括:
    若所述文本数据存在语义错误,提取所述文本数据中的第一实体、第二实体以及用于关联所述第一实体和所述第二实体的关系词。
  8. 如权利要求1至6任一项所述的语义纠错方法,其特征在于,在所述根据所述待纠错的实体和所述纠错后的实体确定纠错后的文本数据之后,所述方法还包括:
    根据所述纠错后的文本数据确定用户意图。
  9. 一种电子设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至8任一项所述的方法。
  10. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至8任一项所述的方法。
PCT/CN2020/126494 2020-01-17 2020-11-04 语义纠错方法、电子设备及存储介质 WO2021143299A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202010053957.8A CN111291571A (zh) 2020-01-17 2020-01-17 语义纠错方法、电子设备及存储介质
CN202010053957.8 2020-01-17
CN202010461387.6A CN113139387A (zh) 2020-01-17 2020-05-27 语义纠错方法、电子设备及存储介质
CN202010461387.6 2020-05-27

Publications (1)

Publication Number Publication Date
WO2021143299A1 true WO2021143299A1 (zh) 2021-07-22

Family

ID=71029073

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/126494 WO2021143299A1 (zh) 2020-01-17 2020-11-04 语义纠错方法、电子设备及存储介质

Country Status (2)

Country Link
CN (2) CN111291571A (zh)
WO (1) WO2021143299A1 (zh)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111291571A (zh) * 2020-01-17 2020-06-16 华为技术有限公司 语义纠错方法、电子设备及存储介质
CN112016305B (zh) * 2020-09-09 2023-03-28 平安科技(深圳)有限公司 文本纠错方法、装置、设备及存储介质
CN112466307B (zh) * 2020-11-19 2023-09-26 珠海格力电器股份有限公司 语音的回复方法和装置、存储介质、电子装置
CN112380848B (zh) * 2020-11-19 2022-04-26 平安科技(深圳)有限公司 文本生成方法、装置、设备及存储介质
CN113591457B (zh) * 2021-07-30 2023-10-24 平安科技(深圳)有限公司 文本纠错方法、装置、设备及存储介质
CN114048321A (zh) * 2021-08-12 2022-02-15 湖南达德曼宁信息技术有限公司 一种多粒度文本纠错数据集生成方法、装置及设备
CN113938708B (zh) * 2021-10-14 2024-04-09 咪咕文化科技有限公司 直播的音频纠错方法、装置、计算设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030220917A1 (en) * 2002-04-03 2003-11-27 Max Copperman Contextual search
CN109508390A (zh) * 2018-12-28 2019-03-22 北京金山安全软件有限公司 基于知识图谱的输入预测方法、装置和电子设备
CN109918640A (zh) * 2018-12-22 2019-06-21 浙江工商大学 一种基于知识图谱的中文文本校对方法
CN110309258A (zh) * 2018-03-15 2019-10-08 中国移动通信集团有限公司 一种输入检查方法、服务器和计算机可读存储介质
CN110489496A (zh) * 2019-07-22 2019-11-22 腾讯科技(深圳)有限公司 一种数据处理方法、装置、电子设备及存储介质
CN111291571A (zh) * 2020-01-17 2020-06-16 华为技术有限公司 语义纠错方法、电子设备及存储介质

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101965887B1 (ko) * 2017-04-07 2019-07-05 주식회사 카카오 대량 데이터 기반 의미 오류 교정 규칙 생성 및 의미 오류 교정 방법, 이를 구현한 오류 교정 시스템
CN107741928B (zh) * 2017-10-13 2021-01-26 四川长虹电器股份有限公司 一种基于领域识别的对语音识别后文本纠错的方法
US10650098B2 (en) * 2018-06-26 2020-05-12 International Business Machines Corporation Content analyzer and recommendation tool
CN109522465A (zh) * 2018-10-22 2019-03-26 国家电网公司 基于知识图谱的语义搜索方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030220917A1 (en) * 2002-04-03 2003-11-27 Max Copperman Contextual search
CN110309258A (zh) * 2018-03-15 2019-10-08 中国移动通信集团有限公司 一种输入检查方法、服务器和计算机可读存储介质
CN109918640A (zh) * 2018-12-22 2019-06-21 浙江工商大学 一种基于知识图谱的中文文本校对方法
CN109508390A (zh) * 2018-12-28 2019-03-22 北京金山安全软件有限公司 基于知识图谱的输入预测方法、装置和电子设备
CN110489496A (zh) * 2019-07-22 2019-11-22 腾讯科技(深圳)有限公司 一种数据处理方法、装置、电子设备及存储介质
CN111291571A (zh) * 2020-01-17 2020-06-16 华为技术有限公司 语义纠错方法、电子设备及存储介质

Also Published As

Publication number Publication date
CN113139387A (zh) 2021-07-20
CN111291571A (zh) 2020-06-16

Similar Documents

Publication Publication Date Title
WO2021143299A1 (zh) 语义纠错方法、电子设备及存储介质
US11301637B2 (en) Methods, devices, and systems for constructing intelligent knowledge base
US10657325B2 (en) Method for parsing query based on artificial intelligence and computer device
WO2019184217A1 (zh) 热点事件分类方法、装置及存储介质
WO2022121171A1 (zh) 相似文本匹配方法、装置、电子设备及计算机存储介质
WO2021135455A1 (zh) 语义召回方法、装置、计算机设备及存储介质
CN111460170B (zh) 一种词语识别方法、装置、终端设备及存储介质
WO2022134360A1 (zh) 基于词嵌入的模型训练方法、装置、电子设备及存储介质
CN110569328A (zh) 实体链接方法、电子装置及计算机设备
CN110134965B (zh) 用于信息处理的方法、装置、设备和计算机可读存储介质
WO2021135603A1 (zh) 意图识别方法、服务器及存储介质
CN112329460A (zh) 文本的主题聚类方法、装置、设备及存储介质
WO2021218087A1 (zh) 基于人工智能的意图识别的方法、装置、计算机设备
CN110569289A (zh) 基于大数据的列数据处理方法、设备及介质
CN111859013A (zh) 数据处理方法、装置、终端和存储介质
CN108875743B (zh) 一种文本识别方法及装置
CN114398968B (zh) 基于文件相似度对同类获客文件进行标注的方法和装置
CN114330335A (zh) 关键词抽取方法、装置、设备及存储介质
CN113408660B (zh) 图书聚类方法、装置、设备和存储介质
CN111814481B (zh) 购物意图识别方法、装置、终端设备及存储介质
CN112748811A (zh) 一种英文单词输入方法及装置
CN112541357B (zh) 实体识别方法、装置及智能设备
CN116542246A (zh) 基于关键词质检文本的方法、装置和电子设备
WO2022257455A1 (zh) 一种相似文本的确定方法、装置、终端设备及存储介质
WO2022198747A1 (zh) 三元组信息的抽取方法、装置、电子设备和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20913679

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20913679

Country of ref document: EP

Kind code of ref document: A1