CN112560477A - Text completion method, electronic device and storage device - Google Patents

Text completion method, electronic device and storage device Download PDF

Info

Publication number
CN112560477A
CN112560477A CN202011452090.XA CN202011452090A CN112560477A CN 112560477 A CN112560477 A CN 112560477A CN 202011452090 A CN202011452090 A CN 202011452090A CN 112560477 A CN112560477 A CN 112560477A
Authority
CN
China
Prior art keywords
text
word
candidate
words
missing
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
CN202011452090.XA
Other languages
Chinese (zh)
Other versions
CN112560477B (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.)
Hebei Xunfei Institute Of Artificial Intelligence
Zhongke Xunfei Internet Beijing Information Technology Co ltd
iFlytek Co Ltd
Original Assignee
Hebei Xunfei Institute Of Artificial Intelligence
Zhongke Xunfei Internet Beijing Information Technology Co ltd
iFlytek 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 Hebei Xunfei Institute Of Artificial Intelligence, Zhongke Xunfei Internet Beijing Information Technology Co ltd, iFlytek Co Ltd filed Critical Hebei Xunfei Institute Of Artificial Intelligence
Priority to CN202011452090.XA priority Critical patent/CN112560477B/en
Publication of CN112560477A publication Critical patent/CN112560477A/en
Application granted granted Critical
Publication of CN112560477B publication Critical patent/CN112560477B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/232Orthographic correction, e.g. spell checking or vowelisation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Machine Translation (AREA)

Abstract

The application discloses a text completion method, electronic equipment and a storage device, wherein the text completion method comprises the following steps: acquiring a text to be completed, and determining a text library from which missing contents of the text to be completed originate; the full text to be supplemented comprises at least one missing position, and the text library relates to the field of preset knowledge; performing completion prediction on a text to be completed by using a knowledge map and a text library corresponding to a preset knowledge field to obtain at least one candidate word at a missing position; and obtaining a complete text of the text to be completed by using the candidate segments of each missing position. According to the scheme, the efficiency of text completion can be improved, and the cost of text completion can be reduced.

Description

Text completion method, electronic device and storage device
Technical Field
The present application relates to the field of natural language processing technologies, and in particular, to a text completion method, an electronic device, and a storage device.
Background
With the development of information technology, text transmission via various networks such as wired/wireless networks has become one of the main means for communication in daily life and work. For example, text messages such as short messages and instant messaging messages are sent to friends and colleagues through mobile phones and tablet computers.
However, in the links of sending, saving, displaying and the like, the text may have partial content missing due to various reasons. In addition, missing content may be the core of the entire text. Such variety can adversely affect the readability and usability of the text. At present, for missing content, a manual completion mode is usually adopted to recover the missing content, so that the efficiency is low and the cost is high. In view of this, how to improve the efficiency of text completion and reduce the cost of text completion becomes a topic with great research value.
Disclosure of Invention
The technical problem mainly solved by the application is to provide a text completion method, an electronic device and a storage device, which can improve the efficiency of text completion and reduce the cost of text completion.
In order to solve the above problem, a first aspect of the present application provides a text completion method, including: acquiring a text to be completed, and determining a text library from which missing contents of the text to be completed originate; the full text to be supplemented comprises at least one missing position, and the text library relates to the field of preset knowledge; performing completion prediction on a text to be completed by using a knowledge map and a text library corresponding to a preset knowledge field to obtain at least one candidate word at a missing position; and obtaining a complete text of the text to be completed by using the candidate segments of each missing position.
In order to solve the above problem, a second aspect of the present application provides an electronic device, which includes a memory and a processor coupled to each other, wherein the memory stores program instructions, and the processor is configured to execute the program instructions to implement the text completion method in the first aspect.
In order to solve the above problem, a third aspect of the present application provides a storage device storing program instructions capable of being executed by a processor, the program instructions being used to implement the text completion method in the first aspect.
According to the scheme, the text to be supplemented is obtained, the text base from which the missing content of the text to be supplemented originates is determined, so that the full prediction is performed on the text to be supplemented by using the knowledge map and the text base corresponding to the preset knowledge field, at least one candidate word of the missing position is obtained, and then the complete text of the text to be supplemented is obtained by using the candidate segments of the missing positions. Therefore, the missing content of the text to be supplemented can be supplemented without depending on manual work, the efficiency of text supplementation can be improved, and the cost of text supplementation can be reduced. In addition, because the missing content is determined to be derived from the text base related to the preset knowledge field, the completion prediction is carried out by utilizing the knowledge map and the text base corresponding to the preset knowledge field, and the accuracy of text completion is further improved. .
Drawings
FIG. 1 is a schematic flow chart diagram illustrating an embodiment of a text completion method according to the present application;
FIG. 2 is a block diagram of an embodiment of a completion method of the present application;
FIG. 3 is a flow diagram of one embodiment of a sample text acquisition process;
FIG. 4 is a flowchart illustrating an embodiment of step S13 in FIG. 1;
FIG. 5 is a state diagram of one embodiment of a verbatim prediction process;
FIG. 6 is a flow diagram of one embodiment of a first predictive network training process;
FIG. 7 is a schematic flow chart illustrating another embodiment of step S13 in FIG. 1;
FIG. 8 is a state diagram utilizing one embodiment of a reference word prediction process;
FIG. 9 is a flowchart illustrating one embodiment of a second predictive network training process;
FIG. 10 is a schematic flow chart diagram illustrating a further embodiment of step S13 in FIG. 1;
FIG. 11 is a block diagram of an embodiment of a knowledge tree;
FIG. 12 is a state diagram of an embodiment of a fused text acquisition process;
FIG. 13 is a flowchart illustrating one embodiment of a third predictive network training process;
FIG. 14 is a flow chart illustrating a method for completing a text of the present application according to another embodiment;
FIG. 15 is a schematic flow chart diagram illustrating a method for completing a document according to another embodiment of the present application;
FIG. 16 is a flow chart illustrating a method of completing a document according to another embodiment of the present application;
FIG. 17 is a block diagram of an embodiment of an electronic device of the present application;
FIG. 18 is a block diagram of an embodiment of a storage device according to the present application.
Detailed Description
The following describes in detail the embodiments of the present application with reference to the drawings attached hereto.
In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular system structures, interfaces, techniques, etc. in order to provide a thorough understanding of the present application.
The terms "system" and "network" are often used interchangeably herein. The term "and/or" herein is merely an association describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship. Further, the term "plurality" herein means two or more than two.
Referring to fig. 1, fig. 1 is a schematic flow chart illustrating a text completion method according to an embodiment of the present application. Specifically, the method may include the steps of:
step S11: and acquiring the text to be completed.
In the embodiment of the present disclosure, the text to be supplemented includes at least one missing position, that is, the text to be supplemented may include 1 missing position, and may also include multiple (e.g., 2, 3, etc.) missing positions, which is not limited herein. For example, for a complete text "the british medical journal" lancet "online release clinical trial result of the new coronary vaccine phase ii of the institute of military medicine", the corresponding full text to be supplemented may be "the british ()" lancet "online release clinical trial result of the new coronary vaccine phase ii of the institute of military medicine", the embodiment of the present disclosure and other disclosed embodiments described below, such as no special description, () represents the deletion position, the above-mentioned full text to be supplemented includes 1 deletion position, or, the corresponding full text to be supplemented may also be "() lancet" online release clinical trial result of the new coronary vaccine phase ii of the institute of military medicine ", that is, the full text to be supplemented includes 2 deletion positions, or, the corresponding full text to be supplemented may also be" () lancet "() state ()") online release clinical trial result of the new coronary vaccine phase ii of the institute of military medicine ", i.e. the text to be complemented comprises 3 missing positions. Other cases may be analogized, and no one example is given here.
It should be noted that each missing position may correspond to one missing word, or may correspond to a plurality of (e.g., 2, 3, etc.) missing words. Still taking the above-mentioned complete text "UK J MEDICAL" FEED "on-line publishing the clinical trial result of Xinguan vaccine phase II of China military medical research institute" as an example, the corresponding full text to be supplemented can be the clinical test result of the Xinguan vaccine II phase of the Chinese military medical research institute published on line by ' UK () ' lancet ', namely, the full text to be supplemented corresponds to 4 deletion characters at the deletion position, or the corresponding full text to be supplemented can also be the clinical test result of the New crown vaccine phase II of the military medical research institute of on-line publication () of the British medical journal Lancet), namely, the full text to be supplemented corresponds to 2 missing characters at the missing position, or the corresponding full text to be supplemented can also be the clinical test result of the Xinguan vaccine II of the Chinese military medical research institute published on line by the 'lancet' in the national medical journal, namely, the full text to be supplemented corresponds to 1 missing character at the missing position. Other cases may be analogized, and no one example is given here.
In addition, in the embodiments of the present disclosure and other embodiments of the following disclosure, the reason why the text to be supplemented has text deletion is not limited. For example, the full text to be supplemented may be missing characters caused by various problems such as network congestion, coding errors and the like in various links such as sending, storing, displaying and the like; or, for example, during the transmission of the confidential text, special encoding or conversion methods are often adopted for the names such as place name, person name, organization name, and the like, which may result in text missing.
Step S12: and determining the source condition of the content missing from the text to be completed.
In an embodiment of the disclosure, the source condition includes any one of: unknown in origin, from a first corpus of text, from a second corpus of text relating to a predetermined domain of knowledge. Specifically, in the case that the source condition includes a source from the first text library, it may be known that the missing content of the text to be supplemented comes from the first text library, but the knowledge field to which the missing content exactly relates cannot be determined, and taking the text to be supplemented "the world intellectual property organization headquarters is set at ()", it may be known that the missing content thereof comes from encyclopedias (e.g., cyberclotypes such as wikipedia and encyclopedia); and in the case where the source case includes a second text library derived from a predetermined knowledge domain, the missing content of the text to be complemented may be known from the second text library, and the second text library relates to the predetermined knowledge domain, and the missing content thereof may be known from the second text library related to the knowledge domain of classical music (e.g., the aforementioned web encyclopedias of wikipedia, encyclopedia, or professional books related to classical music, for example, with the text to be complemented "as one of the characters of the vienna classical party, () being appointed as a salesman palace musician in 1772); however, in the case where the source condition includes that the source is unknown, the knowledge domain from which the missing content exactly originates and the text library from which the missing content originates cannot be known. The above examples are merely possible situations in the actual application process, and the text to be completed and the first text library, the second text library or the preset knowledge field are not limited thereto, and may be specifically set according to the actual application situation, which is not illustrated herein.
In an implementation scenario, a complete text of a text to be completed is sent to a receiving party by a sending party, and if a text missing situation occurs in the receiving process of the receiving party due to the foregoing reasons, a source situation of the missing content of the text to be completed can be determined based on a prior agreement between the sending party and the receiving party. For example, if the sender and the receiver do not agree in advance, it may be determined that the source of the missing content of the text to be completed is "source unknown"; or, for example, if the sender and the receiver agree in advance that the text does not exceed the range of encyclopedia, it may be determined that the source of the missing content of the text to be completed is "from encyclopedia"; or, for example, if the sender and the receiver agree in advance that the text does not exceed the encyclopedia relating to classical music, it may be determined that the source of the missing content of the text to be complemented is "encyclopedia relating to the field of classical music knowledge". Other cases may be analogized, and no one example is given here.
In another implementation scenario, as mentioned above, the complete text of the text to be supplemented is sent to the receiving party by the sending party, and the receiving party has a text missing situation during the receiving process due to the foregoing reasons, and the source situation of the content missing from the text to be supplemented can also be determined based on the context of the historical conversation between the sending party and the receiving party. For example, if the historical conversation between the sender and the receiver does not relate to a specific topic, it may be determined that the source of the missing content of the text to be completed is "source unknown"; or, for example, if the historical conversation between the sender and the receiver mainly relates to the characters in ancient and modern countries, but is not limited to a specific field, the source situation of the missing content of the text to be supplemented can be determined as 'from encyclopedia'; or, for example, if the historical conversation between the sender and the receiver mainly relates to the characters of the various college representatives of classical music, it can be determined that the source of the missing content of the text to be supplemented is "from encyclopedia relating to the classical music knowledge field". Other cases may be analogized, and no one example is given here.
In another implementation scenario, after the text to be supplemented is obtained, the user may be prompted to assist in determining the source of the content missing from the text to be supplemented. Specifically, the user may be prompted to select a text library from which the missing content of the text to be completed originates, such as may include: the method comprises the following steps of determining that the source condition of the missing content of the text to be supplemented is unknown under the condition that a user selects an uncertain option, and further prompting the user to select the knowledge field related to the missing content of the text to be supplemented after the user selects a text library from which the missing content of the text to be supplemented originates, for example, under the condition that the user selects an encyclopedia option, the user can be further prompted to select the knowledge field related to the missing content of the text to be supplemented, for example, the method can comprise the following steps: and determining that the source of the content missing from the text to be supplemented is from encyclopedia under the condition that the user selects uncertain, or from encyclopedia relating to the classical music knowledge under the condition that the user selects classical music. Other cases may be analogized, and no one example is given here.
Step S13: and performing completion prediction on the text to be completed by adopting a text prediction mode matched with the source condition to obtain at least one candidate word at the missing position.
In an implementation scenario, in the case that the source condition includes that the source is unknown, default characters with preset numerical values may be respectively supplemented to each missing position of the full text to be supplemented to obtain a text to be processed, and for each missing position, the text to be processed is subjected to prediction for several times to obtain predicted characters of the default characters at ordinal positions corresponding to the prediction times, and candidate words of the missing position are obtained based on the predicted characters of the several times. In the above manner, under the condition that the source condition includes unknown source, default characters with preset numerical values are respectively supplemented at each missing position of the text to be supplemented, so that the text to be processed is obtained, the text to be processed is predicted for each missing position for a plurality of times, predicted characters of the default characters at sequence positions corresponding to the prediction times are obtained, and then candidate words of the default positions are obtained based on the predicted characters of the plurality of times, so that the text supplementation can be performed without depending on manual work, the efficiency of the text supplementation can be improved, the cost of the text supplementation can be reduced, in addition, under the condition that the source is unknown, character-by-character prediction is performed at each missing position, the prediction precision can be improved, and the accuracy of the text supplementation can be improved.
In a specific implementation scenario, the default symbol may be set according to actual application requirements, for example, the default symbol may be set to [ mask ], which is not limited herein.
In another specific implementation scenario, the preset values may be set according to actual application requirements, for example, the preset values may be set to 2, 3, 4, 5, and the like, which is not limited herein.
In another specific implementation scenario, in order to improve the prediction efficiency, the prediction of the text to be processed for each missing position may be specifically performed by the first prediction network, that is, the text to be processed may be sent to the first prediction network, and finally, the prediction text of the default character at the ordinal position corresponding to the prediction number may be obtained.
In another specific implementation scenario, taking the full text to be supplemented "() medical magazine" lancet "online publishing chinese military medical research institute new crown vaccine phase ii clinical trial result" as an example, after adding 4 default characters, the text to be processed "[ mask ] [ mask ] [ mask ] [ mask ] medical magazine" lancet "online publishing chinese military medical research institute new crown vaccine phase ii clinical trial result" can be obtained, for the default position, the 1 st prediction can obtain the predicted characters (e.g., english, american, french) of the default position (i.e., 1 st [ mask ]) at the ordinal position (i.e., 1 st position) corresponding to the prediction times (i.e., 1 st time), and the 2 nd prediction can obtain the predicted characters (e.g., analogized state) of the default position (i.e., 2 nd position) corresponding to the prediction times (i.e., 2 nd time), so that the candidate words "britain", "and" britain "of the default position" can be obtained, "United states" and "France". Other cases may be analogized, and no one example is given here. For a specific prediction process, reference may be made to the related description in the following disclosed embodiments, and details are not repeated here.
In one implementation scenario, in the case that the source condition includes a source from a first text library, a completion prediction may be performed on the text to be completed by using the first text library, so as to obtain at least one candidate word at the missing position. According to the method, under the condition that the source comprises the source from the first text library, the completion prediction is carried out on the text to be completed through the first text library, so that at least one candidate word at the missing position is obtained, the text completion can be carried out without depending on manual work, the text completion efficiency can be improved, and the text completion cost can be reduced. In addition, under the condition that the missing content originates from the first text base, at least one candidate word at the missing position is directly obtained by prediction by using the first text base, and the efficiency of text completion can be further improved. In addition, because the candidate words are directly predicted according to the missing positions, the missing positions are not limited to missing characters, words or entities, and the mixed granularity prediction of the characters, the words, the entities and the like can be realized.
In a specific implementation scenario, in order to expand the applicable scope, the first text library may specifically include, as far as possible, text corpora that may be involved in the actual application process, such as words, entities, and the like that may occur in daily chat, or various professional scenarios such as finance, music, and the like. For example, the first text library may specifically include corpora of network encyclopedias such as encyclopedia, wikipedia and the like, so that the first text library may be applicable to various service scenarios, and the application range is greatly improved.
In another specific implementation scenario, in order to improve the prediction efficiency, the completion prediction on the text to be completed may be specifically performed by the second prediction network, that is, the text to be completed may be sent to the second prediction network, and finally at least one candidate word at the missing position is obtained.
In yet another specific implementation scenario, taking the full text to be supplemented "() medical magazine" lancet "online publishing the clinical trial result of the new crown vaccine phase ii of the chinese military medical institute" as an example, the full text to be supplemented is subjected to a completion prediction by using the first text library, and at least one candidate word "uk", "usa", "france" at the deletion position can be obtained. Other cases may be analogized, and no one example is given here. For a specific prediction process, reference may be made to the related description in the following disclosed embodiments, and details are not repeated here.
In an implementation scenario, in the case that the source condition includes a second text base derived from a preset knowledge field, the completion prediction may be performed on the text to be completed by using a knowledge map corresponding to the preset knowledge field and the second text base, so as to obtain at least one candidate word at the missing position. According to the method, under the condition that the source condition comprises the second text base which is originated from the preset knowledge field, the completion prediction is carried out on the text to be completed through the knowledge map and the second text base which correspond to the preset knowledge field, so that at least one candidate word of the missing position is obtained, the text completion can be carried out without depending on manual work, the text completion efficiency can be improved, and the text completion cost can be reduced. In addition, under the condition that the missing content is derived from a second text base related to the preset knowledge field, on one hand, at least one candidate word at the missing position is obtained by directly predicting the second text base, so that the efficiency of text completion can be further improved, and on the other hand, at least one candidate word at the missing position is obtained by predicting the knowledge graph corresponding to the preset knowledge field, so that the accuracy of the candidate word can be improved.
In a specific implementation scenario, in order to expand the applicable scope, the second text library may specifically include, as far as possible, text corpora that may be involved in the actual application process, such as words, entities, and the like that may occur in daily chat, or various professional scenarios such as finance, music, and the like. For example, the second text library may specifically include corpora of network encyclopedias such as encyclopedia, wikipedia and the like, so that the second text library may be applicable to various service scenarios, and the application range is greatly improved.
In another specific implementation scenario, in order to improve the prediction efficiency, the completion prediction on the text to be completed may be specifically performed by the third prediction network, that is, the text to be completed may be sent to the third prediction network, and finally at least one candidate word at the missing position is obtained.
In another specific implementation scenario, taking the to-be-supplemented full text "uk ()" lancet "online publishing the clinical test result of the new crown vaccine phase ii of the institute of military medical science" as an example, the to-be-supplemented full text can be subjected to the completion prediction by using the knowledge graph and the second text base corresponding to the medical knowledge field, and at least one candidate word "medical magazine", "journal" or "newspaper" of the deletion position can be obtained. Other cases may be analogized, and no one example is given here. For a specific prediction process, reference may be made to the related description in the following disclosed embodiments, and details are not repeated here.
In addition, please refer to fig. 2 in combination, fig. 2 is a schematic diagram of a frame of an embodiment of the text completion method of the present application. As shown in fig. 2, in order to improve the efficiency of the completion prediction, the completion prediction may be performed using a first prediction network in a case where the source case includes a source unknown, and the completion prediction may be performed using a second prediction network in a case where the source case includes a source from a first corpus of texts, or may be performed using a third prediction network in a case where the source case includes a source from a second corpus of texts related to a preset knowledge domain. Therefore, under the condition of different sources, the completion prediction can be executed by using different prediction networks, so that the application range of text completion can be favorably expanded.
In an implementation scenario, in order to facilitate text completion within the method framework shown in fig. 2, the first text library and the second text library may be the same text library, and as described above, in order to expand the application range, the text library may specifically include text corpora that may be involved in the actual application process as much as possible, such as words, terms, entities, and the like that may occur in daily chat, or various professional scenarios such as finance, music, and the like. For example, the text library may specifically include corpora of network encyclopedias such as encyclopedia, wikipedia and the like, so that the text library may be applicable to various service scenarios, and the application range is greatly improved.
In an implementation scenario, the first prediction network, the second prediction network, and the third prediction may be obtained by respectively training different preset neural networks with different sample texts in different training manners. For example, the first prediction network may be obtained by training a first preset neural network with a first sample text by using a first training mode, the second prediction network may be obtained by training a second preset neural network with a second sample text by using a second training mode, and the third prediction network may be obtained by training a third preset neural network with a third sample text by using a third training mode.
In another implementation scenario, in order to reduce the training complexity, the first prediction network, the second prediction network, and the third prediction network may be obtained by training the same preset neural network with the same sample text in different training manners, that is, the first prediction network, the second prediction network, and the third prediction network may share the sample text and the preset neural network in the training process, so that the training complexity can be reduced. The specific training modes of the first prediction network, the second prediction network, and the third prediction network may refer to the related descriptions in other disclosed embodiments of the present application, and are not repeated herein.
It should be noted that the preset neural network may be specifically set according to an actual application, and for example, the preset neural network may include, but is not limited to: BERT (Bidirectional Encoder representation from transforms), ELMo, GPT (general Pre-transmitting), and the like, without limitation thereto.
Step S14: and obtaining the complete text of the text to be completed by using the candidate words of each missing position.
As shown in fig. 2, after the candidate words at each missing position of the text to be supplemented are obtained, the candidate words at each missing position are further combined to perform joint completion prediction on the text to be supplemented, so as to obtain a complete text of the text to be supplemented.
In an implementation scenario, a corresponding candidate word may be added to each missing position, so that several candidate texts of the text to be added may be obtained, and a final score of each candidate text may be obtained.
In a specific implementation scenario, the candidate words to be supplemented at the missing positions are specifically candidate words predicted at the missing positions, so that when the text to be supplemented includes n missing positions and each missing position corresponds to k candidate words predicted, the candidate texts of the text to be supplemented have k total candidate wordsnAnd (4) respectively. Taking the full text to be supplemented as an example, the medical journal lancet online release () clinical trial result of the military medical research institute Xinguan vaccine II, the first candidate words of the deletion position include: "uk", "usa", candidates for the second deletion position include: "china" and "japan", a corresponding candidate word can be added to each missing position, so that: the total of 4 candidate texts comprise a clinical test result of the new crown vaccine phase II of China military medical research institute published on line in British medical journal Lancet, a clinical test result of the new crown vaccine phase II of China military medical research institute published on line in American medical journal Lancet, a clinical test result of the new crown vaccine phase II of Japan military medical research institute published on line in British medical journal Lancet and a clinical test result of the new crown vaccine phase II of Japan military medical research institute published on line in American medical journal Lancet. Other cases may be analogized, and no one example is given here.
In another specific implementation scenario, in order to improve efficiency and accuracy of scoring candidate texts, a plurality of candidate texts may be respectively sent to a preset scoring network to obtain final scores of corresponding candidate texts. The preset scoring network may be a statistical language network based on an N-gram, and specifically may include but is not limited to: KenLM, SRILM, IRSTLM, BerkeleyLM, etc., without limitation. Taking N to 3 as an example, the final score can be expressed as:
P(w1,…,wn)=P(w1)*...*P(wn|wn-1,wn-2)……(1)
in the above formula (1), w1,…,wnRepresenting n words, in particular w, in the candidate textiRepresenting the ith word in the candidate text, right side P (w)1),…,P(wn|wn-1,wn-2) And the like are predicted using a preset scoring network. Taking the aforementioned candidate text "the british medical journal" lancet "online publishing the clinical test result of the new crown vaccine phase ii of the chinese military medical research institute" as an example, the words in the candidate text may be: british, journal of medicine, lancet, online, release, china, military, medicine, institute, new crown vaccine, phase ii, clinical, trial, and outcome, the terms in the candidate text may be distinguished by separators (e.g., spaces) before the candidate text is fed into the predetermined scoring network, e.g., the candidate text may be expressed as "journal of british lancet online release of clinical trial result of phase ii of new crown vaccine of chinese military medical institute"; or, in order to adapt to various granularities of words, terms, entities, and the like, the terms may be further segmented word by word based on the part-of-speech category of each term, for example, the terms in the candidate text may also be: english, national, medical magazine, lancet, online, publishing, chinese, national, military, medical, research institute, new crown vaccine, stage ii, clinical, trial, results, the candidate text may be divided by separators (e.g., spaces) before being fed into the predetermined scoring network, e.g., the candidate text may be expressed as "english medical magazine lancet online publishing chineseMilitary medical research institute new coronary vaccine phase ii clinical trial results ". Other cases may be analogized, and no one example is given here. For a specific process of segmenting words word by word based on word categories, reference may be made to the related description in the following disclosed embodiments of the present application, and details are not repeated here.
In another specific implementation scenario, after the final scores of the candidate texts are obtained, the candidate text corresponding to the maximum final score may be selected as the complete text of the text to be completed. Still taking the 4 candidate texts as an example, the 4 candidate texts can be respectively sent to a preset scoring network to obtain final scores of the candidate texts, and the candidate text corresponding to the maximum final score is taken as a complete text of the text to be completed, for example, when the final score of the candidate text "on-line published clinical test result of new crown vaccine phase ii of China military medical research institute in UK medical journal" Lane "is maximum, the candidate text can be taken as the complete text of the text to be completed. Other cases may be analogized, and no one example is given here.
In another implementation scenario, in order to improve the accuracy of the final score, a corresponding candidate word may be added to each missing position to obtain a plurality of candidate texts of the text to be added, and for each candidate text, words in the candidate texts are reversely ordered to obtain a reverse text of the candidate text, so that the final score of the candidate text is obtained based on the first score of the candidate text and the second score of the reverse text, and then one candidate text is selected as the complete text of the text to be added based on the final scores of the plurality of candidate texts. According to the method, a plurality of candidate texts of the text to be completed are obtained by filling a corresponding candidate word in each missing position, the words in the candidate texts are reversely sequenced aiming at each candidate text, the reverse text of the candidate text is obtained, and the final score of the candidate text is obtained based on the first score and the second score of the reverse text of the candidate text, so that the forward sequence and the reverse sequence of the candidate text can be comprehensively considered for scoring in the scoring process of the candidate text, the accuracy of the final score can be improved, and the accuracy of the complete text can be improved in the subsequent process of obtaining the complete text based on the final score.
In a specific implementation scenario, the corresponding candidate word supplemented at the missing position is specifically a candidate word predicted at the missing position, which may specifically refer to the foregoing related description, and is not described herein again.
In another specific implementation scenario, as described above, in order to improve efficiency and accuracy of scoring the candidate texts, a first scoring network and a second scoring network may be trained in advance, so that the first score may be obtained by processing the candidate texts using the first scoring network, and the second score may be obtained by processing the candidate texts using the second scoring network. That is, for each candidate text, the candidate text may be sent to a first scoring network to obtain a first score, and the reverse text of the candidate text may be sent to a second scoring network to obtain a second score. In addition, as mentioned above, the first scoring network and the second scoring network may be both statistical language networks based on N-grams, and specifically may include but are not limited to: KenLM, SRILM, IRSTLM, BerkeleyLM, etc., without limitation. Taking N as 3 as an example, the first score may be obtained by using the foregoing correlation description, and the second score may be expressed as:
P(w1,…,wn)=P(wn)*...*P(w1|w2,w3)……(2)
in the above formula (1), w1,…,wnRepresenting n words, in particular w, in the candidate textiRepresenting the ith word in the candidate text, right side P (w)n),…,P(w1|w2,w3) And so on as predicted using the second scoring network. Still taking the aforementioned candidate text "the british medical journal" lancet "online publishing the clinical trial result of the new crown vaccine phase ii of the chinese military medical research institute" as an example, the words in the candidate text may be: british, medical journal, lancet, online, published, chinese, military, medical, institute, new crown vaccine, phase ii, clinical, trial, result, the reverse text of the candidate text may beExpressed as "the results trial clinical phase ii new crown vaccine institute medical military china post online lancet medical journal uk", the words in the reverse text may be distinguished by separators (e.g., spaces) before being fed into the second scoring network, as may be expressed as "the results trial clinical phase ii new crown vaccine institute medical military chinese post online lancet medical journal uk". Or, in order to adapt to various granularities of words, terms, entities, and the like, the terms may be further segmented word by word based on the part-of-speech category of each term, for example, the terms in the candidate text may also be: english, country, journal of medicine, lancet, online, release, zhong, country, military, medicine, institute, new crown vaccine, phase ii, clinical, trial, and result, the reverse text of the candidate text may be expressed as "result trial clinical phase ii new crown vaccine institute medical military country release online lancet medical magazine state english", and before the reverse text is fed into the second scoring network, the reverse text may be distinguished by a separator (e.g., a space), such as may be expressed as "result trial clinical phase ii new crown vaccine institute medical military country release online lancet medical magazine state english". Other cases may be analogized, and no one example is given here. For a specific process of segmenting words word by word based on word categories, reference may be made to the related description in the following disclosed embodiments of the present application, and details are not repeated here.
In another specific implementation scenario, the final score may be obtained by weighting the first score and the second score respectively by using a first weight and a second weight, where the first weight is not less than the second weight, for example, the first weight is 0.6 and the second weight is 0.4, or the first weight is 0.7 and the second weight is 0.3, which is not limited herein. For slogan description, the first weight can be denoted as λ, and the second weight can be denoted as 1- λ, then the final score can be expressed as:
score=λgf(x)+(1-λ)gb(x)……(3)
in the above formula (3), score represents the final score, g, of the candidate text xf(x) A first score representing the candidate text x,gb(x) A second score representing candidate text x.
In another specific implementation scenario, after the final scores of the candidate texts are obtained, the candidate text corresponding to the maximum final score may be selected as the complete text of the text to be completed. Reference may be made to the foregoing description for details, which are not repeated herein.
According to the scheme, the text to be supplemented is obtained, the text to be supplemented comprises at least one missing position, the source condition of the missing content of the text to be supplemented is determined, and the source condition comprises any one of the following conditions: the source is unknown, the source is from the first text base, the source is from the second text base related to the preset knowledge field, therefore, the completion prediction is carried out on the text to be completed by adopting a text prediction mode matched with the source condition, at least one candidate word at the missing position is obtained, and then the candidate word at each missing position is utilized to obtain the complete text of the text to be completed. Therefore, the missing content of the text to be supplemented can be supplemented without depending on manpower, the efficiency of text supplementation can be improved, and the cost of text supplementation can be reduced. In addition, the completion prediction is carried out on the text to be completed by adopting a text prediction mode matched with the source condition, so that the method is favorable for expanding the application range of text completion.
As described in the foregoing disclosure, the first prediction network, the second prediction network, and the third prediction network may share the sample text and the preset neural network in the training process, so that the sample texts for subsequently training the first prediction network, the second prediction network, and the third prediction network may be pre-constructed, and on this basis, the samples are respectively trained to obtain the first prediction network, the second prediction network, and the third prediction network. Referring to fig. 3, fig. 3 is a flowchart illustrating an exemplary text obtaining process according to an embodiment. As shown in fig. 3, the method may specifically include the following steps:
step S31: and performing word segmentation and part-of-speech tagging on the original text to obtain a plurality of words tagged with part-of-speech categories.
In one implementation scenario, the original text may be text related to a business scenario. For example, in a financial related business scenario, the original text may include, but is not limited to: financial news data, financial book data, and the like; alternatively, in a sports related business scenario, the original text may include, but is not limited to: sports news data, sports book data, and the like, and other scenes can be analogized, and the examples are not repeated.
In another implementation scenario, in order to improve the efficiency of word segmentation and part-of-speech tagging, a word segmentation and part-of-speech tagging tool may be used to process the original text to obtain a plurality of words tagged with part-of-speech categories. In particular, word segmentation and part-of-speech tagging tools may include, but are not limited to: ICTCLAS, NLTK, Stanford NLP, etc., without limitation.
Taking the original text "the olympics held for the first time in china 2008" as an example, after the original text is subjected to word segmentation and part-of-speech tagging, a plurality of words tagged with part-of-speech categories can be obtained:
Figure BDA0002827417760000071
the above letters are parts of speech labeled for words, for example, ns represents a place name, nz represents other name entities except common entities such as a place name, a person name, and the like, v represents a verb, m represents a number word, and q represents a quantifier. In addition, words having a correlation may also be combined, for example, the number word "2008" and the quantifier "year" may be combined into "2008". In the case of the original text, the analogy can be made, and no one example is given here.
Step S32: segmenting words with part-of-speech categories as preset categories word by word, and selecting words with preset proportion from segmented words and words without segmentation to default.
In an implementation scenario, the preset category may specifically be a place name, and in this case, for the original text "the olympic games held for the first time in china 2008", the word "china" marked as the place name may be segmented word by word to obtain two words, i.e., "middle" and "country". Other cases may be analogized, and no one example is given here.
It should be noted that, in the process of obtaining the reverse text of the candidate text in the above-described embodiment, in order to adapt to various granularities such as words, terms, entities, and the like, word segmentation and part-of-speech tagging may be performed on the candidate text to obtain a plurality of terms tagged with part-of-speech categories, and the terms whose part-of-speech categories are preset categories are segmented word by word, which may specifically refer to the foregoing related description in the present embodiment, and are not described herein again. On the basis, the segmented words can be reversely ordered to obtain the reverse text of the candidate text. Taking the candidate text "the new crown vaccine phase ii clinical test result of the on-line release chinese military medical research institute from uk medical journal" lancet "as an example, after the candidate text is subjected to word segmentation and part-of-speech tagging, a plurality of words with part-of-speech categories as follows can be obtained:
Figure BDA0002827417760000081
the above letters are parts of speech to which words are labeled, and for example, vd denotes a verb by side, n denotes a noun, and nt denotes an organization group. On the basis that the preset category is the place name, the word "british" marked as the place name can be divided into "english" and "country" word by word, and the word "china" marked as the place name can be divided into "middle" and "country" word by word. Other cases may be analogized, and no one example is given here.
In another implementation scenario, the preset ratio may be set according to an actual application situation, for example, in a service scenario with a large missing content, the preset ratio may be set to be slightly larger, such as 30%, 35%, 40%, and so on; alternatively, in a service scenario where the missing content is relatively slightly less, the preset ratio may be set slightly less, such as 10%, 15%, 20%, and so on. In addition, the preset ratio may be set to a fixed value, such as 25%, and is not limited herein. Still taking the original text "the olympics held for the first time in china 2008" as an example, the final segmented words and the non-segmented words can be expressed as:
Figure BDA0002827417760000082
that is, the number of the words after final segmentation and the number of the words without segmentation are 6, and in the case that the preset ratio is 1/3, 2 words may be selected from the words after segmentation and the words without segmentation to be defaulted, for example, "medium" and "country" may be selected to be defaulted, or "2008" and "host" may also be selected to be defaulted, which is not limited herein. In other cases, the original text and the preset proportion are the same, and so on, and no example is given here.
Step S33: and taking the original text after default as a sample text, and taking the position of the default word as a sample missing position of the sample text.
Still taking the original text "the olympic games held for the first time in china 2008" as an example, in the case of selecting "middle" and "country" for default, the "() () olympic games held for the first time in 2008" may be taken as a sample text, the position of the default word "middle" may be taken as the sample missing position of the sample text, and the position of the default word "country" may be taken as the sample missing position of the sample text. Other cases may be analogized, and no one example is given here.
In one implementation scenario, for facilitating subsequent training using the sample text, the default original text and the default word may also be used as the sample text. Still taking the original text "the olympic games held for the first time in china 2008" as an example, in the case of selecting "middle" and "country" for default, the original text "() () after default" the olympic games held for the first time in 2008 "and the default words" middle "and" country "can be used together as the sample text. Other cases may be analogized, and no one example is given here.
Different from the embodiment, the method includes the steps of performing word segmentation and part-of-speech tagging on an original text to obtain a plurality of words tagged with part-of-speech categories, and segmenting the words with the part-of-speech categories as preset categories word by word, selecting words with preset proportions from the segmented words and the words not segmented to default, further taking the original text after default as a sample text, and taking the position of the default word as a sample missing position of the sample text, so that the sample text with missing contents including mixed granularities of words, entities and the like can be constructed, adaptability of a prediction network obtained by subsequent training to the to-be-completed text with the mixed granularities of the missing words, entities and the like can be improved, and accuracy of subsequent completion prediction can be improved.
Referring to fig. 4, fig. 4 is a schematic flowchart illustrating an embodiment of step S13 in fig. 1. Specifically, the embodiment of the present disclosure is a flowchart illustrating an embodiment of performing completion prediction on a text to be completed when a source condition includes that the source is unknown. Specifically, the method may include the steps of:
step S41: and respectively supplementing default symbols with preset numerical values at each missing position of the text to be supplemented to obtain the text to be processed.
In one implementation scenario, as described in the foregoing disclosure, in the case that the source condition includes that the source is unknown, the complementary prediction may be performed by using a first prediction network, and the first prediction network may be specifically obtained by training a preset neural network (e.g., BERT) by using sample text. On the basis, the number of the missing characters at the missing position of the sample in each sample text can be counted, and the ratio of the number of the missing characters smaller than the candidate value is counted respectively for a plurality of candidate values, so that the smallest candidate value is selected as the preset value from at least one candidate value with the ratio larger than the preset percentage. Specifically, candidate values may include, but are not limited to: 1. 2, 3, 4, 5, 6, etc., without limitation. In addition, the preset percentage may be 90%, 92%, 95%, 97%, 99%, etc., and is not limited herein. In the mode, the number of the missing characters at the missing positions of the samples in the text of each sample is counted, the occupation ratio of the number of the missing characters smaller than the candidate numerical values is counted respectively for the plurality of candidate numerical values, and therefore the smallest candidate numerical value is selected as the preset numerical value from at least one candidate numerical value with the occupation ratio larger than the preset percentage, so that the preset numerical value can cover most scenes, the number of default characters can be reduced as far as possible, and the efficiency of character prediction for each missing position in the follow-up process can be improved.
In a specific implementation scenario, for N sample texts, 20 sample missing positions are included through statistics, where: the number of missing characters at 1 sample missing position is 1, the number of missing characters at 3 sample missing positions is 2, the number of missing characters at 3 sample missing positions is 3, the number of missing characters at 12 sample missing positions is 4, and the number of missing characters at 1 sample missing position is 5, then for candidate values 1, 2, 3, 4, 5 respectively, the ratio of the number of missing characters not greater than candidate value 1 is 1/20-5%, the ratio of the number of missing characters not greater than candidate value 2 is 4/20-20%, the ratio of the number of missing characters not greater than candidate value 3 is 7/20-35%, the ratio of the number of missing characters not greater than candidate value 4 is 19/20-95%, the ratio of the number of missing characters not greater than candidate value 5 is 20/20-100%, and in the case that the preset percentage is 90%, the smallest candidate value 4 may be selected as the preset value from the candidate values 4 corresponding to 95% and the candidate values 5 corresponding to 100%. Other cases may be analogized, and no one example is given here.
In another specific implementation scenario, as described in the foregoing disclosure, the default symbol may be set as [ mask ], and in addition, for the convenience of the first predicted network processing, [ CLS ] and [ SEP ] may be respectively added to the beginning and the end of the text to be added as the start flag and the end flag. Taking the text "the world intellectual property organization headquarters is set at ()" to be complemented as an example, the text can be processed as "the CLS world intellectual property organization headquarters is set at mask ] [ mask ] [ mask ] [ SEP ]", and the rest can be analogized, which is not illustrated one by one here.
In another specific implementation scenario, in order to facilitate the first prediction network processing, word segmentation and part-of-speech tagging may be performed on the text to be completed to obtain a plurality of words tagged with part-of-speech categories, and the words whose part-of-speech categories are preset categories are segmented word by word to obtain the text to be processed. Still taking the aforementioned text to be complemented "the world intellectual property organization headquarter is set at ()", the relevant steps in the aforementioned disclosed embodiment can be adopted to perform word segmentation, part of speech tagging and word-by-word segmentation, and finally the following text to be processed is obtained:
Figure BDA0002827417760000091
under the condition that the text to be supplemented is other texts, the corresponding text to be processed can be obtained by analogy, and the examples are not given one by one.
In another implementation scenario, in order to facilitate the first prediction network processing, before the text to be processed is sent to the first prediction network, each word in the text to be processed may also be position-coded, and still taking the above-mentioned text to be complemented "world intellectual property headquarter set ()" as an example, the position-coded text to be processed may be represented as:
Figure BDA0002827417760000092
under the condition that the text to be supplemented is other texts, the text to be processed after position coding can be obtained by analogy, and the examples are not repeated.
Step S42: and predicting the text to be processed for a plurality of times aiming at each missing position to obtain predicted characters of default characters at the sequence positions corresponding to the prediction times, and obtaining candidate words of the missing positions based on the predicted characters of the plurality of times.
Specifically, when the text to be processed is predicted for the ith time, at least one predicted character of the default character at the ith order position and the predicted probability value of each predicted character can be obtained, on the basis, the default character at the ith order position can be replaced by the at least one predicted character of the default character at the ith order position respectively to obtain at least one new text to be processed, whether the preset ending condition is met or not is further judged, i can be added by 1 under the condition that the preset ending condition is not met, the step of predicting the text to be processed for the ith time and the subsequent steps are executed again, and under the condition that the preset ending condition is met, the candidate words at the missing position can be obtained on the basis of the latest obtained predicted probability value of each predicted character. In the above mode, the ith prediction is carried out on the text to be processed to obtain at least one predicted character of the default character at the ith sequence position and the predicted probability value of each predicted character, and at least one predicted character of the default character at the ith order position is respectively substituted for the default character at the ith order position to obtain at least one new text to be processed, so that when the preset end condition is not met, i is added by 1, and the step of predicting the text to be processed for the ith time and the subsequent steps are executed again, and under the condition of meeting the preset end condition, obtaining the candidate word at the missing position based on the latest obtained prediction probability value of each predicted character in each text to be processed, depending on the previous prediction in each prediction, and furthermore, the relevance between the predicted characters obtained by character-by-character prediction can be improved, and the accuracy of the predicted characters is improved.
In one implementation scenario, the preset ending condition may be specifically set to be any one of the following: and predicting the characters to be preset ending characters, wherein i is not less than a preset numerical value. Specifically, the preset end character may be set according to an actual application situation, which is not limited herein; in addition, the specific meaning of the preset numerical value can refer to the related description in the foregoing disclosed embodiments, and is not repeated herein.
In another implementation scenario, when predicting the text to be processed the ith time, the text to be processed may be specifically sent to the first prediction network, so as to obtain at least one predicted word of the default character at the ith ordinal position and the predicted probability value of each predicted word by prediction. Specifically, when predicting the ith text to be processed, after the text to be processed is sent to the first prediction network, the semantic representation v of the default symbol at the ith ordinal position can be obtained, and based on the semantic representation W of the preset word list, the probability value of each character in the preset word list is obtained, which can be specifically expressed as:
p=softmax(v·W)……(4)
in the formula (4), p represents the probability value of each character in the preset vocabulary, v represents the semantic representation of the default symbol at the ith order position, W represents the semantic representation of the preset vocabulary,. represents the dot product operation, and softmax represents the normalization processing. In addition, the preset vocabulary includes semantic representations of a plurality of (e.g., 30000) common words, which may be obtained in the first prediction network training process. For example, BERT has a semantic representation of approximately 30000 different words. On the basis, at least one character (for example, 2 characters) can be selected as the predicted character at the ith sequence position according to the descending order of the probability values, and the corresponding probability value is used as the predicted probability value of the predicted character.
In yet another implementation scenario, referring to FIG. 5, FIG. 5 is a state diagram of an embodiment of a word-by-word prediction process. As shown in fig. 5, after the text to be supplemented, "world intellectual property headquarters in ()" is processed into the above-mentioned text to be processed, it is sent to the first prediction network, and the 1 st prediction of the text to be processed can obtain the 1 st order default character [ mask ]]And expressing the semantic representation v of each character of v preset words W (v)1,v2,v3,…,vm) Performing dot product (dot) operation to obtain probability values of all characters in the preset word list, and sequencing all the characters in the preset word list according to the sequence of the probability values from large to small (sort): day (i.e. W)1) Button (i.e. W)2) East (i.e., W)3) …, North (i.e., W)m) And selects the characters with the pre-set sequence (such as the 2 bits) from the characters, i.e. "day" and "new" as the default character of the 1 st sequence (mask) in the 1 st prediction]And predicting the characters, taking the probability value of the predicted character day as a predicted probability value, and taking the probability value of the predicted character new word as a predicted probability value. On the basis, the default character of the 1 st order position [ mask ] is replaced by the predicted character of' day]To obtain a new text to be processed, for convenience of description, it may be recorded as a text to be processed 1:
Figure BDA0002827417760000101
and replacing the default character [ mask ] of the 1 st order position with the predicted character 'new', obtaining a new text to be processed, which can be recorded as a text to be processed 2:
Figure BDA0002827417760000102
under the condition that the preset ending condition is not met currently, i is added with 1, namely i is 2 at the moment, and so on, when the 2 nd prediction is performed, the two new texts to be processed can be respectively sent into a first prediction network, the text 1 to be processed can obtain the 'inner' and 'original' of the 2 nd order position default character [ mask ] prediction character when the 2 nd prediction is performed through a processing process similar to the 1 st prediction, and the 'about' and 'ze' of the 2 nd order position default character [ mask ] prediction character when the 2 nd prediction is performed through a processing process similar to the 1 st prediction, of the text 2 to be processed can be obtained. Further, the predicted words "inner" and "this" are respectively substituted for the 2 nd order default [ mask ] of the text 1 to be processed, and 2 new texts to be processed can be obtained on the basis of the text 1 to be processed, similarly, the predicted words "about" and "ze" are respectively substituted for the 2 nd order default [ mask ] of the text 2 to be processed, and 2 new texts to be processed can be obtained on the basis of the text 2 to be processed. And under the condition that the preset ending condition is not met currently, adding 1 to i, namely i is 3 at the moment, re-executing the process, finally obtaining the predicted characters and the predicted probability value by each prediction, wherein the predicted characters and the predicted probability value are shown in a table 1, and the table 1 is a summary table of the predicted characters and the predicted probability value of each prediction. As shown in table 1, on the basis that the predicted characters "day" is obtained by the 1 st prediction, the predicted characters "in" and "this" are obtained by the 2 nd prediction, on the basis that the predicted characters "in" is obtained by the 2 nd prediction, the predicted characters "watt" is obtained by the 3 rd prediction (on this basis, the 4 th prediction is finished, not shown in table 1), on the basis that the predicted characters "this" is obtained by the 2 nd prediction, the 3 rd prediction is finished (i.e., the predicted characters are empty), on the basis that the predicted characters "new" is obtained by the 1 st prediction, the predicted characters "about" and "ze" are obtained by the 2 nd prediction, on the basis that the predicted characters "about" is obtained by the 2 nd prediction, the predicted characters "blue" and "west" are obtained by the 3 rd prediction (on this basis, end of prediction 4, not shown in table 1).
TABLE 1 summary of each prediction text and prediction probability values
Figure BDA0002827417760000111
It should be noted that the predicted word and the predicted probability value shown in table 1 are only one possible case in the actual application process, and do not limit other possible cases in the actual application process, and may be specifically set according to the actual application case, and are not limited herein.
In another implementation scenario, under the condition that a preset ending condition is met, specifically, for each latest text to be processed, an average probability value of prediction probability values of the prediction characters at the missing position is counted, the text to be processed at the previous preset order position is selected according to the descending order of the average probability values, and a combination of the prediction characters at the missing position in the selected text to be processed is used as a candidate word of the missing position. According to the method, the average probability value of the prediction probability values of the prediction characters at the missing positions is counted for each newly obtained text to be processed, so that the overall accuracy of the prediction characters in the text to be processed can be represented by the average probability value.
In a specific implementation scenario, the preset sequence bits may be set according to actual application requirements. For example, in order to increase the speed of performing the joint completion prediction by using the candidate words of each missing position, the preset ordinal position may be set to be slightly smaller, for example, set to be 2, 3, etc.; or, for example, the robustness of subsequent joint completion using candidate words of each missing position may be improved, and the preset ordinal position may be set slightly larger, for example, may be set to 4, 5, and so on, which is not limited herein.
In another specific implementation scenario, for example, still taking the aforementioned text to be completed "the world intellectual property headquarters is ()", please refer to table 1, where each predicted word at the missing position in one text to be processed is "day", "inner" and "tile", the average probability value of the predicted probability values is statistically 0.9, each predicted word at the missing position in another text to be processed is "day" and "text", the average probability value of the predicted probability values is statistically 0.8, each predicted word at the missing position in another text to be processed is "new" and "about", the average probability value of the predicted probability values is statistically 0.875, each predicted word at the missing position in another text to be processed is "new" and "blue", the average probability value of the predicted probability values is statistically 0.8, each predicted word at the missing position in another text to be processed is "new" and "west" respectively, the average probability value of its predicted probability values is statistically 0.78. Therefore, in the case that the preset ordinal is set to 2, the text to be processed with the average probability value at the top 2 bits can be selected, and the combination of the prediction characters at the missing position in the selected text to be processed, i.e., "geneva" and "new york", can be used as the candidate words of the missing position. Other cases may be analogized, and no one example is given here.
It should be noted that, under the condition that the text to be supplemented includes a plurality of missing positions, the above-described manner may be respectively adopted for performing the completion prediction on each missing position, and finally, the candidate word at each missing position is obtained.
Different from the embodiment, when the source condition includes that the source is unknown, default characters with preset numerical values are respectively added to each missing position of the text to be added, so that the text to be processed is obtained, the text to be processed is predicted for each missing position for a plurality of times, predicted characters of the default characters at sequence positions corresponding to the prediction times are obtained, and candidate words of the default positions are obtained based on the predicted characters of the plurality of times, so that the text addition can be performed without depending on manual work, the text addition efficiency can be improved, the text addition cost can be reduced, in addition, under the condition that the source is unknown, character prediction is performed word by word at each missing position, the prediction precision can be improved, and the text addition accuracy can be improved.
Referring to fig. 6, fig. 6 is a flowchart illustrating an embodiment of a first predictive network training process. Specifically, the method may include the steps of:
step S61: and respectively supplementing default symbols with preset numerical values at the missing positions of the samples of the sample texts to obtain the texts to be processed of the samples.
Specifically, reference may be made to the description related to step S41 in the foregoing disclosed embodiment, and details are not described herein again. In addition, the process of obtaining the sample text may specifically refer to the foregoing disclosed embodiment and the related description in fig. 3 of the specification, and is not repeated herein.
Step S62: and aiming at the missing position of each sample, predicting the text to be processed of the sample for a plurality of times by utilizing a first prediction network to obtain the sample prediction characters of the default symbols at the sequence positions corresponding to the prediction times and the sample prediction probability value.
Specifically, for each sample missing position, an ith prediction may be performed on the sample to-be-processed text by using a first prediction network to obtain a sample predicted character of a default symbol at an ith order position and a sample predicted probability value of the sample predicted character, the sample predicted character of the default symbol at the ith order position is substituted for the default symbol at the ith order position to obtain a new sample to-be-processed text, and if a preset ending condition is not satisfied, i is increased by 1, and the step of performing the ith prediction and subsequent steps on the sample to-be-processed text are executed again, and if the preset ending condition is satisfied, the prediction on the current sample missing position may be ended. Specifically, reference may be made to the description related to step S42 in the foregoing disclosed embodiment, and details are not described herein again.
Step S63: and acquiring a first loss value of the first prediction network based on the sample prediction probability value of each sample prediction character in the sample candidate words at the sample missing positions.
As described in the foregoing disclosure, in order to facilitate training by using the sample text, the original text after default and the default words may be used as the sample text, and in addition, in the training process, since default characters with preset numbers are respectively added at the positions where the samples of the sample text are missing, so as to obtain the sample text to be processed, a number of placeholders (e.g., [ PAD ]) may be added for each default word, so that the total number of each default word and each added placeholder is equal to the preset number. For example, still taking the original text "the first olympic games held in china 2008" as an example, in the case of selecting "middle" and "country" for default, the original text "() () after default, which is the first time the olympic games were held in 2008, and the default words" middle "and" country "can be used together as sample texts, and then during the training process, under the condition that the preset numerical value is set to be 4, respectively supplementing 4 default symbols at each default position in the sample text to obtain a sample text to be processed "[ CLS ] [ mask ] [ mask ] [ mask ] [ mask ] [ mask ] [ mask ] [ mask ] [ mask ]2008 holding Olympic Games [ SEP ]" for the first time in 2008, and 3 placeholders are added to the default word "medium" to convert to "medium [ PAD ]", and similarly, for the default word "nation" 3 placeholders are added and converted into "nation [ PAD ] [ PAD ]". Other cases may be analogized, and no one example is given here.
In an implementation scenario, the first loss value may be calculated by using a cross entropy loss function, which may be specifically expressed as:
Figure BDA0002827417760000121
in the above formula (5), M represents the number of missing positions of the sample in the sample text, N represents the preset value, yijIndicates the j (th) character, p, in the default word corresponding to the i (th) missing positionijIndicates for the ith missing positionAnd predicting the sample prediction probability value of the sample prediction character obtained by the j-th prediction.
In addition, it should be noted that, when the default word is complemented with the placeholder [ PAD ], the preset end character in the preset end condition may be specifically set as the placeholder [ PAD ]. In the case of complementing the default word with other characters, the setting manner of the preset ending character may be analogized, and no one example is given here.
Step S64: and adjusting the network parameters of the first prediction network by using the first loss value.
Specifically, the network parameters of the first prediction network may be adjusted by using a first loss value in a random Gradient Descent (SGD), a Batch Gradient Descent (BGD), a small Batch Gradient Descent (Mini-Batch Gradient Descent, MBGD), or other manners, where the Batch Gradient Descent refers to updating the parameters by using all samples during each iteration; the random gradient descent means that one sample is used for parameter updating in each iteration; the small batch gradient descent means that a batch of samples is used for parameter updating at each iteration, and details are not repeated here.
Different from the embodiment, default symbols with preset values are respectively added to each sample missing position of a sample text, so that a sample text to be processed is obtained, the sample text to be processed is predicted for each sample missing position for a plurality of times, sample predicted characters and sample predicted probability values of the default symbols at sequence positions corresponding to the prediction times are obtained, a first loss value of a first predicted network is obtained based on the sample predicted probability values of each sample predicted character in sample candidate words at each sample missing position, and accordingly network parameters of the first predicted network are adjusted based on the first loss value. Therefore, character prediction is carried out word by word at each sample missing position, and the network parameters of the first prediction network are adjusted based on the first loss value obtained through statistics, so that the prediction accuracy of the first prediction network can be improved.
Referring to fig. 7, fig. 7 is a schematic flowchart illustrating another embodiment of step S13 in fig. 1. Specifically, the embodiment of the present disclosure is a flowchart illustrating an embodiment of performing completion prediction on a text to be completed when a source condition includes a source from a first text library. Specifically, the method may include the steps of:
step S71: and performing semantic extraction on the text to be supplemented to obtain individual semantic representations of all the missing positions.
In an implementation scenario, in order to facilitate semantic extraction, a default symbol may be respectively supplemented at each missing position of a full text to be supplemented to obtain a text to be processed, so as to perform semantic extraction on the text to be processed to obtain an individual semantic representation of each default symbol, which is used as an individual semantic representation of the missing position where the default symbol is located. In the mode, the default symbol is respectively added at each missing position of the full text to be added to obtain the text to be processed, on the basis, the semantic extraction is carried out on the text to be processed to obtain the individual semantic representation of each default symbol, and the individual semantic representation of the default symbol is used as the individual semantic representation of the missing position of the default symbol, so that the candidate words of the missing position can be predicted based on the individual semantic representation of the single default symbol in the follow-up process, the missing position is not limited to the missing words, the missing words or the missing entities, and the mixed granularity prediction of the words, the missing entities and the like can be realized.
In a specific implementation scenario, the specific setting manner of the default symbol may refer to the related description in the foregoing disclosed embodiment, for example, may be set as [ mask ], which is not limited herein.
In another specific implementation scenario, [ CLS ] and [ SEP ] can be respectively added into the beginning and the end of the text to be added as a start mark and an end mark. Still taking the aforementioned text "the world intellectual property organization headquarters is set at ()" to be complemented, it may be processed as "[ CLS ] the world intellectual property organization headquarters is set at [ mask ] [ SEP ]", and so on in other cases, which is not illustrated one by one here.
In another specific implementation scenario, in order to facilitate the implementation of the prediction of mixed granularity of characters, words, entities, and the like, the method may further perform word segmentation and part-of-speech tagging on the text to be completed to obtain a plurality of words tagged with part-of-speech categories, and segment the words whose part-of-speech categories are preset categories word by word to obtain the text to be processed. The specific ways of word segmentation and part-of-speech tagging can refer to the related descriptions in the foregoing disclosed embodiments, and are not described herein again. In addition, the preset category may be set as a place name, and specific reference may be made to the related description in the foregoing disclosed embodiments, which is not described herein again.
Still taking the aforementioned text to be supplemented "the world intellectual property organization headquarter is set at ()", the following text to be processed can be obtained by adopting the relevant steps in the aforementioned public embodiments to perform the supplement of default symbols, start symbols and end symbols, word segmentation, part of speech tagging and word segmentation one by one:
Figure BDA0002827417760000131
under the condition that the text to be supplemented is other texts, the corresponding text to be processed can be obtained by analogy, and the examples are not given one by one.
In one implementation scenario, as described in the foregoing disclosure, in the case that the source condition includes a source from the first text library, the completion prediction may be performed by using a second prediction network, and the second prediction network may be specifically obtained by training a preset neural network (e.g., BERT) by using sample text. On the basis, the full text to be supplemented can be sent to the second prediction network, so that individual semantic representations of all missing positions can be obtained. In addition, the training process of the second prediction network may specifically refer to the following disclosure embodiments, which are not repeated herein.
In a specific implementation scenario, in order to facilitate the second prediction network processing, before the text to be processed is sent to the second prediction network, each word in the text to be processed may be further position-coded, and still taking the text to be complemented "world intellectual property headquarter set ()" as an example, the position-coded text to be processed may be represented as:
Figure BDA0002827417760000132
under the condition that the text to be supplemented is other texts, the text to be processed after position coding can be obtained by analogy, and the examples are not repeated.
Step S72: and aiming at each missing position, obtaining at least one candidate word of the missing position by utilizing the individual semantic representation of the missing position and the word semantic representation of each reference word.
In an embodiment of the disclosure, the first corpus of text contains at least one reference text, and the reference text contains at least one reference word. The setting manner of the first text base may specifically refer to the related description in the foregoing disclosed embodiment, and is not described herein again.
In an implementation scenario, word segmentation and part-of-speech tagging may be performed on at least one reference text, so as to obtain a plurality of words tagged with part-of-speech categories, and the words whose part-of-speech categories are preset categories are segmented word by word, so as to obtain a plurality of reference words by using the segmented words and the words which are not segmented, and further perform semantic extraction on the plurality of reference words, so as to obtain a word semantic representation of the reference words. According to the method, the words marked with the part-of-speech categories are obtained by respectively carrying out word segmentation and part-of-speech tagging on at least one reference text, and the words with the part-of-speech categories as the preset categories are segmented word by word, so that the reference words are obtained by utilizing the segmented words and the words which are not segmented, and further the reference words comprising mixed granularities of characters, words, entities and the like can be obtained, and the prediction of the mixed granularities of the characters, the words, the entities and the like can be further realized.
In a specific implementation scenario, the specific processes of word segmentation, part-of-speech tagging and word-by-word segmentation may refer to the related descriptions in the foregoing disclosed embodiments, and are not described herein again. In addition, the preset category may be set according to actual application requirements, for example, the preset category may be set as a place name, and specific reference may be made to the related description in the foregoing disclosed embodiment, which is not described herein again.
In another specific implementation scenario, in order to further construct a reference word containing mixed granularity of characters, words, entities and the like, words with part-of-speech categories as preset categories may be segmented word by word, and for words segmented word by word, words before segmentation and characters obtained after segmentation word by word may be used as reference words. Taking the word "Beijing" as an example, the part of speech category of the word is a place name, and under the condition that the preset category is the place name, the word "Beijing" can be segmented word by word to obtain the characters "Beijing" and "Beijing", so that the word "Beijing" before segmentation and the characters "Beijing" and "Beijing" obtained after segmentation can be used as reference words. Other cases may be analogized, and no one example is given here.
In another specific implementation scenario, a preset word vector training tool (e.g., word2vec, glove, etc.) may be specifically used to perform word vector training on the reference word, so as to extract a word semantic representation of the reference word.
In another specific implementation scenario, a word with an occurrence frequency higher than a preset frequency may be screened from the segmented words and the non-segmented words to obtain a plurality of reference words. Specifically, the frequency of occurrence refers to the frequency of occurrence in the first corpus of text. For example, the first library is counted 10 ten thousand words, wherein the word "Beijing" appears 100 times in total, so the frequency of occurrence of the word "Beijing" is 0.1%, while the word "crevice" appears only 1 time, so the frequency of occurrence of the word "crevice" is 0.001%, and so on, and no more examples are given here. In addition, the preset frequency may be set according to the actual application requirement, for example, may be set to 0.01%, 0.05%, and the like, and is not limited herein. In the mode, the words with the occurrence frequency higher than the preset frequency are screened from the words after segmentation and the words not after segmentation, a plurality of reference words are obtained, and the scale of the reference words can be further reduced.
In another specific implementation scenario, words whose part-of-speech categories meet preset rejection conditions may be rejected from the segmented words and the non-segmented words to obtain a plurality of reference words. Specifically, the preset rejection condition may be set to include: the part-of-speech category is any one of stop words and special symbols, and stop words can be functional words in human language without actual meaning, such as 'the', 'is' in English, or the like, or such as 'kayi', 'ya' in Chinese; further, special symbols may include, but are not limited to: punctuation symbols (e.g., pause number ',' etc.), unit symbols (e.g., kilogram 'kg', etc.), numbering symbols (e.g., (r), etc.), tab symbols, currency symbols, etc., without limitation. In the mode, the words with parts of speech types meeting the preset rejection conditions are rejected from the words after segmentation and the words not after segmentation, a plurality of reference words are obtained, and the scale of the reference words can be further reduced.
In an implementation scenario, for each missing position, the similarity between the individual semantic representation of the missing position and the term semantic representation of each reference term may be utilized, so that the reference terms located at the previous preset order may be selected as candidate terms of the missing position according to the descending order of the similarity. Specifically, the similarity between the individual semantic representations and the term semantic representations may be a cosine similarity; in addition, the preset rank may be set according to actual application needs, for example, in order to improve the speed of performing joint completion prediction by using candidate words of each missing position, the preset rank may be set to be slightly smaller, for example, may be set to be 2, 3, and so on; or, for example, the robustness of subsequent joint completion using candidate words of each missing position may be improved, and the preset ordinal position may be set slightly larger, for example, may be set to 4, 5, and so on, which is not limited herein.
In another implementation scenario, the prediction probability values for each reference word may be derived using the individual semantic representations and the word semantic representation of each reference word. Specifically, the prediction probability value of the reference word may indicate the possibility that the word missing at the missing position is the reference word, and the higher the prediction probability value is, the higher the possibility that the word missing at the missing position is the reference word is. On the basis, the reference words at the front preset sequence positions can be selected as candidate words at the missing positions according to the descending sequence of the prediction probability values. The setting manner of the preset sequence bits can refer to the related description, and is not described herein again. In the mode, the prediction probability values of the reference words are obtained by utilizing the individual semantic representation and the word semantic representation of the reference words, so that the reference words positioned at the preset sequence positions are selected as the candidate words at the missing positions according to the sequence of the prediction probability values from large to small, the reference words can be selected as the candidate words at the missing positions based on the individual semantic representation and the word semantic representation, and the accuracy of the candidate words can be improved.
In a specific implementation scenario, as described above, the text to be processed is sent to the second prediction network, so that an individual semantic representation of the missing position can be obtained, for convenience of description, the individual semantic representation can be denoted as h, the term semantic representation of each reference term can be denoted as W, it should be noted that W is a set of term semantic representations of each reference term, and then the probability prediction value p can be calculated by the following equation:
p=softmax(h·W)……(6)
in the above equation (6), p represents the prediction probability value of each reference word, h represents the individual semantic representation of the deletion position, W represents the word semantic representation of each reference word, dot product operation, and softmax represents normalization processing.
In another specific implementation scenario, referring to FIG. 8 in combination, FIG. 8 is a state diagram illustrating an embodiment of a process for predicting a reference word. As shown in FIG. 8, after the text to be complemented, "world intellectual property headquarter ()" is processed into the above-mentioned text to be processed, it is sent to the second prediction network, so that the individual semantic representation h of the missing position can be obtained, and m reference words (W) can be obtained1,W2,W3,…,Wm) M semantic word representations (v) can be obtained correspondingly after the warp quantization1,v2,v3,…,vm) Thus, the individual semantic representation h is represented with the m term semantic representations (v)1,v2,v3,…,vm) Performing dot product (dot) operation to obtain the prediction probability value (p) of each reference word1,p2,p3,…,pm) And sequencing (sort) the reference words according to the descending order of the prediction probability values, and finally selecting the reference words with the front preset sequence (such as the front 2 bits), for example, selecting 'geneva' and 'new york' as candidate words of the missing position. It should be noted that fig. 8 shows only one possible situation in the actual application process, and does not limit other possible situations in the actual application process, and the setting may be specifically performed according to the actual application situation, and is not limited herein.
It should be noted that, under the condition that the text to be supplemented includes a plurality of missing positions, the above-described manner may be respectively adopted for performing the completion prediction on each missing position, and finally, the candidate word at each missing position is obtained.
Different from the embodiment, the individual semantic representation of each missing position is obtained by performing semantic extraction on the text to be completed, so that at least one candidate word of each missing position is directly obtained by utilizing the individual semantic representation of the missing position and the word semantic representation of each reference word aiming at each missing position, and the accuracy and the efficiency of completion prediction can be improved. In addition, because the candidate words are directly predicted according to the missing positions, the missing positions are not limited to missing characters, words or entities, and the mixed granularity prediction of the characters, the words, the entities and the like can be realized.
Referring to fig. 9, fig. 9 is a flowchart illustrating an embodiment of a second predictive network training process. Specifically, the method may include the steps of:
step S91: and semantic extraction is carried out on the sample text by utilizing a second prediction network to obtain the individual semantic representation of the sample at each sample missing position.
In an embodiment of the present disclosure, the sample text includes at least one sample missing position. The process of obtaining the sample text may specifically refer to the foregoing disclosed embodiment and the related description in fig. 3 of the specification, and is not repeated herein.
The manner of semantic extraction for the sample text may specifically refer to the related description of step S71 in the foregoing embodiment, and is not described herein again.
Step S92: and aiming at each sample missing position, obtaining a sample prediction probability value of each reference word by using the sample individual semantic representation of the sample missing position and the word semantic representation of each reference word.
Specifically, reference may be made to the description related to step S72 in the foregoing disclosed embodiment, and details are not described herein again.
Step S93: and acquiring a second loss value of the second prediction network based on the sample prediction probability values of the reference words at the missing positions of each sample.
Specifically, the second loss value may be calculated by using a cross entropy loss function, which may be specifically expressed as:
Figure BDA0002827417760000151
in the above formula (7), M represents the number of missing positions of the sample in the sample text, yiIs a default word, p, corresponding to the ith missing position in the sample textiAnd the sample prediction probability value of each reference word obtained by predicting the ith missing position in the sample text is represented.
Step S94: and adjusting the network parameters of the second prediction network by using the second loss value.
Specifically, the network parameters of the second prediction network may be adjusted by using a second loss value in a random Gradient Descent (SGD), a Batch Gradient Descent (BGD), a small Batch Gradient Descent (Mini-Batch Gradient Descent, MBGD), or other manners, where the Batch Gradient Descent refers to updating the parameters by using all samples during each iteration; the random gradient descent means that one sample is used for parameter updating in each iteration; the small batch gradient descent means that a batch of samples is used for parameter updating at each iteration, and details are not repeated here.
Different from the previous embodiment, the semantic extraction is carried out on the sample text by utilizing the second prediction network to obtain the sample individual semantic representation of each sample missing position, thus aiming at each sample missing position, the sample individual semantic representation of the sample missing position and the word semantic representation of each reference word are utilized to obtain the sample prediction probability value of each reference word, and then a second loss value of a second prediction network is obtained based on the sample prediction probability value of each reference word at each sample missing position, on the basis, network parameters of the second prediction network are adjusted by using the second loss value, so that word prediction is assisted at the position of sample missing by using word semantic representation of the reference word, and the network parameters of the second prediction network are adjusted based on the second loss value obtained through statistics, so that the accuracy of the second prediction network can be improved. In addition, the whole sample missing position is directly predicted, so that the sample missing position is not limited to missing characters, words or entities, and the prediction of mixed granularity of the characters, the words, the entities and the like can be favorably realized.
Referring to fig. 10, fig. 10 is a schematic flowchart illustrating a further embodiment of step S13 in fig. 1. Specifically, the embodiment of the present disclosure is a flowchart illustrating an embodiment of performing completion prediction on a text to be completed in a case where a source situation includes a source from a second text base related to a preset knowledge domain. As described in the foregoing disclosure, the completion prediction may be performed on the to-be-completed text by using a knowledge graph and a text library corresponding to a preset knowledge domain. In the embodiment of the present disclosure, the knowledge graph may include several triples, where a triplet may include two entities and an entity relationship between the two entities, and the triplet may be specifically expressed as < entity 1, entity relationship, entity 2 >. Taking the preset knowledge domain as classical music as an example, several triplets may include but are not limited to: < mozart, place of birth, salborg >, < mozart, hapa, classical hapa >, < austria, the longest history, salborg >, < salborg, commemorative time, mozart week >, when the preset knowledge field is other, the analogy can be done, and no one-by-one example is provided here. The embodiment of the present disclosure may specifically include the following steps:
step S1010: and searching the entities in the triples to obtain a target triple containing the target entity.
In the embodiment of the present disclosure, the target entity is an entity extracted from the full text to be supplemented. Specifically, a Natural Language Processing (NLP) tool (e.g., LTP or the like) may be used to perform named entity recognition on the text to be supplemented, so that the target entity may be extracted from the text to be supplemented. Taking the aforementioned text to be completed "as one of the representative characters of the vienna classical happies, () appointed as the saletsburg palace musician in 1772 as an example, the target entity" saletsburg "can be extracted from the text, and the rest can be done in the same way, and so on, and thus, no further example is given here.
In an implementation scenario, entity search may be performed in a knowledge graph corresponding to a preset knowledge domain, and a triple including a target entity is directly used as a target triple. Still taking as an example the to-be-complemented text "one of the representatives of the vienna classical happa, () appointed as the saletsburg palace musician in 1772", the aforementioned triplet containing the target entity "saletsburg" may be directly: < mozart, place of birth, salburg >, < austria, the oldest history, salburg >, < salburg, memorial day, mozart week >, as the target triplet. When the text to be supplemented is in other cases, the analogy can be performed, and the examples are not repeated. By the method, the triples containing the target entities are directly used as the target triples, and the speed of searching the target triples can be improved.
In another implementation scenario, a triple including a target entity may be used as a candidate triple, and another entity except the target entity in the candidate triples may be used as a reference entity, on the basis, the term semantic representation of each reference term in the second text library is used to obtain the entity semantic representation of the reference entity, and obtain the overall semantic representation of the text to be completed, so that at least one candidate triple is selected as the target triple based on the similarity between the entity semantic representation of each reference entity and the overall semantic representation. In the above manner, the triples including the target entity are used as the candidate triples, and another entity except the target entity in the candidate triples is used as the reference entity, so that the term semantic representation of each reference term in the text library is utilized to obtain the whole semantic representation of the text to be supplemented and the entity semantic representation of the reference entity, and then at least one candidate triplet is selected as the target triplet based on the similarity between the entity semantic representation of each reference entity and the whole semantic representation, so that the candidate triples can be further screened based on the similarity, the interference of triples with lower similarity on subsequent completion prediction can be favorably reduced, and the complexity of subsequently integrating the target triples into the text to be supplemented can be favorably reduced.
In a specific implementation scenario, the overall semantic representation may be obtained by fusing term semantic representations of respective terms in the text to be complemented. The word semantics of each word in the text to be complemented may be specifically expressed as:
Figure BDA0002827417760000161
in the above formula (8), VseqRepresenting the overall semantic representation of the text to be supplemented, n representing the total number of words in the text to be supplemented, VtiRepresenting the t-th in the text to be completediA term semantic representation of the individual terms. Taking as an example the text to be completed "as one of the vienna classical happies representatives, () appointed as the sautsburg palace artist in 1772", each word in the text to be completed includes: as one of vienna, classical, happa, representative, and person, 1772, year, quilt, mission, yes, salburg, court, and musician, the semantic representation of the word may be substituted into equation (8) to obtain the overall semantic representation of the full text to be complemented. Other cases may be analogized, and no one example is given here.
In another specific implementation scenario, the similarity between each entity semantic representation and the whole semantic representation may specifically be a cosine similarity, and specifically, the similarity S may be obtained by the following formula:
S=cosine(Vseq,Vent2)……(9)
in the above formula (9), VseqRepresenting the overall semantic representation, V, of the text to be completedent2An entity semantic representation representing another entity (i.e., a reference entity) in the target triple other than the target entity. Still taking the to-be-complemented text "as one of the vienna classical happies representative characters, () appointed as saltsburg palace staffs in 1772 as an example, while obtaining the overall semantic representation of the to-be-complemented text by using the above formula (8), candidate triples can be obtained separately:<mozart, Ex. George, Saltsburgh>、<Austrian, the longest history, Saltsburgh>、<Sairsburg, commemorative day, Mozart week>The semantic representation of the entity of the reference entity "mozart" except the target entity "saertberg", the semantic representation of the entity of the reference entity "austria", and the semantic representation of the entity of the reference entity "mozart week", and the similarity between the overall semantic representation and the semantic representations of the three entities is obtained based on the formula (9). Other cases may be analogized, and no one example is given here.
In another specific implementation scenario, the candidate triples may be sorted according to a descending order of similarity, so as to select the candidate triples with the previously preset ordinal as the target triples. Specifically, the preset order bits may be set according to the actual application requirement, for example, may be set to 2, 3, 4, and so on. In addition, in order to reduce the interference of candidate triples with lower similarity on subsequent completion prediction, reduce the complexity of integrating target triples into a text to be completed, and avoid the occurrence of lower completion prediction accuracy caused by too few target triples, the preset order may be specifically set to 2, that is, the candidate triples with similarity ranked in the first two digits after being ranked from large to small may be used as the target triples. Taking still the full text to be complemented "as one of the vienna classical happies representatives, () being appointed as the saurtzburg palatist in 1772", one can choose < mozart, birth place, saurtzburg >, < saurtzburg, memorial day, mozart week > as the target triplet. Other cases may be analogized, and no one example is given here.
In another specific implementation scenario, the second text library may include at least one reference text, and the reference text includes at least one reference word, so that word segmentation and part-of-speech tagging may be performed on the at least one reference text, respectively, to obtain a plurality of words tagged with part-of-speech categories, and word segmentation with the part-of-speech categories being preset categories is performed word by word, and a plurality of reference words are obtained by using the segmented words and the words that are not segmented, and then semantic extraction is performed on the plurality of reference words, so as to obtain word semantic representations of the reference words.
Step S1020: and fusing the target triple into a target entity of the text to be completed to obtain a fused text.
In an implementation scenario, after the target triple is obtained, the reference entity, the target entity, and the entity relationship therebetween in the target triple may be extracted, and the reference entity and the entity relationship therein are inserted into the left side and/or the right side of the target entity of the text to be completed, so as to obtain the fused text. Still taking the to-be-complemented text "as one of the vienna classical haplotypes representative characters, () being appointed as the saertburg impersonator in 1772, the reference entity (i.e. mozart), the target entity (i.e. saertburg) and the entity relationship (i.e. place of birth) in the target triplet < mozart, place of birth, saertburg > may be extracted, and the reference entity (i.e. mozart week), the target entity (i.e. saertburg) and the entity relationship (memorial day) in the other target triplet < saertburg, memorial day may be extracted, and the reference entity" mozart ", the entity relationship" memorial day "and the reference entity" mozart week ", the memorial day" are inserted to the left of the target entity "saertburg" in the to-be-complemented text "being appointed as one of the vienna classical haplotypes representative characters, () being appointed as the saintri impersonator in 1772, alternatively, the fused text "designated as one of the wiener classical haplotyp representative characters" in 1772 was inserted to the right side of the full text target entity "saertberg" () designated as one of the wiener classical haplotyp memorial day funerans of the origin mazate of the saertberg in 1772, or the fused text "designated as one of the wiener classical haplotyp representative characters" in 1772 was inserted to the left and right sides of the full text target entity "saertberg" () designated as one of the wiener classical mustaryp of the origin saertberg monument memorial day funerans of the origin mazate in 1772, which is not limited herein. Other cases may be analogized, and no one example is given here.
In another implementation scenario, after the target triple is obtained, a knowledge tree may also be constructed by using the target triple, and the knowledge tree is converted into a text sequence, where a root node of the knowledge tree is a target entity, a leaf node of the knowledge tree is a reference entity, the reference entity is another entity in the target triple except the target entity, and a middle node between the root node and the leaf node is an entity relationship between the target entity and the reference entity, and on this basis, the text sequence may be merged into the target entity to be completed with the text, so as to obtain a merged text. According to the method, the knowledge tree is constructed by the target triple, and the knowledge tree is converted into the text sequence, so that the text sequence is fused to the target entity of the text to be completed to obtain the fused text, the method is favorable for converting the target triple into the text sequence with the structural characteristics by constructing the knowledge tree, the readability of the fused text can be further improved, and the accuracy of the subsequent completion prediction can be improved.
In one specific implementation scenario, please refer to fig. 11 in combination, and fig. 11 is a schematic diagram of a framework of an embodiment of a knowledge tree. As shown in fig. 11, taking as an example the to-be-complemented text "as one of the vienna classical haplotypes, designated as the saletsburg palace artist in 1772", its corresponding target triplet includes: < mozart, place of birth, salborg >, < salborg, memorial day, mozart week >, so the target entity "salborg" can be used as the root node of the knowledge tree, the reference entities "mozart" and "mozart week" can be used as the leaf nodes, and the entity relationships "place of birth" and "memorial day" can be used as the intermediate nodes of the root node and the leaf nodes, respectively. It should be noted that in the embodiments of the present disclosure and the following disclosure, unless otherwise specified, the root node represents a node in the knowledge tree where no parent node exists, and the leaf node represents a node in the knowledge tree where no child node exists.
In another specific implementation scenario, the knowledge tree is a binary tree, and on this basis, the knowledge tree may be traversed sequentially in a middle-order traversal manner, and a combination of the terms traversed sequentially is used as a text sequence. In the disclosed embodiments and the following disclosed embodiments, the middle-order traversal mode is a binary tree traversal mode, which may also be referred to as a middle root traversal mode and a middle-order tour, and when the middle-order traversal mode is adopted, a left sub-tree is traversed first, then a root node is visited, and finally a right sub-tree is traversed. Referring to fig. 11, taking the knowledge tree shown in fig. 11 as an example, when the knowledge tree is traversed in a middle-order traversal manner, the left sub-tree is traversed first: "mozart", "place of birth", and then access the root node: "Saertburgh", and finally traversing the right subtree: the "memorial day" and "mozart week" are combined by sequentially traversing words, namely, the "mozart week" of memorial day of saertdeburg, a birth of mozart, as a text sequence. Other cases may be analogized, and no one example is given here.
In another specific implementation scenario, after the text sequence is obtained, the target entity in the text to be completed may be replaced by the text sequence to obtain a fused text. Referring to fig. 12, fig. 12 is a state diagram illustrating an embodiment of a process for obtaining a fused text. As shown in fig. 12, taking the to-be-complemented text "as one of the representative characters of vienna classical haplotuses" () being appointed as saertburg tynday celebrity in 1772 as an example, after the above entity search, knowledge tree construction and conversion, the text sequence "mozart celebrate souvenir day mozart week" can be obtained, on the basis of which, the target entity in the to-be-complemented text can be directly replaced with the text sequence, so as to obtain the fused text "as one of the representative characters of vienna classical haplotuses" () being appointed as mozart celebrate souvenir day mozart tynday celebrate in 1772. Other cases may be analogized, and no one example is given here.
Step S1030: and performing completion prediction on the fused text by using a second text library to obtain at least one candidate word at the missing position.
Specifically, the second text library includes at least one reference text, and the reference text includes at least one reference word, and semantic extraction is performed on the reference word, so that word semantic representation of the reference word can be obtained, and the specific process may refer to relevant descriptions in the foregoing disclosed embodiments, which is not described herein again. On the basis, according to the position sequence, the first digital sequence bits can be sequentially coded for the words belonging to the text to be complemented in the fused text, the second digital sequence bits can be sequentially coded for the words belonging to the target triple in the fused text, and the largest first digital sequence bit is smaller than the smallest second digital sequence bit, so that semantic extraction is carried out on the coded fused text, the individual semantic representation of each missing position is obtained, and further, for each missing position, the individual semantic representation of the missing position and the word semantic representation of each reference word can be utilized to obtain at least one candidate word of the missing position. According to the method, the first digital sequence is sequentially coded for the words belonging to the text to be complemented in the fused text according to the position sequence, the second digital sequence is sequentially coded for the words belonging to the target triple in the fused text, and the largest first digital sequence is smaller than the smallest second digital sequence, so that the field knowledge can be fused under the condition that the original word sequence of the text to be complemented is not changed in the complementing prediction process, on the basis, the second semantic extraction is performed on the coded fused text to obtain the individual semantic representation of each missing position, and at least one candidate word of the missing position is obtained by utilizing the individual semantic representation of the missing position and the word semantic representation of each reference word, so that the accuracy of the individual semantic representation can be improved, and the accuracy of the complementing prediction can be improved.
In an implementation scenario, as described in the foregoing disclosure, before encoding according to the position precedence order, a default symbol may be added to each missing position of the merged text. The specific setting manner of the default symbol may refer to the related description in the foregoing disclosed embodiments, for example, may be set as [ mask ], which is not limited herein.
In another implementation scenario, [ CLS ] and [ SEP ] can be added as the start flag and the end flag respectively at the beginning and the end of the fused text. Taking the above-mentioned fused text "as one of the representative characters of the vienna classical haplothy, () being appointed as the mazen of mazen celebrate souvenir mazen of sazen burgh in 1772 as an example, it can be treated as" [ CLS ] as one of the representative characters of the vienna classical haplothy, [ mask ] being appointed as the mazen of mazen celebrate souvenir mazen [ SEP ] in mozen celebrate in 1772, and the rest can be analogized and so on, which is not illustrated herein.
In another implementation scenario, in order to facilitate the implementation of the prediction of mixed granularity of characters, words, entities, and the like, the method can further perform word segmentation and part-of-speech tagging on the fused text to obtain a plurality of words tagged with part-of-speech categories, and segment words with the part-of-speech categories as preset categories one by one. The specific ways of word segmentation and part-of-speech tagging can refer to the related descriptions in the foregoing disclosed embodiments, and are not described herein again. In addition, the preset category may be set as a place name, and specific reference may be made to the related description in the foregoing disclosed embodiments, which is not described herein again. Still taking the fused text "as one of the vienna classical happies representative characters, () appointed as mozart celebrate souvenir muzart peri palace musician in 1772 as an example, the related steps in the previously disclosed embodiments can be adopted to perform the padding of default symbols, start symbols and end symbols, and the segmentation, part of speech tagging and word-by-word segmentation, and finally the fused text can be processed as:
Figure BDA0002827417760000191
in the case that the fused text is other text, the analogy can be done, and no one example is given here.
In yet another implementation scenario, to distinguish between words belonging to the text to be complemented and words belonging to the target triplet, a sequence start flag may also be complemented before the text sequence in the fused text and a sequence end flag may be complemented after the text sequence. The sequence start flag and the sequence end flag may be set according to actual application requirements, for example, < S > may be used as the sequence start flag, and < T > may be used as the sequence end flag. On this basis, the fused text "as one of the vienna classical happies representative characters, () appointed as mozart's celebrating memorial mozart monpott in mozart in 1772" can be treated as:
Figure BDA0002827417760000192
in another implementation scenario, since the target entity exists in both the target triplet and the text to be complemented, in order to further maintain the original word order of the text to be complemented, the target entity may be regarded as a word belonging to the text to be complemented, that is, the target entity is encoded as the first numerical order. Also, the second digit order may be encoded immediately after the first digit order, e.g., the largest first digit order is i, and the smallest second digit order may be i + 1. Still taking the above-mentioned text to be completed "as one of the wiener classical happies representatives, () was designated as the sautsburg palace artist in 1772" as an example, the position-coded fused text can be represented as:
Figure BDA0002827417760000193
furthermore, as described in the foregoing disclosure, in the case that the source condition includes a second text base derived from a preset knowledge domain, the complementary prediction may be performed using a third prediction network, and the third prediction network may be specifically obtained by training a preset neural network (e.g., BERT) using sample text. On the basis, the encoded fusion text can be sent to a third prediction network, so that individual semantic representations of all missing positions can be obtained. The process of obtaining the sample text may specifically refer to the related description in the foregoing disclosed embodiments, and is not described herein again. In addition, the training process of the third prediction network may specifically refer to the following disclosure embodiments, which are not repeated herein.
In one implementation scenario, the individual semantic representations and the term semantic representation of each reference term may result in a prediction probability value for each reference term. Specifically, the prediction probability value of the reference word may indicate the possibility that the word missing at the missing position is the reference word, and the higher the prediction probability value is, the higher the possibility that the word missing at the missing position is the reference word is. On the basis, the reference words at the front preset sequence positions can be selected as candidate words at the missing positions according to the descending sequence of the prediction probability values. The setting manner of the preset sequence bits can refer to the related description, and is not described herein again.
In a specific implementation scenario, as described above, the encoded fused text is sent to the third prediction network, so that an individual semantic representation of the missing position can be obtained, for convenience of description, the individual semantic representation can be denoted as h, the term semantic representation of each reference term can be denoted as W, it should be noted that W is a set of term semantic representations of each reference term, and then the probability prediction value p can be calculated according to the following equation:
p=softmax(h·W)……(10)
in the above equation (10), p represents the prediction probability value of each reference word, h represents the individual semantic representation of the deletion position, W represents the word semantic representation of each reference word,. represents the dot product operation, and softmax represents the normalization processing. Reference may be made to the related description in the foregoing disclosed embodiments, and details are not repeated herein.
It should be noted that, in the case that a target triple including a target entity cannot be searched, the fused text is the text to be supplemented itself, in this case, the supplementation prediction cannot refer to the domain knowledge, that is, the semantic extraction may be directly performed on the text to be supplemented to obtain the individual semantic representation of each missing position, and for each missing position, at least one candidate word at the missing position is obtained by using the individual semantic representation of the missing position and the word semantic representation of each reference word, which may be specifically referred to the relevant description in the foregoing disclosed embodiment, and is not described herein again. Therefore, the completion prediction can be performed on the text to be completed no matter whether the target triple can be searched, so that the field knowledge can be used in a pluggable manner, and the flexibility of the completion prediction can be greatly improved.
In addition, in the case of updating the knowledge graph, the searched target triple may also be changed, and in this case, at least one candidate word of the missing position may still be predicted by using the steps in the embodiment of the present disclosure. Therefore, no matter whether the knowledge graph is updated or not, the follow-up completion prediction of the image can not be carried out, and therefore the expansibility of the completion prediction can be greatly improved.
In addition, when the full text to be supplemented includes a plurality of missing positions, the above-described method may be respectively adopted for performing the completion prediction on each missing position, and finally, the candidate word of each missing position is obtained.
Different from the embodiment, the target triple containing the target entity is obtained by searching the entities in the triples, and the target triple is fused at the target entity of the text to be completed to obtain the fused text, so that the second text library is used for performing completion prediction on the fused text to obtain at least one candidate word at the missing position. Therefore, the target triple containing the target entity is obtained through searching, and the target triple is fused into the target entity of the text to be supplemented, so that the domain knowledge closely related to the text to be supplemented can be fused into the text to be supplemented, and the accuracy of subsequent completion prediction can be further improved.
Referring to fig. 13, fig. 13 is a flowchart illustrating an embodiment of a third predictive network training process. In the embodiment of the present disclosure, the sample knowledge graph includes a plurality of sample triples, and the sample triples include two sample entities and a sample entity relationship between the two sample entities, which may specifically refer to the related description in the foregoing embodiment, and details are not repeated here. The embodiment of the present disclosure may specifically include the following steps:
step 1310: and carrying out entity search in the plurality of sample triples to obtain a sample target triple containing a sample target entity.
In the embodiment of the present disclosure, the sample target entity is an entity extracted from the sample text. Specifically, reference may be made to the related description of step S1010 in the foregoing disclosed embodiment, which is not described herein again.
Step S1320: and fusing the sample target triple into the sample target entity of the sample text to obtain the sample fused text.
Specifically, reference may be made to the related description of step S1020 in the foregoing disclosed embodiment, which is not described herein again.
Step S1330: and according to the position sequence, sequentially coding a first sample numerical sequence for the words belonging to the sample text in the sample fusion text, and sequentially coding a second sample numerical sequence for the words belonging to the sample target triple in the sample fusion text.
In the embodiment of the present disclosure, the largest first sample digit order is smaller than the smallest second sample digit order, which may specifically refer to the related description of step S1030 in the foregoing embodiment, and is not described herein again.
Step S1340: and semantic extraction is carried out on the coded sample fusion text by utilizing a third prediction network, so as to obtain the sample individual semantic representation of each sample missing position.
Specifically, reference may be made to the related description of step S1030 in the foregoing disclosed embodiment, which is not described herein again.
Step S1350: and aiming at each sample missing position, obtaining a sample prediction probability value of each reference word by using the sample individual semantic representation of the sample missing position and the word semantic representation of each reference word.
Specifically, reference may be made to the related description of step S1030 in the foregoing disclosed embodiment, which is not described herein again.
Step S1360: and acquiring a third loss value of a third prediction network based on the sample prediction probability values of the reference words at the missing positions of each sample.
Specifically, the third loss value may be calculated by using a cross-entropy loss function, which may be specifically expressed as:
Figure BDA0002827417760000201
in the above formula (7), M represents the number of missing positions of the sample in the sample text, yiIs a default word, p, corresponding to the ith missing position in the sample textiAnd the sample prediction probability value of each reference word obtained by predicting the ith missing position in the sample text is represented.
Step S1370: and adjusting the network parameter of the third predicted network by using the third loss value.
Specifically, the network parameters of the third prediction network may be adjusted by using a third loss value in a random Gradient Descent (SGD), a Batch Gradient Descent (BGD), a small Batch Gradient Descent (Mini-Batch Gradient Descent, MBGD), or other manners, where the Batch Gradient Descent refers to updating the parameters by using all samples during each iteration; the random gradient descent means that one sample is used for parameter updating in each iteration; the small batch gradient descent means that a batch of samples is used for parameter updating at each iteration, and details are not repeated here.
Different from the embodiment, the method comprises the steps of performing entity search in a plurality of sample triples to obtain sample target triples containing sample target entities, fusing the sample target triples into the sample target entities of sample texts to obtain sample fused texts, sequentially encoding words belonging to the sample texts in the sample fused texts according to the position sequence to obtain first sample digital sequence, sequentially encoding words belonging to the sample target triples in the sample fused texts to obtain second sample digital sequence, performing semantic extraction on the encoded sample fused texts by using a third prediction network to obtain sample individual semantic representations of each sample missing position, and obtaining sample prediction probability values of each reference word by using the sample individual semantic representations of the sample missing positions and the word semantic representations of each reference word for each sample missing position, and then acquiring a third loss value of a third prediction network based on the sample prediction probability value of each reference word at each sample missing position, and adjusting network parameters of the third prediction network by using the third loss value, so that a sample target triple containing a sample target entity is obtained by searching, and the sample target triple is merged into the sample target entity of the sample text, so that the domain knowledge closely related to the sample text can be merged into the sample text, and the accuracy of the third prediction network can be further improved.
It should be noted that the completion prediction methods matched with different source situations in the present application may be integrated into the same system framework as shown in fig. 2 and the above-mentioned various disclosed embodiments, or may be implemented separately and independently.
Referring to fig. 14, fig. 14 is a flowchart illustrating a text completion method according to another embodiment of the present application. Specifically, the method may include the steps of:
step S1410: and acquiring the text to be supplemented, and determining that the source of the missing content of the text to be supplemented is unknown.
In the disclosed embodiment, the text to be supplemented includes at least one missing position. Reference may be made to the related steps in the foregoing embodiments, which are not described herein again.
Step S1420: and performing word-by-word prediction on the text to be complemented to obtain at least one candidate word at the missing position.
In an implementation scenario, default characters with preset numerical values can be respectively supplemented at each missing position of a full text to be supplemented to obtain a text to be processed, the text to be processed is predicted for each missing position for a plurality of times to obtain predicted characters of the default characters corresponding to ordinal positions in the prediction times, and candidate words of the missing positions are obtained based on the predicted characters of the plurality of times. Reference may be made to the related description in the foregoing disclosed embodiments, and details are not repeated herein.
In another implementation scenario, different from the foregoing description, for the ith missing position, candidate words predicted at the missing position may be respectively supplemented at 1 st to i-1 th missing positions, default characters with preset numerical values are respectively supplemented at the ith missing position to N-th missing positions, so that a plurality of texts to be processed may be obtained, each text to be processed may be predicted for a plurality of times, predicted characters of the default characters corresponding to the ordinal positions in the number of times of prediction may be obtained, a combination of the predicted characters for the plurality of times is used as a candidate word corresponding to the text to be processed, and then the candidate word corresponding to each text to be processed may be used as a candidate word at the ith missing position, and so on until candidate words at all N missing positions are obtained. In the above manner, the prediction of the candidate word at the next missing position depends on the candidate word at the previous missing position, so that the relevance between the candidate words at each missing position in the completion prediction process can be favorably improved, and the accuracy of the candidate word at each missing position can be favorably and gradually improved in the completion prediction process of each missing position.
In a specific implementation scenario, taking a full text to be supplemented "() medical magazine" lancet "online publication () military medical institute new crown vaccine phase ii clinical trial result" as an example, the full text to be supplemented includes 2 (that is, N is 2) missing positions, for the 1 st missing position, default characters with preset numerical values may be respectively supplemented in the 2 missing positions to serve as a text to be processed, the text to be processed is used for performing a plurality of predictions, and finally, a combination of the predicted characters for a plurality of times is used as a candidate word (for example, "uk" and "usa") corresponding to the text to be processed, and a specific process of predicting the characters may refer to the related description in the foregoing disclosed embodiment, and is not described herein again. On the basis, for the 2 nd missing position, the candidate words predicted at the missing position can be respectively supplemented at the 1 st missing position, that is, the candidate words "uk" and "usa" are respectively supplemented at the 1 st missing position, and default characters with preset values are supplemented at the 2 nd missing position, so as to obtain 2 texts to be processed, for the 2 texts to be processed, prediction can be respectively carried out for a plurality of times, and finally, for the texts to be processed with the 1 st missing position supplemented in "uk", the candidate words "china" can be predicted at the 2 nd missing position, and for the texts to be processed with the 1 st missing position supplemented in "usa", the candidate words "japan" can be predicted at the 2 nd missing position, so that all 2 missing positions are completely predicted, and finally, the candidate words at the 1 st missing position include "uk" and "usa", candidate words for the 2 nd deletion position include "china" and "japan". The above example is only one possible case in the practical application process, and does not limit other possible cases. In addition, in the case that the number of the missing positions is other, the analogy can be repeated, and the examples are not repeated.
Step S1430: and obtaining the complete text of the text to be completed by using the candidate words of each missing position.
In an implementation scenario, a corresponding candidate word may be added to each missing position, so that several candidate texts of the text to be added may be obtained, and a final score of each candidate text may be obtained. Reference may be made to the related description in the foregoing disclosed embodiments, and details are not repeated herein.
In another implementation scenario, in order to improve the accuracy of the final score, a corresponding candidate word may be added to each missing position to obtain a plurality of candidate texts of the text to be added, and for each candidate text, words in the candidate texts are reversely ordered to obtain a reverse text of the candidate text, so that the final score of the candidate text is obtained based on the first score of the candidate text and the second score of the reverse text, and then one candidate text is selected as the complete text of the text to be added based on the final scores of the plurality of candidate texts. Reference may be made to the related description in the foregoing disclosed embodiments, and details are not repeated herein.
Different from the embodiment, the method comprises the steps of obtaining the text to be supplemented, determining that the source of the missing content of the text to be supplemented is unknown, performing word-by-word prediction on the text to be supplemented to obtain at least one candidate word at the missing position, and further obtaining the complete text of the text to be supplemented by using the candidate words at each missing position, so that the missing content of the text to be supplemented can be supplemented without depending on manual work, the text supplementation efficiency can be improved, and the text supplementation cost can be reduced. In addition, under the condition that the source of the missing content is unknown, the accuracy of text completion can be favorably improved through word-by-word prediction.
Referring to fig. 15, fig. 15 is a flowchart illustrating a text completion method according to another embodiment of the present application. Specifically, the method may include the steps of:
step S1510: and acquiring the text to be supplemented, and determining a text library from which the missing content of the text to be supplemented originates.
In the disclosed embodiment, the text to be supplemented includes at least one missing position. Reference may be made to the related steps in the foregoing embodiments, which are not described herein again.
Step S1520: and performing completion prediction on the text to be completed by using the text library to obtain at least one candidate word at the missing position.
In an implementation scenario, the text library includes at least one reference text, and the reference text includes at least one reference word, on this basis, semantic extraction may be performed on the text to be complemented to obtain an individual semantic representation of each missing position, and for each missing position, at least one candidate word of the missing position is obtained by using the individual semantic representation of the missing position and the word semantic representation of each reference word. Reference may be made to the related description in the foregoing disclosed embodiments, and details are not repeated herein.
In another implementation scenario, as described above, the text library includes at least one reference text, and the reference text includes at least one reference word, so that semantic extraction may be performed on the reference word to obtain a word semantic representation of the reference word, and the specific process may refer to the related description in the foregoing disclosed embodiment, and is not described herein again. On the basis, the word of the text to be complemented can be segmented to obtain a plurality of words, the word semantic representation of the reference word consistent with the words in the text to be complemented is used as the word semantic representation of the word, and then the word semantic representations of the plurality of words in the text to be complemented are fused to obtain the overall semantic representation of the text to be complemented, for example, the word semantic representation is a vector containing elements with preset dimensions (such as 128 dimensions), and the word semantic representations of the plurality of words at the same positions can be averaged to obtain the overall semantic representation of the text to be complemented. Furthermore, the similarity (e.g., cosine similarity) between the term semantic representation and the whole semantic representation of each reference term in the text library can be respectively obtained, so that the reference terms can be sorted according to the sequence of similarity from high to low, and then the reference terms positioned at the front preset order (e.g., the front 5) can be selected as candidate terms at each missing term position in the text to be completed.
Step S1530: and obtaining the complete text of the text to be completed by using the candidate words of each missing position.
In an implementation scenario, a corresponding candidate word may be added to each missing position, so that several candidate texts of the text to be added may be obtained, and a final score of each candidate text may be obtained. Reference may be made to the related description in the foregoing disclosed embodiments, and details are not repeated herein.
In another implementation scenario, in order to improve the accuracy of the final score, a corresponding candidate word may be added to each missing position to obtain a plurality of candidate texts of the text to be added, and for each candidate text, words in the candidate texts are reversely ordered to obtain a reverse text of the candidate text, so that the final score of the candidate text is obtained based on the first score of the candidate text and the second score of the reverse text, and then one candidate text is selected as the complete text of the text to be added based on the final scores of the plurality of candidate texts. Reference may be made to the related description in the foregoing disclosed embodiments, and details are not repeated herein.
Different from the embodiment, the method includes the steps that the text to be completed is obtained, the text base from which the missing content of the text to be completed originates is determined, the text base is used for performing completion prediction on the text to be completed, at least one candidate word at the missing position is obtained, and then the candidate words at all the missing positions are used for obtaining the complete text of the text to be completed. Therefore, the missing content of the text to be supplemented can be supplemented without depending on manual work, the efficiency of text supplementation can be improved, and the cost of text supplementation can be reduced. In addition, the missing content is determined to be from the text library, so that the text to be complemented is subjected to complementation prediction by using the text library, and at least one candidate word at the missing position is directly obtained, namely the missing is unknown and is not limited to the missing characters, words or entities, and the method can be favorable for realizing the prediction of mixed granularity of the characters, the words, the entities and the like.
Referring to fig. 16, fig. 16 is a flowchart illustrating a text completion method according to another embodiment of the present application. Specifically, the method may include the steps of:
step S1610: and acquiring the text to be supplemented, and determining a text library from which the missing content of the text to be supplemented originates.
In the embodiment of the disclosure, the full text to be supplemented comprises at least one missing position, and the text base relates to the field of preset knowledge. Reference may be made to the related steps in the foregoing embodiments, which are not described herein again.
Step S1620: and performing completion prediction on the text to be completed by using a knowledge map and a text library corresponding to the preset knowledge field to obtain at least one candidate word at the missing position.
In an implementation scenario, a knowledge graph includes a plurality of triples, each triplet includes two entities and an entity relationship between the two entities, on the basis, entity search can be performed in the triples to obtain a target triplet including a target entity, the target entity is an entity extracted from a text to be supplemented, the target triplet is fused at the target entity of the text to be supplemented to obtain a fused text, and therefore a text library is used for performing completion prediction on the fused text to obtain at least one candidate word at a missing position. Reference may be made to the related description in the foregoing disclosed embodiments, and details are not repeated herein.
In another implementation scenario, similar to the foregoing description, the knowledge graph includes a plurality of triples, each triplet includes two entities and an entity relationship between the two entities, and on this basis, an entity search may be performed in the plurality of triples to obtain a target triplet including a target entity, and the target entity is an entity extracted from the full text to be supplemented. Different from the foregoing description, while searching for a target triple, the completion prediction may be performed on the text to be completed directly by using the text library to obtain at least one candidate word at the missing position, and the specific process may refer to the related description in the foregoing disclosed embodiment, which is not described herein again. On this basis, another entity except the target entity in the target triplet may be extracted, which may be referred to as a reference entity as described in the foregoing disclosure, and the reference entity may be used to further screen at least one candidate word obtained by the complementary prediction, for example, the entity semantic representations of the reference entity and the word semantic representations of the respective candidate words may be used to select, in descending order of the degree of correlation, the candidate word located in the previous preset order (e.g., the previous 5) as the final candidate word at the missing position. By the method, entity searching and completion predicting can be executed in parallel, and accordingly text completion efficiency can be further improved.
Step S1630: and obtaining a complete text of the text to be completed by using the candidate segments of each missing position.
In an implementation scenario, a corresponding candidate word may be added to each missing position, so that several candidate texts of the text to be added may be obtained, and a final score of each candidate text may be obtained. Reference may be made to the related description in the foregoing disclosed embodiments, and details are not repeated herein.
In another implementation scenario, in order to improve the accuracy of the final score, a corresponding candidate word may be added to each missing position to obtain a plurality of candidate texts of the text to be added, and for each candidate text, words in the candidate texts are reversely ordered to obtain a reverse text of the candidate text, so that the final score of the candidate text is obtained based on the first score of the candidate text and the second score of the reverse text, and then one candidate text is selected as the complete text of the text to be added based on the final scores of the plurality of candidate texts. Reference may be made to the related description in the foregoing disclosed embodiments, and details are not repeated herein.
Different from the embodiment, the method includes the steps of obtaining a text to be completed, determining a text base from which missing contents of the text to be completed originate, performing completion prediction on the text to be completed by using a knowledge graph and a text base corresponding to a preset knowledge field to obtain at least one candidate word at a missing position, and obtaining a complete text of the text to be completed by using candidate segments at each missing position. Therefore, the missing content of the text to be supplemented can be supplemented without depending on manual work, the efficiency of text supplementation can be improved, and the cost of text supplementation can be reduced. In addition, because the missing content is determined to be derived from the text base related to the preset knowledge field, the completion prediction is carried out by utilizing the knowledge map and the text base corresponding to the preset knowledge field, and the accuracy of text completion is further improved.
Referring to fig. 17, fig. 17 is a block diagram illustrating an electronic device 1700 according to an embodiment of the present application. The electronic device 1700 includes a memory 1701 and a processor 1702 coupled to each other, the memory 1701 having stored therein program instructions, the processor 1702 being configured to execute the program instructions to implement the steps in any of the above-described embodiments of the text completion method. Specifically, electronic device 1700 may include, but is not limited to: desktop computers, notebook computers, tablet computers, servers, etc., without limitation thereto.
In particular, the processor 1702 is configured to control itself and the memory 1701 to implement the steps of any of the text completion method embodiments described above. Processor 1702 may also be referred to as a CPU (Central Processing Unit). The processor 1702 may be an integrated circuit chip having signal processing capabilities. The Processor 1702 may also be a general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. Additionally, the processor 1702 may be implemented collectively by an integrated circuit chip.
In some disclosed embodiments, the processor 1702 is configured to obtain the text to be supplemented, and determine a text corpus from which missing content of the text to be supplemented originates; the full text to be supplemented comprises at least one missing position, and the text library relates to the field of preset knowledge; the processor 1702 is configured to perform completion prediction on a text to be completed by using a knowledge graph and a text base corresponding to a preset knowledge field to obtain at least one candidate word at a missing position; the processor 1702 is configured to obtain a complete text of the text to be completed by using the candidate segments of the missing positions.
Different from the embodiment, the method includes the steps of obtaining a text to be completed, determining a text base from which missing contents of the text to be completed originate, performing completion prediction on the text to be completed by using a knowledge graph and a text base corresponding to a preset knowledge field to obtain at least one candidate word at a missing position, and obtaining a complete text of the text to be completed by using candidate segments at each missing position. Therefore, the missing content of the text to be supplemented can be supplemented without depending on manual work, the efficiency of text supplementation can be improved, and the cost of text supplementation can be reduced. In addition, because the missing content is determined to be derived from the text base related to the preset knowledge field, the completion prediction is carried out by utilizing the knowledge map and the text base corresponding to the preset knowledge field, and the accuracy of text completion is further improved.
In some disclosed embodiments, the knowledge-graph includes a plurality of triples, where a triplet includes two entities and an entity relationship between the two entities, and the processor 1702 is configured to perform an entity search in the plurality of triples to obtain a target triplet including a target entity; the target entity is an entity extracted from the full text to be supplemented; the processor 1702 is configured to merge the target triple into a target entity of the text to be completed, so as to obtain a merged text; the processor 1702 is configured to perform a complementary prediction on the fused text by using a text library to obtain at least one candidate word at the missing position.
Different from the embodiment, the target triple containing the target entity is obtained by searching the entities in the triples, and the target triple is fused at the target entity of the text to be completed to obtain the fused text, so that the second text library is used for performing completion prediction on the fused text to obtain at least one candidate word at the missing position. Therefore, the target triple containing the target entity is obtained through searching, and the target triple is fused into the target entity of the text to be supplemented, so that the domain knowledge closely related to the text to be supplemented can be fused into the text to be supplemented, and the accuracy of subsequent completion prediction can be further improved.
In some disclosed embodiments, the corpus of text contains at least one reference text, and the reference text contains at least one reference word, the processor 1702 is configured to identify a triplet containing the target entity as the candidate triplet, and identify another entity in the candidate triplet other than the target entity as the reference entity; the processor 1702 is configured to obtain an overall semantic representation of the text to be completed by using the term semantic representation of each reference term in the text library, and obtain an entity semantic representation of the reference entity; the processor 1702 is configured to select at least one candidate triple as a target triple based on a similarity between the entity semantic representation of the respective reference entity and the overall semantic representation, respectively.
Different from the embodiment, the triples including the target entity are used as the candidate triples, and another entity except the target entity in the candidate triples is used as the reference entity, so that the term semantic representation of each reference term in the text library is utilized to obtain the whole semantic representation of the text to be completed and the entity semantic representation of the reference entity, and then at least one candidate triplet is selected as the target triplet based on the similarity between the entity semantic representation of each reference entity and the whole semantic representation, so that the candidate triples can be further screened based on the similarity, the interference of triples with lower similarity on subsequent completion prediction can be favorably reduced, and the complexity of subsequently fusing the target triples into the text to be completed can be favorably reduced.
In some disclosed embodiments, the processor 1702 is configured to perform word segmentation and part-of-speech tagging on at least one reference text, respectively, to obtain a plurality of words tagged with part-of-speech categories; the processor 1702 is configured to segment words with part-of-speech categories as preset categories word by word, and obtain a plurality of reference words by using the segmented words and the words that are not segmented; the processor 1702 is configured to perform a first semantic extraction on the plurality of reference terms, respectively, to obtain term semantic representations of the reference terms.
Different from the foregoing embodiment, the words and parts of speech tagging are performed on at least one reference text respectively to obtain a plurality of words tagged with parts of speech categories, and the words with the parts of speech categories as preset categories are segmented word by word, so that the segmented words and the words not segmented are utilized to obtain a plurality of reference words, and further, the reference words including mixed particle sizes of characters, words, entities and the like can be obtained, and the prediction of the mixed particle sizes of the characters, the words, the entities and the like can be further facilitated to be subsequently realized.
In some disclosed embodiments, the overall semantic representation is obtained by fusing the term semantic representations of the terms in the text to be complemented; and/or, the target triplet includes: and the similarity is arranged in the candidate triples of the first two bits after being sorted from big to small.
Different from the foregoing embodiment, the overall semantic representation is obtained by fusing the term semantic representations of the terms in the text to be completed, which can be beneficial to improving the accuracy of the overall semantic representation, and the target triple is set to include: the candidate triples with the similarity ranked in the first two digits after being ranked from big to small can reduce the interference of the candidate triples with low similarity to the subsequent completion prediction, reduce the complexity of integrating the target triples into the text to be completed, and avoid the occurrence of low completion prediction accuracy caused by too few target triples.
In some disclosed embodiments, the processor 1702 is configured to construct a knowledge tree using the target triples and convert the knowledge tree into a text sequence; the root node of the knowledge tree is a target entity, the leaf nodes of the knowledge tree are reference entities, the reference entities are other entities except the target entities in the target triples, and the middle nodes between the root node and the leaf nodes are entity relationships between the target entities and the reference entities; the processor 1702 is configured to blend the text sequence into a target entity of the text to be completed, so as to obtain a blended text.
Different from the embodiment, the knowledge tree is constructed by using the target triple, and the knowledge tree is converted into the text sequence, so that the text sequence is merged into the target entity of the text to be completed to obtain the merged text, and therefore, the method is beneficial to converting the target triple into the text sequence with the structural characteristics by constructing the knowledge tree, the readability of the merged text can be further improved, and the accuracy of the subsequent completion prediction can be improved.
In some disclosed embodiments, the knowledge tree is a binary tree, and the processor 1702 is configured to sequentially traverse the knowledge tree in a middle-order traversal manner, and use a combination of the sequentially traversed words as a text sequence, and/or the processor 1702 is configured to replace a target entity in the text to be completed with the text sequence to obtain a fused text.
Different from the embodiment, the knowledge tree is a binary tree, the knowledge tree is traversed in sequence in a middle-order traversal mode, and the combination of the terms traversed in sequence is used as a text sequence, so that the readability of the text sequence can be improved, and the accuracy of subsequent completion prediction can be improved; and the target entity in the text to be supplemented is replaced by the text sequence to obtain the fused text, so that the complexity of fusing the text sequence into the text to be supplemented can be reduced.
In some disclosed embodiments, the text library includes at least one reference text, and the reference text includes at least one reference word, and the processor 1702 is configured to sequentially encode a first numerical order for words belonging to the text to be complemented in the fused text and sequentially encode a second numerical order for words belonging to the target triple in the fused text according to a position precedence order; wherein the largest first digital ordinal bit is smaller than the smallest second digital ordinal bit; the processor 1702 is configured to perform second semantic extraction on the encoded fusion text to obtain individual semantic representations of each missing position; the processor 1702 is configured to, for each missing position, derive at least one candidate word for the missing position using the individual semantic representation of the missing position and the word semantic representation of the respective reference word.
Different from the previous embodiment, by sequentially encoding the first numerical ordinal according to the position sequence of the words belonging to the text to be complemented in the fused text, and sequentially encoding the words belonging to the target triple in the fused text with second numerical sequence, wherein the largest first numerical sequence is smaller than the smallest second numerical sequence, so that the domain knowledge can be fused under the condition of keeping the original word sequence of the text to be complemented unchanged in the complementation prediction process, on the basis, second semantic extraction is carried out on the encoded fusion text to obtain individual semantic representation of each missing position, and at least one candidate word at the missing position is obtained by utilizing the individual semantic representation of the missing position and the word semantic representation of each reference word, so that the accuracy of individual semantic representation can be improved, and the accuracy of completion prediction can be improved.
In some disclosed embodiments, the first semantic extraction is performed by using a prediction network, the prediction network is obtained by training a preset neural network by using a sample text, and the sample text includes at least one sample missing position, and the processor 1702 is configured to perform word segmentation and part-of-speech tagging on an original text to obtain a plurality of words tagged with part-of-speech categories; the processor 1702 is configured to segment words with part-of-speech categories as preset categories word by word, and select words with preset proportions from the segmented words and the words that are not segmented for default; the processor 1702 is configured to use the original text after default as the sample text, and use the position of the default word as the sample missing position.
Different from the embodiment, the method includes the steps of performing word segmentation and part-of-speech tagging on an original text to obtain a plurality of words tagged with part-of-speech categories, and segmenting the words with the part-of-speech categories as preset categories word by word, selecting words with preset proportions from the segmented words and the words not segmented to default, further taking the original text after default as a sample text, and taking the position of the default word as a sample missing position of the sample text, so that the sample text with missing contents including mixed granularities of words, entities and the like can be constructed, adaptability of a prediction network obtained by subsequent training to the to-be-completed text with the mixed granularities of the missing words, entities and the like can be improved, and accuracy of subsequent completion prediction can be improved.
In some disclosed embodiments, the processor 1702 is configured to patch a corresponding candidate word at each missing position to obtain a plurality of candidate texts of the text to be padded; the processor 1702 is configured to, for each candidate text, rank the words in the candidate text in the reverse direction to obtain a reverse text of the candidate text, and obtain a final score of the candidate text based on a first score of the candidate text and a second score of the reverse text; the processor 1702 is configured to select one candidate text as a complete text of the text to be completed based on the final scores of the several candidate texts.
Different from the embodiment, a plurality of candidate texts of the text to be completed are obtained by filling a corresponding candidate word in each missing position, and the words in the candidate texts are reversely sequenced aiming at each candidate text to obtain the reverse text of the candidate text, so that the final score of the candidate text is obtained based on the first score and the second score of the reverse text of the candidate text, therefore, the forward sequence and the reverse sequence of the candidate text can be comprehensively considered for scoring in the scoring process of the candidate text, the accuracy of the final score can be improved, and the accuracy of the complete text can be improved in the subsequent process of obtaining the complete text based on the final score.
Referring to fig. 18, fig. 18 is a block diagram illustrating a storage device 1800 according to an embodiment of the present invention. The storage 1800 stores program instructions 1801 that are executable by the processor, where the program instructions 1801 are for implementing the steps in any of the above embodiments of the text completion method.
According to the scheme, the efficiency of text completion can be improved, and the cost of text completion can be reduced.
In some embodiments, functions of or modules included in the apparatus provided in the embodiments of the present disclosure may be used to execute the method described in the above method embodiments, and specific implementation thereof may refer to the description of the above method embodiments, and for brevity, will not be described again here.
The foregoing description of the various embodiments is intended to highlight various differences between the embodiments, and the same or similar parts may be referred to each other, and for brevity, will not be described again herein.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a module or a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some interfaces, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.

Claims (12)

1. A method of text completion, comprising:
acquiring a text to be completed, and determining a text library from which missing contents of the text to be completed originate; the text to be completed comprises at least one missing position, and the text library relates to the field of preset knowledge;
performing completion prediction on the text to be completed by using a knowledge graph corresponding to the preset knowledge field and the text library to obtain at least one candidate word of the missing position;
and obtaining the complete text of the text to be completed by using the candidate segments of the missing positions.
2. The method of claim 1, wherein the knowledge-graph contains a number of triples, the triples including two entities and an entity relationship between the two entities; the performing completion prediction on the text to be completed by using the knowledge graph corresponding to the preset knowledge field and the text library to obtain at least one candidate word of the missing position comprises:
searching entities in the triples to obtain a target triplet containing a target entity; the target entity is an entity extracted from the text to be completed;
fusing the target triple into the target entity of the text to be completed to obtain a fused text;
and performing completion prediction on the fusion text by using the text library to obtain at least one candidate word at the missing position.
3. The method of claim 2, wherein the text library includes at least one reference text, and the reference text includes at least one reference word; the searching the entities in the triples to obtain the target triples containing the target entities includes:
taking a triple containing the target entity as a candidate triple, and taking another entity except the target entity in the candidate triple as a reference entity;
acquiring the whole semantic representation of the text to be completed by utilizing the word semantic representation of each reference word in the text library, and acquiring the entity semantic representation of the reference entity;
and selecting at least one candidate triple as the target triple based on the similarity between the entity semantic representation of each reference entity and the overall semantic representation.
4. The method of claim 3, wherein before the obtaining the overall semantic representation of the text to be completed and the entity semantic representation of the reference entity using the term semantic representations of the respective reference terms in the text corpus, the method further comprises:
performing word segmentation and part-of-speech tagging on the at least one reference text respectively to obtain a plurality of words tagged with part-of-speech categories;
segmenting words with part-of-speech categories as preset categories word by word, and obtaining a plurality of reference words by utilizing segmented words and words which are not segmented;
and respectively carrying out first semantic extraction on the plurality of reference words to obtain word semantic representations of the reference words.
5. The method according to claim 3, wherein the overall semantic representation is obtained by means of word semantic representation fusion of each word in the text to be complemented;
and/or, the target triplet includes: and the similarity is arranged in the candidate triples of the first two bits after being sorted from big to small.
6. The method according to claim 2, wherein the fusing the target triple into the target entity of the text to be completed to obtain a fused text, includes:
constructing a knowledge tree by using the target triple, and converting the knowledge tree into a text sequence; wherein a root node of the knowledge tree is the target entity, a leaf node of the knowledge tree is a reference entity, the reference entity is another entity in the target triple except the target entity, and an intermediate node between the root node and the leaf node is an entity relationship between the target entity and the reference entity;
and fusing the text sequence into the target entity of the text to be completed to obtain the fused text.
7. The method of claim 6, wherein the knowledge tree is a binary tree; the converting the knowledge tree into a text sequence includes:
sequentially traversing the knowledge tree in a middle-order traversal mode, and taking the combination of the sequentially traversed words as the text sequence;
and/or, the step of blending the text sequence into the target entity of the text to be completed to obtain the blended text comprises:
and replacing the target entity in the text to be supplemented with the text sequence to obtain the fusion text.
8. The method of claim 2, wherein the text library includes at least one reference text, and the reference text includes at least one reference word; the performing completion prediction on the fused text by using the text library to obtain at least one candidate word of the missing position includes:
according to the position sequence, sequentially coding a first digital sequence order for the words belonging to the text to be complemented in the fused text, and sequentially coding a second digital sequence order for the words belonging to the target triple in the fused text; wherein the largest of the first digital ordinal bits is less than the smallest of the second digital ordinal bits;
performing second semantic extraction on the encoded fusion text to obtain individual semantic representation of each missing position;
and aiming at each missing position, obtaining at least one candidate word of the missing position by utilizing the individual semantic representation of the missing position and the word semantic representation of each reference word.
9. The method of claim 8, wherein the first semantic extraction is performed using a prediction network, wherein the prediction network is obtained by training a pre-set neural network using sample text, and wherein the sample text comprises at least one sample missing position; the step of obtaining the sample text comprises:
performing word segmentation and part-of-speech tagging on an original text to obtain a plurality of words tagged with part-of-speech categories;
segmenting words with the part of speech category as a preset category word by word, and selecting words with a preset proportion from the segmented words and the words which are not segmented for default;
and taking the original text after default as the sample text, and taking the position of the default word as the missing position of the sample.
10. The method according to claim 1, wherein the obtaining a complete text of the text to be completed by using the candidate segments of the missing positions comprises:
filling a corresponding candidate word in each missing position to obtain a plurality of candidate texts of the text to be filled;
for each candidate text, reversely ordering words in the candidate text to obtain a reverse text of the candidate text, and obtaining a final score of the candidate text based on a first score of the candidate text and a second score of the reverse text;
and selecting one candidate text as a complete text of the text to be completed based on the final scores of the candidate texts.
11. An electronic device comprising a memory and a processor coupled to each other, the memory having stored therein program instructions, the processor being configured to execute the program instructions to implement the text completion method of any one of claims 1 to 10.
12. A storage device storing program instructions executable by a processor to perform the text completion method of any one of claims 1 to 10.
CN202011452090.XA 2020-12-09 2020-12-09 Text completion method, electronic equipment and storage device Active CN112560477B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011452090.XA CN112560477B (en) 2020-12-09 2020-12-09 Text completion method, electronic equipment and storage device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011452090.XA CN112560477B (en) 2020-12-09 2020-12-09 Text completion method, electronic equipment and storage device

Publications (2)

Publication Number Publication Date
CN112560477A true CN112560477A (en) 2021-03-26
CN112560477B CN112560477B (en) 2024-04-16

Family

ID=75061289

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011452090.XA Active CN112560477B (en) 2020-12-09 2020-12-09 Text completion method, electronic equipment and storage device

Country Status (1)

Country Link
CN (1) CN112560477B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114090722A (en) * 2022-01-19 2022-02-25 支付宝(杭州)信息技术有限公司 Method and device for automatically completing query content

Citations (30)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080195388A1 (en) * 2007-02-08 2008-08-14 Microsoft Corporation Context based word prediction
US20100131447A1 (en) * 2008-11-26 2010-05-27 Nokia Corporation Method, Apparatus and Computer Program Product for Providing an Adaptive Word Completion Mechanism
CN102662987A (en) * 2012-03-14 2012-09-12 华侨大学 Classification method of web text semantic based on Baidu Baike
CN106155999A (en) * 2015-04-09 2016-11-23 科大讯飞股份有限公司 Semantics comprehension on natural language method and system
US20180101599A1 (en) * 2016-10-08 2018-04-12 Microsoft Technology Licensing, Llc Interactive context-based text completions
CN108334487A (en) * 2017-07-14 2018-07-27 腾讯科技(深圳)有限公司 Lack semantics information complementing method, device, computer equipment and storage medium
CN109408826A (en) * 2018-11-07 2019-03-01 北京锐安科技有限公司 A kind of text information extracting method, device, server and storage medium
CN109614501A (en) * 2018-12-13 2019-04-12 浙江工商大学 A kind of industrial hidden danger standardization report method and system of knowledge based map
CN109977234A (en) * 2019-03-28 2019-07-05 哈尔滨工程大学 A kind of knowledge mapping complementing method based on subject key words filtering
CN110019687A (en) * 2019-04-11 2019-07-16 宁波深擎信息科技有限公司 A kind of more intention assessment systems, method, equipment and the medium of knowledge based map
CN110275960A (en) * 2019-06-11 2019-09-24 中国电子科技集团公司电子科学研究院 Representation method and system based on the knowledge mapping and text information for censuring sentence
CN110825875A (en) * 2019-11-01 2020-02-21 科大讯飞股份有限公司 Text entity type identification method and device, electronic equipment and storage medium
CN110851615A (en) * 2019-09-09 2020-02-28 中国电子科技集团公司电子科学研究院 Complementary deduction method and device of parameter-shared knowledge graph
US10594757B1 (en) * 2017-08-04 2020-03-17 Grammarly, Inc. Sender-receiver interface for artificial intelligence communication assistance for augmenting communications
CN111144127A (en) * 2019-12-25 2020-05-12 科大讯飞股份有限公司 Text semantic recognition method and model acquisition method thereof and related device
CN111142965A (en) * 2019-12-16 2020-05-12 深圳市优必选科技股份有限公司 Language configuration method and device, electronic equipment and storage medium
CN111144110A (en) * 2019-12-27 2020-05-12 科大讯飞股份有限公司 Pinyin marking method, device, server and storage medium
CN111275091A (en) * 2020-01-16 2020-06-12 平安科技(深圳)有限公司 Intelligent text conclusion recommendation method and device and computer readable storage medium
CN111444695A (en) * 2020-03-25 2020-07-24 腾讯科技(深圳)有限公司 Text generation method, device and equipment based on artificial intelligence and storage medium
CN111507088A (en) * 2020-04-15 2020-08-07 深圳前海微众银行股份有限公司 Sentence completion method, equipment and readable storage medium
CN111552811A (en) * 2020-04-24 2020-08-18 深圳数联天下智能科技有限公司 Method and device for information completion in knowledge graph, computer equipment and storage medium
CN111651570A (en) * 2020-05-13 2020-09-11 深圳追一科技有限公司 Text sentence processing method and device, electronic equipment and storage medium
CN111708882A (en) * 2020-05-29 2020-09-25 西安理工大学 Transformer-based Chinese text information missing completion method
CN111709240A (en) * 2020-05-14 2020-09-25 腾讯科技(武汉)有限公司 Entity relationship extraction method, device, equipment and storage medium thereof
CN111753051A (en) * 2020-06-19 2020-10-09 贵州华创智道知识产权服务有限公司 Text data query subscription method and system
CN111831806A (en) * 2020-07-02 2020-10-27 北京小米松果电子有限公司 Semantic integrity determination method and device, electronic equipment and storage medium
CN111859968A (en) * 2020-06-15 2020-10-30 深圳航天科创实业有限公司 Text structuring method, text structuring device and terminal equipment
CN111859974A (en) * 2019-04-22 2020-10-30 广东小天才科技有限公司 Semantic disambiguation method and device combined with knowledge graph and intelligent learning equipment
CN112000815A (en) * 2020-10-28 2020-11-27 科大讯飞(苏州)科技有限公司 Knowledge graph complementing method and device, electronic equipment and storage medium
CN112035672A (en) * 2020-07-23 2020-12-04 深圳技术大学 Knowledge graph complementing method, device, equipment and storage medium

Patent Citations (30)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080195388A1 (en) * 2007-02-08 2008-08-14 Microsoft Corporation Context based word prediction
US20100131447A1 (en) * 2008-11-26 2010-05-27 Nokia Corporation Method, Apparatus and Computer Program Product for Providing an Adaptive Word Completion Mechanism
CN102662987A (en) * 2012-03-14 2012-09-12 华侨大学 Classification method of web text semantic based on Baidu Baike
CN106155999A (en) * 2015-04-09 2016-11-23 科大讯飞股份有限公司 Semantics comprehension on natural language method and system
US20180101599A1 (en) * 2016-10-08 2018-04-12 Microsoft Technology Licensing, Llc Interactive context-based text completions
CN108334487A (en) * 2017-07-14 2018-07-27 腾讯科技(深圳)有限公司 Lack semantics information complementing method, device, computer equipment and storage medium
US10594757B1 (en) * 2017-08-04 2020-03-17 Grammarly, Inc. Sender-receiver interface for artificial intelligence communication assistance for augmenting communications
CN109408826A (en) * 2018-11-07 2019-03-01 北京锐安科技有限公司 A kind of text information extracting method, device, server and storage medium
CN109614501A (en) * 2018-12-13 2019-04-12 浙江工商大学 A kind of industrial hidden danger standardization report method and system of knowledge based map
CN109977234A (en) * 2019-03-28 2019-07-05 哈尔滨工程大学 A kind of knowledge mapping complementing method based on subject key words filtering
CN110019687A (en) * 2019-04-11 2019-07-16 宁波深擎信息科技有限公司 A kind of more intention assessment systems, method, equipment and the medium of knowledge based map
CN111859974A (en) * 2019-04-22 2020-10-30 广东小天才科技有限公司 Semantic disambiguation method and device combined with knowledge graph and intelligent learning equipment
CN110275960A (en) * 2019-06-11 2019-09-24 中国电子科技集团公司电子科学研究院 Representation method and system based on the knowledge mapping and text information for censuring sentence
CN110851615A (en) * 2019-09-09 2020-02-28 中国电子科技集团公司电子科学研究院 Complementary deduction method and device of parameter-shared knowledge graph
CN110825875A (en) * 2019-11-01 2020-02-21 科大讯飞股份有限公司 Text entity type identification method and device, electronic equipment and storage medium
CN111142965A (en) * 2019-12-16 2020-05-12 深圳市优必选科技股份有限公司 Language configuration method and device, electronic equipment and storage medium
CN111144127A (en) * 2019-12-25 2020-05-12 科大讯飞股份有限公司 Text semantic recognition method and model acquisition method thereof and related device
CN111144110A (en) * 2019-12-27 2020-05-12 科大讯飞股份有限公司 Pinyin marking method, device, server and storage medium
CN111275091A (en) * 2020-01-16 2020-06-12 平安科技(深圳)有限公司 Intelligent text conclusion recommendation method and device and computer readable storage medium
CN111444695A (en) * 2020-03-25 2020-07-24 腾讯科技(深圳)有限公司 Text generation method, device and equipment based on artificial intelligence and storage medium
CN111507088A (en) * 2020-04-15 2020-08-07 深圳前海微众银行股份有限公司 Sentence completion method, equipment and readable storage medium
CN111552811A (en) * 2020-04-24 2020-08-18 深圳数联天下智能科技有限公司 Method and device for information completion in knowledge graph, computer equipment and storage medium
CN111651570A (en) * 2020-05-13 2020-09-11 深圳追一科技有限公司 Text sentence processing method and device, electronic equipment and storage medium
CN111709240A (en) * 2020-05-14 2020-09-25 腾讯科技(武汉)有限公司 Entity relationship extraction method, device, equipment and storage medium thereof
CN111708882A (en) * 2020-05-29 2020-09-25 西安理工大学 Transformer-based Chinese text information missing completion method
CN111859968A (en) * 2020-06-15 2020-10-30 深圳航天科创实业有限公司 Text structuring method, text structuring device and terminal equipment
CN111753051A (en) * 2020-06-19 2020-10-09 贵州华创智道知识产权服务有限公司 Text data query subscription method and system
CN111831806A (en) * 2020-07-02 2020-10-27 北京小米松果电子有限公司 Semantic integrity determination method and device, electronic equipment and storage medium
CN112035672A (en) * 2020-07-23 2020-12-04 深圳技术大学 Knowledge graph complementing method, device, equipment and storage medium
CN112000815A (en) * 2020-10-28 2020-11-27 科大讯飞(苏州)科技有限公司 Knowledge graph complementing method and device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
鲍开放等: "基于结构与文本联合表示的知识图谱补全方法", 《计算机工程》, vol. 44, no. 7 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114090722A (en) * 2022-01-19 2022-02-25 支付宝(杭州)信息技术有限公司 Method and device for automatically completing query content
CN114090722B (en) * 2022-01-19 2022-04-22 支付宝(杭州)信息技术有限公司 Method and device for automatically completing query content

Also Published As

Publication number Publication date
CN112560477B (en) 2024-04-16

Similar Documents

Publication Publication Date Title
US11113234B2 (en) Semantic extraction method and apparatus for natural language, and computer storage medium
CN107463666B (en) sensitive word filtering method based on text content
CN110020424B (en) Contract information extraction method and device and text information extraction method
CN103218444B (en) Based on semantic method of Tibetan language webpage text classification
EP2643770A2 (en) Text segmentation with multiple granularity levels
CN112560476A (en) Text completion method, electronic device and storage device
WO2016095645A1 (en) Stroke input method, device and system
CN106383836A (en) Ascribing actionable attributes to data describing personal identity
CN109508448A (en) Short information method, medium, device are generated based on long article and calculate equipment
CN106997339A (en) Text feature, file classification method and device
JP6186198B2 (en) Learning model creation device, translation device, learning model creation method, and program
CN114528944B (en) Medical text coding method, device, equipment and readable storage medium
CN112560477A (en) Text completion method, electronic device and storage device
CN117371534B (en) Knowledge graph construction method and system based on BERT
WO2022160445A1 (en) Semantic understanding method, apparatus and device, and storage medium
CN117036833B (en) Video classification method, apparatus, device and computer readable storage medium
CN110019958A (en) A kind of generation method, device and the terminal device of films and television programs label
CN107679122A (en) One kind searches for method and terminal generally
Goh Using named entity recognition for automatic indexing
CN113158648A (en) Text completion method, electronic device and storage device
CN111950274A (en) Chinese word segmentation method and device for linguistic data in professional field
JP4266240B1 (en) Item judgment system and item judgment program
CN112559761A (en) Method and system for generating text based on map, electronic equipment and storage medium
CN113688615A (en) Method, device and storage medium for generating field annotation and understanding character string
JPS61248160A (en) Document information registering system

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
CB02 Change of applicant information

Address after: 311-2, 3 / F, building 5, East District, No.10 courtyard, northwest Wangdong Road, Haidian District, Beijing

Applicant after: iFLYTEK (Beijing) Co.,Ltd.

Applicant after: Hebei Xunfei Institute of Artificial Intelligence

Applicant after: IFLYTEK Co.,Ltd.

Address before: 311-2, 3 / F, building 5, East District, No.10 courtyard, northwest Wangdong Road, Haidian District, Beijing

Applicant before: Zhongke Xunfei Internet (Beijing) Information Technology Co.,Ltd.

Applicant before: Hebei Xunfei Institute of Artificial Intelligence

Applicant before: IFLYTEK Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant