Text processing method and device, storage medium, electronic device and system

By generating and storing index relationships, the real-time problem caused by offline updates of the text rewriting model is solved, achieving real-time performance and efficiency in online text rewriting.

CN114817447BActive Publication Date: 2026-01-16BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210495448.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-07
Publication Date
2026-01-16
Estimated Expiration
2042-05-07

AI Technical Summary

Technical Problem

In existing technologies, offline updates of text rewriting models affect the real-time performance of online text processing, resulting in insufficient real-time performance of text rewriting in industrial application scenarios.

Method used

By generating index relationships and storing them in an index database, online intervention on the input text is achieved, avoiding the need for offline model updates and directly using the index relationships in the index database to rewrite the text.

Benefits of technology

It enables real-time text rewriting, improving the efficiency and accuracy of text processing in industrial applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114817447B_ABST
    Figure CN114817447B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a text processing method, device, storage medium, electronic equipment and system, the method comprising: obtaining a target example text needing rewriting and a target phrase rewriting example pair corresponding to the target example text, the target phrase rewriting example pair comprising a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase; generating an index relationship according to the target example text and the target phrase rewriting example pair; storing the index relationship to an index database; and performing text rewriting on an input text obtained according to the index relationship in the index database, thereby solving the problem of affecting the real-time performance of online text rewriting due to the offline updating of a model for text rewriting.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of natural language processing, in particular, to a text processing method and device, a storage medium, an electronic device and system. BACKGROUND

[0002] In the related art, the original input text obtained may not reasonably express its original meaning, therefore, it is necessary to intervene in the processing (such as rewriting) of such text in order to better express its original meaning.

[0003] However, in the traditional text rewriting, a model is usually used to rewrite the text, and the offline updating of the model is involved in the use of the model, and in the actual industrial application scenario, online real-time processing of the text is particularly important, therefore, the way of offline updating of the model will seriously affect the real-time performance of online processing of the text. SUMMARY

[0004] This summary is provided to introduce a selection of concepts, which will be described with greater specificity below in the detailed description section. This summary is not intended to identify key or essential features of the claimed technology, nor is it intended to limit the scope of the claimed technology.

[0005] In a first aspect, the present disclosure provides a text processing method, comprising:

[0006] obtaining a target example text to be rewritten and a target phrase rewriting example pair corresponding to the target example text, the target phrase rewriting example pair comprising a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase;

[0007] generating an index relationship according to the target example text and the target phrase rewriting example pair;

[0008] storing the index relationship to an index database;

[0009] rewriting the input text obtained according to the index relationship in the index database.

[0010] In a second aspect, the present disclosure provides a text processing device, comprising:

[0011] a first obtaining module configured to obtain a target example text to be rewritten and a target phrase rewriting example pair corresponding to the target example text, the target phrase rewriting example pair comprising a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase;

[0012] generating an index relationship according to the target example text and the target phrase rewriting example pair;

[0013] storing the index relationship to an index database;

[0014] rewriting the input text according to the index relationship in the index database.

[0015] In a third aspect, the present disclosure provides a computer readable medium having stored thereon a computer program, which, when executed by a processing device, implements the steps of the method of the first aspect.

[0016] In a fourth aspect, the present disclosure provides an electronic device comprising:

[0017] a storage device having stored thereon a computer program;

[0018] a processing device configured to execute the computer program in the storage device to implement the steps of the method of the first aspect.

[0019] In a fifth aspect, the present disclosure provides a text processing system comprising:

[0020] an index database;

[0021] an index server;

[0022] an intervention platform configured to obtain a target example text and a target phrase rewriting example pair corresponding to the target example text, the target phrase rewriting example pair comprising a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase;

[0023] The index server is configured to obtain the target example text and the target phrase rewriting example pair from the intervention platform, generate an index relationship according to the obtained target example text and the target phrase rewriting example pair, and store the index relationship to the index database. The index server is also configured to rewrite an input text according to the index relationship in the index database.

[0024] According to the above technical solution, since the index relationship can be generated according to the obtained target example text and target phrase rewriting example pair and directly stored in the index database, online intervention of the index database can be realized without offline updating of the index database, and rewriting of the input text can be realized through the index relationship in the index database, thereby solving the problem of affecting the real-time performance of online text rewriting due to offline updating of the model for text rewriting.

[0025] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description

[0026] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale. In the drawings:

[0027] Figure 1 This is a schematic diagram illustrating a text processing system according to an exemplary embodiment of the present disclosure.

[0028] Figure 2 This is a flowchart illustrating a text processing method according to an exemplary embodiment of the present disclosure.

[0029] Figure 3 This is a schematic diagram illustrating an index relationship generation method according to an exemplary embodiment of the present disclosure.

[0030] Figure 4 This is a schematic diagram of the structure of a BERT model according to an exemplary embodiment of the present disclosure.

[0031] Figure 5 This is a block diagram illustrating a text processing apparatus according to an exemplary embodiment of the present disclosure.

[0032] Figure 6 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment of the present disclosure. Detailed Implementation

[0033] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0034] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0035] As used herein, the term "includes" and its variants are to be read to be analogous to "comprises," or "comprising." The term "based on" is to be read as "based, at least in part, on." The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments." Related terms have corresponding meanings.

[0036] It should be noted that the terms "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not intended to limit the order or interdependence of the functions performed by these devices, modules or units.

[0037] It should be noted that the terms "one", "multiple" mentioned in the present disclosure are illustrative and not restrictive, and those skilled in the art should understand that "one or more" should be understood unless otherwise explicitly indicated in the context.

[0038] The names of the messages or information exchanged between the devices in the embodiments of the present disclosure are only for illustrative purposes, and are not intended to limit the scope of the messages or information.

[0039] It can be understood that, before using the technical solutions disclosed in the embodiments of the present disclosure, the type, use range, use scenario, etc. of the personal information involved in the present disclosure should be informed to the user and the authorization of the user should be obtained through appropriate means according to relevant laws and regulations.

[0040] For example, in response to receiving the active request of the user, prompt information is sent to the user to explicitly prompt the user that the operation requested to be performed will require obtaining and using the personal information of the user. Thus, the user can voluntarily choose whether to provide the personal information to the software or hardware such as electronic device, application program, server or storage medium, etc. that performs the operation of the technical solutions of the present disclosure according to the prompt information.

[0041] As an optional but not limited implementation manner, in response to receiving the active request of the user, the manner of sending prompt information to the user may, for example, be the manner of pop-up window, and the prompt information may, for example, be presented in the form of text in the pop-up window. In addition, the pop-up window may, for example, carry selection controls for the user to select "agree" or "disagree" to provide personal information to the electronic device.

[0042] It can be understood that the above notification and user authorization process is only illustrative, and does not limit the implementation manner of the present disclosure, and other manners meeting the relevant laws and regulations can also be applied to the implementation manner of the present disclosure.

[0043] Meanwhile, it can be understood that the data involved in the technical solution (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of the corresponding laws, regulations and relevant provisions.

[0044] As mentioned in the background, usually a large amount of text training data is used to train a neural network model, so as to rewrite the text according to the trained neural network model, and in the actual use of the model, for the input which is greatly different from the distribution of the text training data, the model often gives abnormal output, which affects the overall performance of the model. To solve the problem of abnormal output of the model, usually the abnormal input and output instances are manually corrected (or labeled) and then fed into the model for retraining. However, the retraining of the model involves the re-adjustment and learning of the model parameters, which is usually completed in an offline stage, so as to affect the real-time performance of the text rewriting processing in the actual industrial application scenario. In addition, since the model re-onlineing may also involve the re-deployment of the environment, so as to further affect the real-time performance of the text rewriting processing in the actual industrial application scenario.

[0045] Therefore, the embodiments of the present disclosure provide a text processing method, device, storage medium, electronic equipment and system, which effectively ensure the real-time performance of text rewriting processing.

[0046] The embodiments of the present disclosure are further explained and described below in combination with the drawings.

[0047] Figure 1 is a schematic diagram of a text processing system according to an exemplary embodiment of the present disclosure. Referring to Figure 1 , the text processing method can be applied to the intervention side of the text processing system, and the intervention platform of the intervention side is used to acquire a target example text which needs to be rewritten and a target phrase rewriting example pair corresponding to the target example text. The index server (illustrated in Figure 1 ) is used to acquire the target example text and the target phrase rewriting example pair from the intervention platform, generate an index relationship according to the acquired target example text and the target phrase rewriting example pair, and store the index relationship to an index database (illustrated in Figure 1 ). The index server is also used to perform text rewriting on the acquired input text according to the index relationship in the index database. Specifically, when the index server receives an index processing request (RPC, Remote Procedure Call) initiated by the intervention platform, Figure 1 , the index server generates the index relationship.

[0048] Continuing to refer to Figure 1In some embodiments, the intervention platform on the intervention side is used to receive example text to be rewritten and phrase rewriting example pairs corresponding to the example text from expert input. The intervention platform on the intervention side is also used to search a corpus database based on the example text. Figure 1 The inverted index of the Chinese-Israeli corpus (illustrated) retrieves the recalled text and example rewritten phrase pairs corresponding to the inverted index of the text and phrases. The intervention platform on the intervention side also stores the example text, recalled text, and example rewritten phrase pairs in the intervention database. When the index server receives an indexing request initiated by the intervention platform, it can initialize loading from the intervention database to obtain the example text, recalled text, and example rewritten phrase pairs, and then perform index relation generation.

[0049] Continue to refer to Figure 1 In some embodiments, the index server on the intervention side is used to implement access to the index database ( Figure 1 The management of index relationships in the vector index (illustrated in Chinese) can include, for example, adding new index relationships in the index database (which can be understood as the generation of the aforementioned index relationships), deleting index relationships in the index database, and modifying index relationships in the index database.

[0050] Continue to refer to Figure 1 In some embodiments, the index server on the intervention side is also used for the application side ( Figure 1 Text processing request initiated by the application side (as illustrated) Figure 1 The text processing request, carrying the user's input text, is sent from the application to the index server via an RPC (Redirect Communication Protocol) between the application and the index service. The index server then responds to the text processing request, rewriting the user's input text. Specifically, the text processing request initiated by the application corresponds to... Figure 1 The generation service shown includes +intervention() and +generation(), where +intervention() can be a corresponding implementation of the retrieval service provided by the index server. Figure 1 The +search() function is used to determine whether the input text needs to be rewritten and, if so, to rewrite it. The +generate() function can be used to generate the rewritten text. For example, +generate() can translate the rewritten text to obtain the translated text.

[0051] Furthermore, this disclosure can be applied to scenarios including but not limited to text translation, text summarization, and intelligent dialogue. The following uses the text translation scenario as an example to explain a text processing method provided by the embodiments of this disclosure, specifically using the translation of Chinese text into English text as an example.

[0052] Figure 2is a flow chart of a text processing method according to an example embodiment of the present disclosure. Referring to Figure 2 , comprising the following steps:

[0053] Step S201, obtaining a target example text to be rewritten and a target phrase rewriting example pair corresponding to the target example text, the target phrase rewriting example pair comprising a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase.

[0054] Step S202, generating an index relationship according to the target example text and the target phrase rewriting example pair.

[0055] Step S203, storing the index relationship to an index database.

[0056] Step S204, performing text rewriting on the obtained input text according to the index relationship in the index database.

[0057] It needs to be understood that in different language environments, direct translation of the text will cause the semantic change of the sentence, that is, the translated text cannot reasonably and accurately express the original meaning, therefore, in this case, the text needs to be rewritten.

[0058] For example, taking the target example text "This dish tastes super, the chef really has two brushes" as an example, in the translation scene, the phrase "two brushes" in the target example text does not refer to the actual brush, so it cannot be directly translated as "two brushes", and then "This dish tastes super, the chef really has two brushes" needs to be rewritten.

[0059] Continuing the above example, the target example text can be "This dish tastes super, the chef really has two brushes", the target example rewriting phrase can be "two brushes", the target example replacement phrase corresponding to the target example rewriting phrase can be "point something", and the target example replacement phrase corresponding to the target example rewriting phrase can also be "something". In the case where the target example replacement phrase is "point something", "two brushes" in "This dish tastes super, the chef really has two brushes" can be directly replaced, and then the text after replacement is translated into English; in the case where the target example replacement phrase is "something", "This dish tastes super, the chef really has two brushes" can be translated first, and the English word corresponding to "two brushes" can be replaced with "something", or "two brushes" in "This dish tastes super, the chef really has two brushes" can be replaced with "something" first, and then the text after replacement is translated. The specific rewriting form does not limit the present disclosure.

[0060] It should be noted that the index relationship represents a key-value pair relationship, and the value corresponding to the key can be determined according to the key in the index relationship. For example, the semantic information of the target example rewriting phrase in the target example text can be taken as the key, and the target example replacement phrase corresponding to the target example rewriting phrase can be taken as the value to generate the index relationship.

[0061] According to the above generated index relationship, specifically, the target example rewriting phrase corresponding to the input text is found in the index relationship, and the input text is rewritten according to the target example replacement phrase corresponding to the target example rewriting phrase corresponding to the input text. The specific rewriting implementation can refer to the above examples, and this embodiment will not be described here.

[0062] It should be noted that the target example rewriting phrase corresponding to the input text actually means that the context semantic information of the target example rewriting phrase in the input text is the same as the context semantic information of the same phrase in the input text as the target example rewriting phrase.

[0063] In the above manner, since the index relationship can be generated according to the obtained target example text and target phrase rewriting example, and directly stored in the index database, online intervention of the index database can be realized without offline updating of the index database, and rewriting of the input text can be realized through the index relationship in the index database, thereby solving the problem that the model needs to be updated offline when the model is used for text rewriting, and the real-time performance of online text rewriting is affected.

[0064] In actual application, the input text of the user is various, but the same replacement can be realized for the same phrase under different sentence semantics. The following table provides some intervention (rewriting) examples:

[0065]

[0066] Table 1

[0067] The expected effects of intervention or no intervention on different input texts in Table 1 are compared. For the examples of input texts in Table 1, the ideal intervention processing of the text can be that according to the different semantics of the “two brushes” in different input texts, the context semantics of the phrase can be better obtained according to several input text examples, and more such text examples can be reasonably intervened or avoided, thereby improving the generalization of text intervention.

[0068] In order to improve the generalization of text intervention, the target example text can include expert input example text that needs to be rewritten and recalled text that also needs to be rewritten recalled from the corpus according to the example text. In this case, Figure 2Step S201 shown can be implemented in the following way: obtain the input sample text to be rewritten and the phrase rewriting example pair corresponding to the sample text, wherein the phrase rewriting example pair includes the example rewriting phrase and the example replacement phrase corresponding to the example rewriting phrase; based on the example rewriting phrase in the phrase rewriting example pair, recall the recalled text corresponding to the example rewriting phrase pair in the pre-built inverted index of text and phrases; determine the recalled text and the sample text as the target sample text, and determine the phrase rewriting example pair as the target phrase rewriting example pair.

[0069] The example text can be an example text that needs to be rewritten and entered by an expert.

[0070] It should be noted that inverted indexes originate from the practical application of finding records based on attribute values. Each entry in such an index table includes an attribute value and the addresses of the records that have that attribute value. In this example, the inverted index is applied by rewriting the phrase as the attribute value and retrieving the text as the addresses of the records that have that attribute value.

[0071] In some embodiments, the intervention platform provides an input interface for sample text and corresponding phrase rewriting example pairs. After inputting the sample text and corresponding phrase rewriting example pairs, the intervention platform provides a request interface for invoking a new service in the index service. Figure 1 The "+" symbol (with added parentheses) is used to establish and store the index relationship between the input example text and the corresponding phrase rewrite examples.

[0072] In some embodiments, the pre-built inverted index of text and phrases can be constructed using data from a web corpus. Taking the pre-built inverted index of text and phrases including the inverted index relationships in Table 1 such as “This dish tastes amazing and the chef really has something,” “He scored three goals in a game, and he really has something,” and “This painter used two brushes intotal,” and using the example rewritten phrase pair “two brushes-something” as an example, and taking “This dish tastes amazing and the chef really has something” as an example, based on the example rewritten phrase “two brushes” in the example rewritten phrase pair, “He scored three goals in a game, and he really has something” can be recalled in the above inverted index.

[0073] Specifically, the establishment of the inverted index described above can be performed according to the context semantics of the phrase in the text. Taking the example of the inverted index described above, since the context semantics of the example paraphrase phrase in “He scored three goals in a game, really two brushes” is the same as that of the example paraphrase phrase in the example text (This dish is super delicious, the chef really has two brushes), for the text “He scored three goals in a game, really two brushes”, it is also applicable to the same paraphrase for “two brushes” in the example text. Therefore, “He scored three goals in a game, really two brushes” can be used as a recall text; since the context semantics of the example paraphrase phrase in “This painter used a total of two brushes” is not the same as that of the example paraphrase phrase in the example text (This dish is super delicious, the chef really has two brushes), it is not applicable to the same paraphrase for “two brushes” in the example text, therefore, it cannot be used as a recall text.

[0074] In the above manner, by inputting the example text and the phrase paraphrase example pair by the expert, the recall text with the same context semantics of the example paraphrase phrase in the example text is recalled in the pre-constructed inverted index of the text and the phrase, and the index relationship of the recall text is established, thereby improving the generalization of the index database, and further improving the generalization of the input text paraphrase.

[0075] In some embodiments, the index relationship can be generated by a vector representation. For example, Figure 2 The step S202 shown can be implemented by determining a first vector representation of the target example paraphrase phrase in the target example text, the first vector representation being used to represent the context semantic information of the target example paraphrase phrase in the target example text; and generating an index relationship according to the first vector representation and the target phrase paraphrase example pair.

[0076] In some embodiments, the first vector representation of the target example paraphrase phrase in the target example text can be determined by a pre-trained BERT model. Referring to Figure 3 , Figure 3 “this dish is super delicious, the chef really has two brushes” in the example text, Figure 3 “two brushes” in the example paraphrase phrase, Figure 3 “intervention word” in the example replacement phrase, by encoding “two brushes” by the pre-trained model, the obtained vector (i.e. the first vector representation) [0.01, 0.02, -0.03, …, 0.05, 0.37] is used as the key in the index relationship, and “two brushes” and “intervention word” form a mapping relationship as the value in the index relationship, and the generated index relationship is stored in the vector index.

[0077] In some embodiments, the first vector representation can be determined according to the token vector corresponding to each word in the target example rewriting phrase output by the last layer of the pre-trained BERT model. For example, referring to Figure 4 , Figure 4 is a structure of a BERT model, which includes 12 layers of encoders, each of which is configured to encode an input of the layer of encoder to obtain a token vector, Figure 4 In the example, the input character includes 9 characters, and the last layer outputs a token vector corresponding to each character. The average vector of the token vector corresponding to each word (including "two", "put", "brush", and "child") in the target example rewriting phrase output by the last layer can be used as the corresponding first vector representation.

[0078] It should be noted that, Figure 4 In the example, the input of the BERT model is only a part of the target example text. In actual application, the entire target example text can also be used as the input of the BERT model to obtain the first vector representation.

[0079] In the above manner, the key part of the index relationship is represented by a vector, which can facilitate subsequent rewriting of the input text based on the index database.

[0080] In some embodiments, the text processing method can further include: in response to an update request for the index database, updating the index relationship in the index database, wherein the update request includes one of a deletion request and a modification request.

[0081] In the embodiment of Figure 2 , it can be understood that the index relationship is added in the index database, which can be understood as an update mode of the index database. In addition to the mode of adding the index relationship, the intervention side can also provide other services for the stored index relationship in the index database to update the stored index relationship itself.

[0082] For example, the update request can be implemented through the index service shown in Figure 1 , and the corresponding service is called to generate the corresponding situation.

[0083] The update request can carry an identifier of the index relationship that needs to be updated. According to the identifier, the corresponding index relationship can be found in the index database, and then the index relationship can be deleted or changed. For example, the change can be a change of the intervention word mentioned in the above embodiment.

[0084] By the above manner, the index relationship stored in the index database is updated in response to the update request corresponding to the different index relationship service, thereby improving the practicability of the whole text processing method.

[0085] In some embodiments, Figure 2 The step S204 shown in the method 200 can be implemented by the following manner: in response to the obtained input text, if the input text includes the to-be-rewritten phrase, determining whether the input text is the text to be rewritten according to the index relationship in the index database; and if the input text is determined to be the text to be rewritten, rewriting the to-be-rewritten phrase in the input text according to the index relationship corresponding to the input text.

[0086] It should be noted that if the input text input by the user does not include the to-be-rewritten phrase, it means that the to-be-rewritten phrase in the input text does not need to be rewritten. In the case that the input text includes the to-be-rewritten phrase, it is further determined that the input text is the text to be rewritten, and then the to-be-rewritten phrase in the input text is rewritten according to the index relationship corresponding to the input text, so as to avoid reducing the probability of text error rewriting.

[0087] For example, for the input text "this painter used two brushes in total", the meaning of the to-be-rewritten phrase "two brushes" in the input text represents the meaning of referring to the actual brush, and therefore the input text does not need to be rewritten.

[0088] For example, for the input text "he scored three goals in a game, really two brushes", the meaning of the to-be-rewritten phrase "two brushes" in the input text does not represent the meaning of referring to the actual brush, and therefore the input text needs to be rewritten.

[0089] In some embodiments, whether the input text includes the to-be-rewritten phrase can be determined by the following manner: performing word segmentation on the input text to obtain a plurality of phrase results; for each phrase result, matching a phrase corresponding to the phrase result in a pre-constructed phrase dictionary tree; and if the phrase corresponding to the phrase result is successfully matched, it is determined that the input text includes the to-be-rewritten phrase.

[0090] For example, for the input text "he scored three goals in a game, really two brushes", the phrase result obtained can include "two brushes".

[0091] It should be noted that the dictionary tree is also called a word search tree, which is a tree structure with high query efficiency. The dictionary tree is similar to the dictionary. When you want to check if a word is in the dictionary tree, first check if the first letter of the word is in the first layer of the dictionary. If not, it means that the dictionary tree does not have the word. If it is, find if the second letter of the word is in the child node of the letter. If not, there is no word. If so, continue to find in the same way. Therefore, by rewriting the phrase phrase to build a dictionary tree, the efficiency of determining whether the input text includes the to-be-rewritten phrase can be improved, and the real-time performance can be further improved.

[0092] In the above related embodiments, the index relationship is composed of the first vector representation and the target phrase rewriting example. The first vector representation is used to represent the context semantic information of the target example rewriting phrase in the target example text. Therefore, whether the input text is a text that needs to be rewritten can be determined according to whether the context semantic information of the to-be-rewritten phrase in the input text matches the first vector representation.

[0093] For example, the second vector representation of the to-be-rewritten phrase in the input text is obtained, and the second vector representation is used to represent the context semantic information of the to-be-rewritten phrase in the input text. The target vector representation closest to the second vector representation in the index database is found according to the second vector representation. In the case where the distance between the target vector representation and the second vector representation is less than a preset distance threshold, it is determined that the input text is a text that needs to be rewritten.

[0094] It should be noted that the first vector representation closest to the second vector representation in the index database is the target vector representation.

[0095] The determination manner of the second vector representation is similar to that of the first vector representation. For details, refer to the related embodiments described above, which will not be repeated here.

[0096] The preset distance threshold can be set according to actual conditions, which will not be limited in this embodiment.

[0097] In this embodiment, the data structure of the index database can be a graph structure, which can be a HNSW (Hierarchical Navigable Small World, hierarchical navigable small world) graph structure. For specific search algorithms, refer to related technologies, which will not be repeated here. In the case where the data structure of the index database is a HNSW graph structure, the target vector representation closest to the second vector representation in the index database can be found by using a naive search algorithm. In this way, brute force search can be avoided.

[0098] The following input text is used as an example to illustrate the text rewriting:

[0099] Input text 1: This dish tastes great, the chef really has two brushes.

[0100] Input text 2: He writes code very 6, really has two brushes.

[0101] Input text 3: The painter used a total of two brushes.

[0102] Input text 4: This game is not interesting, the players are all brushes.

[0103] Since there is a phrase of "two brushes" in the pre-built phrase dictionary tree, and there is no phrase of "brush", the input text 4 can be filtered, and no rewriting processing is performed on the input text 4, thereby avoiding incorrect rewriting;

[0104] The BERT model is used to perform vector encoding on the input text 1, the input text 2 and the input text 3 to obtain respective corresponding second vector representations:

[0105] The second vector representation corresponding to the input text 1: [0.01, 0.02, -0.03,..., 0.05, 0.37].

[0106] The second vector representation corresponding to the input text 2: [0.09, 0.04, -0.01,..., 0.17, 0.07].

[0107] The second vector representation corresponding to the input text 3: [0.06, 0.12, -0.93,..., 0.85, 0.17].

[0108] According to the index relationship in the index database, the naive search algorithm is used to find the target vector representation closest to the second vector representation of the input text 1, the input text 2 and the input text 3, respectively, and then the distance between the second vector representation of the input text 1 and the target vector representation corresponding thereto, the distance between the second vector representation of the input text 2 and the target vector representation corresponding thereto, and the distance between the second vector representation of the input text 3 and the target vector representation corresponding thereto are obtained:

[0109] The distance between the second vector representation of the input text 1 and the target vector representation corresponding thereto: 0.

[0110] The distance between the second vector representation of the input text 2 and the target vector representation corresponding thereto: 20.

[0111] The distance between the second vector representation of the input text 3 and the target vector representation corresponding thereto: 200.

[0112] Since the preset distance threshold is 50, the input text 3 does not need to be rewritten, and the input text 1 and the input text 2 are rewritten, and then the text is obtained:

[0113] The rewritten text corresponding to the input text 1: This dish tastes great, the chef really has [intervention word].

[0114] The rewritten text corresponding to the input text 2: He codes very 6, really has [intervention word].

[0115] The intervention word can refer to the related embodiments described above, and the present embodiment is not limited herein. Figure 5 is a block diagram of a text processing device according to an example embodiment of the present disclosure, referring to Figure 5 , the text processing device 500 includes:

[0116] The first acquisition module 501 is configured to acquire a target example text to be rewritten and a target phrase rewriting example pair corresponding to the target example text, wherein the target phrase rewriting example pair includes a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase.

[0117] The generation module 502 is configured to generate an index relationship according to the target example text and the target phrase rewriting example pair.

[0118] The storage module 503 is configured to store the index relationship to an index database.

[0119] The rewriting module 504 is configured to perform text rewriting on the acquired input text according to the index database.

[0120] Optionally, the first acquisition module 501 includes:

[0121] The first acquisition sub-module is configured to acquire an input example text to be rewritten and a phrase rewriting example pair corresponding to the example text, wherein the phrase rewriting example pair includes an example rewriting phrase and an example replacement phrase corresponding to the example rewriting phrase.

[0122] The recall sub-module is configured to recall a recall text corresponding to the example rewriting phrase pair according to the example rewriting phrase in the phrase rewriting example pair in a pre-constructed inverted index of text and phrase.

[0123] The first determination sub-module is configured to determine the recall text and the example text as the target example text, and determine the phrase rewriting example pair as the target phrase rewriting example pair.

[0124] Optionally, the generation module 502 includes:

[0125] a second determining sub-module, configured to determine a first vector representation of the target example paraphrase in the target example text, the first vector representation being used to represent context semantic information of the target example paraphrase in the target example text;

[0126] a generating sub-module, configured to generate an index relationship according to the first vector representation and the target paraphrase example pair.

[0127] Optionally, the apparatus 500 further includes:

[0128] a responding module, configured to update the index relationship in the index database in response to an update request for the index database, wherein the update request includes one of a deletion request and a modification request.

[0129] Optionally, the paraphrasing module 504 includes:

[0130] a responding sub-module, configured to respond to the obtained input text, and determine whether the input text is a text that needs to be paraphrased according to the index relationship in the index database, in a case where the input text includes a to-be-paraphrased phrase.

[0131] a paraphrasing sub-module, configured to perform paraphrasing processing on the to-be-paraphrased phrase in the input text according to the index relationship corresponding to the input text, in a case where it is determined that the input text is a text that needs to be paraphrased.

[0132] Optionally, the apparatus 500 further includes:

[0133] a word segmentation module, configured to perform word segmentation on the input text to obtain a plurality of phrase results;

[0134] a matching module, configured to, for each of the phrase results, match a phrase that matches the phrase result in a pre-constructed phrase dictionary tree, the phrase dictionary tree being constructed by using the target example paraphrase;

[0135] a first determining module, configured to determine that the input text includes the to-be-paraphrased phrase, in a case where a phrase corresponding to the phrase result is successfully matched.

[0136] Optionally, the index relationship is composed of a first vector representation and the target paraphrase example pair, the first vector representation being used to represent context semantic information of the target example paraphrase in the target example text, and the paraphrasing sub-module includes:

[0137] an obtaining unit, configured to obtain a second vector representation of the to-be-paraphrased phrase in the input text, the second vector representation being used to represent context semantic information of the to-be-paraphrased phrase in the input text;

[0138] a searching unit configured to search, according to the second vector representation, a target vector representation closest to the second vector representation in the index database;

[0139] a determining unit configured to determine that the input text is text that needs to be rewritten in a case that the distance between the target vector representation and the second vector representation is less than a preset distance threshold.

[0140] Optionally, a data structure of the index database is a graph structure, and the searching unit specifically searches, according to the second vector representation, a target vector representation closest to the second vector representation in the index database by using a naive searching algorithm.

[0141] Reference will be made to the following description Figure 6 , which shows a structural schematic diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure can include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Personal Computers), PMPs (Portable Multimedia Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and the like, as well as fixed terminals such as digital TVs, desktop computers, and the like. Figure 6 The electronic device shown is only an example, and should not bring any limitation to the functions and use range of the embodiments of the present disclosure.

[0142] As shown in Figure 6 , the electronic device 600 can include a processing device (such as a central processor, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or programs loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0143] Generally, the following devices can be connected to the I / O interface 605: input devices 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, and the like; output devices 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, and the like; storage devices 608 including, for example, a magnetic tape, a hard disk, and the like; and communication devices 609. The communication devices 609 can allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6The electronic device 600 is shown with various elements, but it is understood that not all of these elements are required for implementation or possession. More or less elements can alternatively be implemented or possessed.

[0144] In particular, in accordance with embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program comprising program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are performed.

[0145] It is noted that the computer-readable medium described above in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium, for example, can be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination thereof. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program used by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave in a propagated data signal, in which the computer-readable program code is carried. Such a propagated data signal can take a variety of forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium that is not a computer-readable storage medium and that can be used to carry or store program code used by or in connection with an instruction execution system, apparatus, or device. Program code contained in the computer-readable medium can be transmitted using any suitable medium, including but not limited to wire, cable, optical fiber, RF (radio frequency), etc., or any suitable combination thereof.

[0146] In some embodiments, the electronic device can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communications (e.g., a communications network) of any form or medium, such as the Internet. Examples of communications networks include local area networks ("LANs"), wide area networks ("WANs"), internetworks (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.

[0147] The computer readable medium described above can be included in the electronic device described above; or can exist separately from the electronic device and be not assembled into the electronic device.

[0148] The computer readable medium described above carries one or more programs, which, when executed by the electronic device, cause the electronic device to: acquire a target example text to be rewritten and a target phrase rewriting example pair corresponding to the target example text, the target phrase rewriting example pair including a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase; generate an index relationship according to the target example text and the target phrase rewriting example pair; store the index relationship to an index database; and perform text rewriting on an input text acquired according to the index relationship in the index database.

[0149] Computer program code for carrying out operations of the present disclosure can be written in any one or combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network ("LAN") or a wide area network ("WAN"), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0150] The computer program product of the first aspect can include one or more non-transitory computer-readable media storing instructions that, when executed, cause one or more processors to perform the operations of the first aspect. The one or more non-transitory computer-readable media can include, for example, Blu-ray discs, DVDs, CD-ROMs, flash memory, volatile memory, non-volatile memory, or a suitable combination of different computer-readable media.

[0151] The modules involved in the embodiments of the present disclosure can be implemented in the form of software or in the form of hardware. Among them, the name of the module does not constitute a limitation to the module itself in some cases. For example, the first obtaining module can also be described as "a module that obtains the target example text that needs to be rewritten and the target phrase rewriting example pair corresponding to the target example text".

[0152] The functions described in the foregoing description can be implemented, at least in part, by one or more hardware logic components. For example, and without limitation, example types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Application-specific Integrated Circuits (ASICs), Application-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.

[0153] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more of: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0154] According to one or more embodiments of the present disclosure, example 1 provides a text processing method, comprising:

[0155] obtaining a target example text requiring rewriting and a target phrase rewriting example pair corresponding to the target example text, the target phrase rewriting example pair comprising a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase;

[0156] generating an index relationship according to the target example text and the target phrase rewriting example pair;

[0157] storing the index relationship to an index database;

[0158] performing text rewriting on an input text obtained according to the index relationship in the index database.

[0159] According to one or more embodiments of the present disclosure, example 2 provides the method of example 1, wherein the obtaining a target example text requiring rewriting and a target phrase rewriting example pair corresponding to the target example text comprises:

[0160] obtaining an input example text requiring rewriting and a phrase rewriting example pair corresponding to the example text, the phrase rewriting example pair comprising an example rewriting phrase and an example replacement phrase corresponding to the example rewriting phrase;

[0161] recalling a recall text corresponding to the example rewriting phrase pair in a pre-built inverted index of text and phrase according to the example rewriting phrase in the phrase rewriting example pair;

[0162] determining the recall text and the example text as the target example text, and determining the phrase rewriting example pair as the target phrase rewriting example pair.

[0163] According to one or more embodiments of the present disclosure, example 3 provides the method of example 1, wherein the generating an index relationship according to the target example text and the target phrase rewriting example pair comprises:

[0164] determining a first vector representation of the target example rewriting phrase in the target example text, the first vector representation being used to represent context semantic information of the target example rewriting phrase in the target example text;

[0165] generating an index relationship according to the first vector representation and the target phrase rewriting example pair.

[0166] According to one or more embodiments of the present disclosure, example 4 provides the method of example 1, wherein the method further comprises:

[0167] updating, in response to an update request for the index database, an index relationship in the index database, wherein the update request comprises one of a deletion request and a modification request.

[0168] According to one or more embodiments of the present disclosure, example 5 provides the method of any one of examples 1-4, wherein the text rewriting of the obtained input text according to the index relationship in the index database comprises:

[0169] in response to the obtained input text, determining, in a case that the input text includes a to-be-rewritten phrase, whether the input text is text that needs to be rewritten according to the index relationship in the index database;

[0170] in a case that the input text is determined to be text that needs to be rewritten, rewriting the to-be-rewritten phrase in the input text according to the index relationship corresponding to the input text.

[0171] According to one or more embodiments of the present disclosure, example 6 provides the method of example 5, wherein the method further comprises:

[0172] segmenting the input text to obtain a plurality of phrase results;

[0173] for each of the phrase results, matching a phrase matching the phrase result in a pre-constructed phrase dictionary tree, the phrase dictionary tree being constructed by the target example rewritten phrase;

[0174] in a case that a phrase corresponding to the phrase result is successfully matched, determining that the input text includes the to-be-rewritten phrase.

[0175] According to one or more embodiments of the present disclosure, example 7 provides the method of example 5, wherein the index relationship is composed of a first vector representation and the target phrase rewritten example, the first vector representation being used to represent context semantic information of the target example rewritten phrase in the target example text, and the determining, according to the index relationship in the index database, whether the input text is text that needs to be rewritten comprises:

[0176] obtaining a second vector representation of the to-be-rewritten phrase in the input text, the second vector representation being used to represent context semantic information of the to-be-rewritten phrase in the input text;

[0177] finding, according to the second vector representation, a target vector representation closest to the second vector representation in the index database;

[0178] in a case that a distance between the target vector representation and the second vector representation is less than a preset distance threshold, determining that the input text is text that needs to be rewritten.

[0179] According to one or more embodiments of the present disclosure, example 8 provides the method of example 7, wherein the data structure of the index database is a graph structure, and the finding, according to the second vector representation, a target vector representation closest to the second vector representation in the index database comprises:

[0180] According to the second vector representation, employing a naive search algorithm to find, in the index database, a target vector representation closest to the second vector representation.

[0181] According to one or more embodiments of the present disclosure, example 9 provides a text processing apparatus, comprising:

[0182] a first obtaining module configured to obtain a target example text to be rewritten and a target phrase rewriting example pair corresponding to the target example text, the target phrase rewriting example pair comprising a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase;

[0183] a generating module configured to generate an index relationship according to the target example text and the target phrase rewriting example pair;

[0184] a storing module configured to store the index relationship to an index database;

[0185] a rewriting module configured to perform text rewriting on an obtained input text according to the index database.

[0186] According to one or more embodiments of the present disclosure, example 10 provides a computer readable medium having stored thereon a computer program, which, when executed by a processing apparatus, implements the steps of the method of any one of examples 1-8.

[0187] According to one or more embodiments of the present disclosure, example 11 provides an electronic device, comprising:

[0188] a storage device having stored thereon a computer program;

[0189] a processing apparatus configured to execute the computer program in the storage device to implement the steps of the method of any one of examples 1-8.

[0190] According to one or more embodiments of the present disclosure, example 12 provides a text processing system, comprising:

[0191] an index database;

[0192] an index server;

[0193] The intervention platform is configured to obtain a target example text requiring rewriting and a target phrase rewriting example pair corresponding to the target example text, the target phrase rewriting example pair comprising a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase;

[0194] The index server is configured to obtain the target example text and the target phrase rewriting example pair from the intervention platform, generate an index relationship according to the obtained target example text and the target phrase rewriting example pair, and store the index relationship in the index database; the index server is further configured to perform text rewriting on the obtained input text according to the index relationship in the index database.

[0195] According to one or more embodiments of the present disclosure, example 13 provides the system of example 12, further comprising:

[0196] A corpus database configured to store a pre-constructed inverted index of text and phrases;

[0197] The intervention platform is further configured to obtain an input example text requiring rewriting and a phrase rewriting example pair corresponding to the example text, recall a recall text corresponding to the example rewriting phrase pair in the pre-constructed inverted index of text and phrases in the corpus database, determine the recall text and the example text as the target example text, and determine the phrase rewriting example pair as the target phrase rewriting example pair, the phrase rewriting example pair comprising the example rewriting phrase and the example replacement phrase corresponding to the example rewriting phrase.

[0198] According to one or more embodiments of the present disclosure, example 14 provides the system of example 12, further comprising:

[0199] An intervention database;

[0200] The intervention platform is further configured to store the target example text requiring rewriting and the target phrase rewriting example pair corresponding to the target example text in the intervention database, and generate an index establishment request and send the index establishment request to the index server;

[0201] The index server is further configured to obtain the target example text and the target phrase rewriting example pair corresponding to the target example text from the intervention database in response to the index processing request.

[0202] According to one or more embodiments of the present disclosure, example 15 provides the system of example 12, further comprising:

[0203] An application end configured to send the input text to the index server.

[0204] The above description merely illustrates the preferred embodiment of the disclosure and a principle of applied technologies. It should be understood by those skilled in the art that the disclosed range of the disclosure is not limited to the technical solutions formed by the specific combinations of the technical features described above, and should also cover other technical solutions formed by the combinations of the technical features described above or their equivalent features without departing from the disclosed concept. For example, the technical solutions formed by the mutual replacement of the above-described features and the technical features with similar functions disclosed in the disclosure (but not limited to) can be formed.

[0205] Furthermore, although operations are depicted in a particular, sequential order, this should not be understood as requiring or implying that the operations are performed in the order illustrated or sequentially. In certain circumstances, multitasking and parallel processing can be advantageous. Likewise, although specific implementation details are contained in the above discussion, these should not be construed as limiting the scope of the disclosure. Certain features described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable sub-combination.

[0206] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely illustrative of the example forms of implementing the claims. As to the means for performing the operations of the apparatus in the above-described embodiments, the specific manner in which the various modules perform the operations has been described in detail in the embodiments related to the method, and will not be described here.

Claims

1. A text processing method characterized by, The method comprises: obtaining a target example text needing rewriting and a target phrase rewriting example pair corresponding to the target example text, the target phrase rewriting example pair comprising a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase; generating an index relationship according to the target example text and the target phrase rewriting example pair; storing the index relationship to an index database; rewriting the input text according to the index relationship in the index database; the generating of the index relationship according to the target example text and the target phrase rewriting example pair comprises: determining a first vector representation of the target example rewriting phrase in the target example text, the first vector representation being used to represent the context semantic information of the target example rewriting phrase in the target example text; and generating the index relationship according to the first vector representation and the target phrase rewriting example pair; the rewriting of the input text according to the index relationship in the index database comprises: in response to the input text, if the input text comprises a rewriting phrase to be rewritten, obtaining a second vector representation of the rewriting phrase to be rewritten in the input text, the second vector representation being used to represent the context semantic information of the rewriting phrase to be rewritten in the input text; searching for a target vector representation closest to the second vector representation in the index database according to the second vector representation; if the distance between the target vector representation and the second vector representation is less than a preset distance threshold, determining that the input text is a text needing rewriting; and rewriting the rewriting phrase to be rewritten in the input text according to the index relationship corresponding to the input text.

2. The method of claim 1, wherein, The method further comprises: obtaining an input example text needing rewriting and a phrase rewriting example pair corresponding to the example text, the phrase rewriting example pair comprising an example rewriting phrase and an example replacement phrase corresponding to the example rewriting phrase; recalling a recall text corresponding to the example rewriting phrase pair in a pre-constructed inverted index of text and phrase according to the example rewriting phrase in the phrase rewriting example pair; determining the recall text and the example text as the target example text, and determining the phrase rewriting example pair as the target phrase rewriting example pair.

3. The method of claim 1, wherein, The method further comprises: updating the index relationship in the index database in response to an update request for the index database, wherein the update request comprises one of a deletion request and a modification request.

4. The method of claim 1, wherein, The method further comprises: performing word segmentation on the input text to obtain a plurality of phrase results; for each phrase result, matching a phrase matching the phrase result in a pre-constructed phrase dictionary tree, the phrase dictionary tree being constructed by the target example rewriting phrase; if a phrase corresponding to the phrase result is successfully matched, it is determined that the input text comprises the rewriting phrase to be rewritten.

5. The method of claim 1, wherein, The data structure of the index database is a graph structure, and the method of searching for a target vector representation closest to the second vector representation in the index database according to the second vector representation comprises: According to the second vector representation, a naive search algorithm is used to search for a target vector representation closest to the second vector representation in the index database.

6. A text processing apparatus characterized by comprising: Comprise: A first acquisition module is configured to acquire a target example text to be rewritten and a target phrase rewriting example pair corresponding to the target example text, wherein the target phrase rewriting example pair comprises a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase; A generation module is configured to generate an index relationship according to the target example text and the target phrase rewriting example pair; A storage module is configured to store the index relationship in an index database; A rewriting module is configured to perform text rewriting on an acquired input text according to the index database; The generation module comprises: A second determination submodule is configured to determine a first vector representation of the target example rewriting phrase in the target example text, wherein the first vector representation is used to represent context semantic information of the target example rewriting phrase in the target example text; A generation submodule is configured to generate an index relationship according to the first vector representation and the target phrase rewriting example pair; The rewriting module is further configured to, in response to the acquired input text, in the case that the input text includes a to-be-rewritten phrase, acquire a second vector representation of the to-be-rewritten phrase in the input text, wherein the second vector representation is used to represent context semantic information of the to-be-rewritten phrase in the input text; search for a target vector representation closest to the second vector representation in the index database according to the second vector representation; in the case that the distance between the target vector representation and the second vector representation is less than a preset distance threshold, determine that the input text is a text to be rewritten; and perform rewriting processing on the to-be-rewritten phrase in the input text according to the index relationship corresponding to the input text.

7. A computer readable medium having stored thereon a computer program, characterized in that The program is executed by the processing device to implement the steps of the method of any one of claims 1-5.

8. An electronic device, comprising: Comprise: A storage device having a computer program stored thereon; A processing device configured to execute the computer program in the storage device to implement the steps of the method of any one of claims 1-5.

9. A text processing system, characterized by Comprise: An index database; An index server; An intervention platform configured to acquire a target example text to be rewritten and a target phrase rewriting example pair corresponding to the target example text, wherein the target phrase rewriting example pair comprises a target example rewriting phrase and a target example replacement phrase corresponding to the target example rewriting phrase; The index server is configured to acquire the target example text and the target phrase rewriting example pair from the intervention platform, determine a first vector representation of the target example rewriting phrase in the target example text, generate an index relationship according to the first vector representation and the target phrase rewriting example pair, and store the index relationship into the index database, wherein the first vector representation is used to represent context semantic information of the target example rewriting phrase in the target example text. The index server is further configured to, in response to the acquired input text, acquire a second vector representation of a rewriting-to-be phrase in the input text, when the input text includes the rewriting-to-be phrase, wherein the second vector representation is used to represent context semantic information of the rewriting-to-be phrase in the input text. According to the second vector representation, find a target vector representation closest to the second vector representation in the index database; when a distance between the target vector representation and the second vector representation is less than a preset distance threshold, determine that the input text is a text needing rewriting; and perform rewriting processing on the rewriting-to-be phrase in the input text according to the index relationship corresponding to the input text.

10. The system of claim 9, wherein, Further comprising: a corpus database configured to store a pre-constructed inverted index of text and phrases; The intervention platform is further configured to acquire an input example text needing rewriting and a phrase rewriting example pair corresponding to the example text, recall a recall text corresponding to the example rewriting phrase pair in the pre-constructed inverted index of text and phrases in the corpus database, determine the recall text and the example text as the target example text, and determine the phrase rewriting example pair as the target phrase rewriting example pair, wherein the phrase rewriting example pair includes the example rewriting phrase and an example replacement phrase corresponding to the example rewriting phrase.

11. The system of claim 9, wherein, Further comprising: an intervention database; The intervention platform is further configured to store the acquired target example text needing rewriting and a target phrase rewriting example pair corresponding to the target example text into the intervention database, and generate an index establishment request and send the index establishment request to the index server; The index server is further configured to, in response to the index processing request, acquire the target example text and the target phrase rewriting example pair corresponding to the target example text from the intervention database.

12. The system of claim 9, wherein, Further comprising: an application end configured to send the input text to the index server.

Citation Information

Patent Citations

  • Text processing method and device, text processing model training method and device and storage medium

    CN112528621A

  • Data processing method and device, electronic equipment and storage medium

    CN113792135A