A method, device, equipment and storage medium for detecting watermarks in text
By extracting emotional feature masks and obtaining ciphertext watermarks in digital text, the problems of insufficient security, transparency and robustness of text watermark detection in the prior art are solved, and more efficient text watermark detection and protection are achieved.
Patent Information
- Application Number
- CN202011497653.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-17
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2040-12-17
AI Technical Summary
The prior art has shortcomings in security, transparency and robustness in the detection of ciphertext watermarks of digital texts, making it difficult to achieve a good balance in performance.
By extracting the emotional feature mask of the text to be processed and obtaining the ciphertext watermark when it is determined that the text has a watermark identification, the degree of matching between the emotional feature mask and the ciphertext watermark is determined to achieve ciphertext watermark detection of the text.
Improves the security, transparency and robustness of text watermarks, ensuring that text watermarks can still be effectively detected and protected when subject to certain interference or attacks.
Smart Images

Figure CN114648435B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of copyright protection, and relates to but is not limited to a method, device, equipment and storage medium for detecting watermarks in text. Background Art
[0002] Digital watermarking technology in related technologies is a computer hiding technology based on content and non-cryptographic mechanism, which directly embeds some identification information into digital carriers, protecting information security without affecting the use value of the original carrier. Text watermarking is a research branch of digital watermarking. Based on the characteristics of text watermarking technology, the following are three related technologies of text watermarking and the existing technical problems:
[0003] 1. Watermark embedding and detection technology based on text format is to convert text bitmaps into images and directly apply mature watermark technology in the image field to text watermarks. At the same time, the style features of the text, such as paragraph spacing, character spacing, etc., are used to control the display form of the digital watermark. Problems with this technology: Style features cannot detect whether the file has been tampered with, and the security performance is low.
[0004] Second, the watermark embedding and detection technology based on text data will insert subtle spelling, syntax, punctuation and even content errors into the text to embed the watermark. The problems with this technology are: it will change the original file content, which may cause changes in the semantics of the text content, destroy the transparency principle of the watermark, and cannot generate a robust text watermark. When the data is slightly damaged, different text watermarks may be generated, affecting the results of watermark detection, and the robustness is not strong; the embedded watermark is highly undetectable because it has the same text characteristics as the original carrier, and illegal interceptors cannot determine whether there is hidden information.
[0005] 3. Watermark embedding and detection technology based on text content will analyze the text semantics according to the text content, and combine statistical methods or syntactic methods to calculate the text content features, and write simulation functions to generate secret information throughout the text to achieve watermark embedding. This technology hides the watermark in the statistical laws or grammatical codes of the text. Problems with this technology: The content feature volume is large, which will bring more redundant feature data to the original carrier.
[0006] In summary, the existing ciphertext watermark detection technologies for digital texts have their own shortcomings in terms of security, transparency, robustness, etc., or cannot achieve a good balance in performance. Summary of the invention
[0007] In view of this, the present application provides a method, device, equipment and storage medium for detecting watermarks in text to solve at least one problem existing in the prior art, which at least solves the problem that the prior art has shortcomings in security, transparency, robustness, etc., or cannot achieve a good balance in performance.
[0008] The technical solution of this application is implemented as follows:
[0009] In a first aspect, the present application provides a method for detecting watermarks in text, comprising: extracting a sentiment feature mask of the text to be processed; when it is determined that a watermark mark exists in the text to be processed, obtaining a ciphertext watermark of the text to be processed, wherein the ciphertext watermark is formed by embedding the sentiment feature mask into the text to be processed according to a conversion rule; determining a matching degree between the sentiment feature mask and the ciphertext watermark; and performing ciphertext watermark detection on the text to be processed according to the matching degree.
[0010] In a second aspect, the present application provides a device for detecting watermarks in text, the device comprising: an extraction module, used to extract a sentiment feature mask of the text to be processed; an acquisition module, used to acquire a ciphertext watermark of the text to be processed when it is determined that a watermark mark exists in the text to be processed, wherein the ciphertext watermark is formed by embedding the sentiment feature mask into the text to be processed according to a conversion rule; a determination module, used to determine the degree of match between the sentiment feature mask and the ciphertext watermark; and a detection module, used to perform ciphertext watermark detection on the text to be processed based on the degree of match.
[0011] In a third aspect, the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the text watermark embedding and detection method of the above method is implemented.
[0012] In a fourth aspect, the present application provides a storage medium for detecting watermarks in text, which stores executable instructions for causing a processor to execute and implement the text watermark embedding and detection method of the above method.
[0013] The present application provides a method, device, equipment and storage medium for detecting watermarks in texts. First, the emotional feature mask of the text to be processed is extracted. Secondly, when it is determined that the text to be processed has a watermark mark, the ciphertext watermark is obtained, and then the matching degree between the emotional feature mask and the ciphertext watermark is determined. Finally, the ciphertext watermark detection is performed on the text to be processed according to the matching degree. In this way, firstly, the characteristics of the text to be processed are fully considered, the text emotional features that can characterize the text content are masked and implicitly embedded in the text, and the selected emotional features can well reflect the content tendency of the text and characterize the text content. Secondly, a watermark embedding method based on text emotional features is used. The text features after masking are small in size and low in calculation cost, which improves the processing efficiency and reduces the amount of redundant data carried. At the same time, the processing method of separating the text content from the text watermark ensures the transparency and security of the text watermark. Finally, the emotional feature mask and the ciphertext watermark are used to determine the matching degree to realize the ciphertext watermark detection of the text to be processed. Under the condition of a certain degree of interference or attack, the text watermark can still play a role, which improves the robustness of the text watermark. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 A schematic diagram of a process for detecting a watermark in a text provided in an embodiment of the present application;
[0015] Figure 2A A schematic diagram of an improved text sentiment model based on a long short-term memory network model provided in an embodiment of the present application;
[0016] Figure 2B A schematic diagram of a process for detecting a watermark in a text provided in an embodiment of the present application;
[0017] Figure 3 A schematic diagram of a process for detecting a watermark in a text provided in an embodiment of the present application;
[0018] Figure 4 A schematic diagram of a process for detecting a watermark in a text provided in an embodiment of the present application;
[0019] Figure 5 A schematic diagram of the structure of a device for detecting watermarks in text provided in an embodiment of the present application;
[0020] Figure 6 A hardware entity diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0022] It should be understood that some embodiments described herein are only used to explain the technical solution of the present application, and are not used to limit the technical scope of the present application.
[0023] The present application provides a method for detecting a watermark in a text, such as Figure 1 As shown, the method includes:
[0024] Step S101, extracting the emotional feature mask of the text to be processed;
[0025] Sentimental features refer to features that can reflect the content tendency of a text. Selecting sentimental features can represent the content of a text. The mask can be a string of binary codes. Here, the sentimental feature mask can be a string of binary codes that can represent the content tendency of a text.
[0026] Step S102: when it is determined that the text to be processed has a watermark mark, obtaining a ciphertext watermark of the text to be processed, wherein the ciphertext watermark is formed by embedding the emotion feature mask into the text to be processed according to a conversion rule;
[0027] Here, the watermark identifier can be embedded in the text according to actual needs, and is used to distinguish between text with embedded watermarks and text without embedded watermarks. For example, the content of the watermark identifier can be the logo information of the creator and owner of the text. When it is determined that the text to be processed has a watermark identifier, it is determined that the text to be processed is a file that has been embedded with a watermark. Files embedded with watermarks can be embedded with three types of watermarks: the first type is to embed a plain text watermark, the main purpose of which is to clarify copyright and prevent illegal use. The plain text watermark content can be customized as needed; the second type is to embed a cipher text watermark, which is used to prevent the file from being destroyed or tampered with; the third type is to embed a watermark identifier to protect the rights and interests of the legal owner of the text.
[0028] The ciphertext watermark is formed by embedding the emotional feature mask into the text according to the conversion rule. Here, the conversion rule can be a Unicode conversion rule. Because computers can only process numbers, if you want to process text, you must first convert the text into numbers before processing. Unicode is a character encoding scheme developed by an international organization that can accommodate all the text and symbols in the world.
[0029] Step S103, determining the matching degree between the emotion feature mask and the ciphertext watermark;
[0030] Because the ciphertext watermark is formed by embedding the emotional feature mask into the text to be processed according to the conversion rules, the matching value between the emotional feature mask and the ciphertext watermark can be calculated. The ciphertext watermark can be a different ciphertext watermark generated for the different contents of each page of text. When the text to be processed is a single page of text, the matching degree refers to a matching value; when the text to be processed is a multi-page text, the matching degree is a set of matching values, where the number of matching values in the set is the same as the number of pages of the text to be processed.
[0031] Step S104: perform ciphertext watermark detection on the text to be processed according to the matching degree.
[0032] According to the matching degree, it can be determined whether the text to be processed is the text that has completed the ciphertext watermark embedding or whether the data of the ciphertext watermark of the text to be processed is damaged or the content is tampered with during the transmission process.
[0033] In the embodiment of the present application, the emotional feature mask of the text to be processed is firstly extracted, and then the ciphertext watermark is obtained when it is determined that the text to be processed has a watermark mark, and then the matching degree between the emotional feature mask and the ciphertext watermark is determined, and finally the ciphertext watermark detection is performed on the text to be processed according to the matching degree. In this way, firstly, the characteristics of the text to be processed are fully considered, the text emotional features that can characterize the text content are masked and implicitly embedded in the text, and the selected emotional features can well reflect the content tendency of the text and characterize the text content. Secondly, a watermark embedding method based on text emotional features is used, and the text features after masking are small in size and low in calculation cost, which improves the processing efficiency and reduces the amount of redundant data carried. At the same time, the processing method of separating the text content from the text watermark ensures the transparency and security of the text watermark. Finally, the emotional feature mask and the ciphertext watermark are used to determine the matching degree to realize the ciphertext watermark detection of the text to be processed. Under the condition of a certain degree of interference or attack, the text watermark can still play a role, which improves the robustness of the text watermark.
[0034] Figure 2A A schematic diagram of an improved text sentiment model based on a long short-term memory network model provided in an embodiment of the present application is shown in FIG. Figure 2A As shown, it includes: word vector 201, sentiment vector 202, sentence sentiment vector 203, long short-term memory network (LSTM, Long Short-Term Memory) 204, normalization layer (Softmax) 205, fully connected layer (FC) 206 and sentiment feature (f) 207, where,
[0035] Word vector 201, through the text structured model to parse out each word in the sentence, and as word embedding input, the word embedding in a sentence can be represented as {w1,w2,…,w i}, one word corresponds to one of the word vectors.
[0036] Emotion vector 202, takes the emotional tendency information to be judged as input for emotion embedding, {v1,v2,…,v i} is the sentiment embedding corresponding to all words, v i ={p1,…,p M}, M is the number of sentiment polarities to be judged, usually 3, corresponding to the sentiment polarities {positive, negative, neutral}, p M is the probability corresponding to each sentiment polarity, the sum is 1;
[0037] The first feature vector w after connecting the word vector 201 and the sentiment vector 202 T v is input into the long short-term memory network (LSTM) to extract the current stage of each sentence and obtain the second feature vector.
[0038] The first feature vector w after connecting the word vector 201 and the sentiment vector 202 T v is normalized (Softmax) 205 to obtain the sentence sentiment vector 203, h = {h1, h2, ..., h i That is, the sentence sentiment of each sentence at the current stage is extracted using the following formula (1) to obtain the sentence sentiment vector 203.
[0039] h i =Softmax(w i T v i ) (1);
[0040] In the last layer of the long short-term memory network 204, the second feature vector of the last stage and the sentence sentiment vector 203 of the whole stage are combined, h = {h1, h2, ..., h i The output is linearly transformed through the fully connected layer FC so that its vector length is the same as the sentiment polarity to be judged.
[0041] A normalization (Softmax) layer 205 is used to take the most likely emotional feature as the output of the model, and the following formula (2) is used to represent the probability of the output belonging to each category.
[0042] f=[f1,f2,…,f M ] (2);
[0043] Among them, M is the number of sentiment polarities that need to be judged.
[0044] use Figure 2A The improved text sentiment model based on the long short-term memory network model shown is based on the target text represented by the fusion vector, which is input into the long short-term memory network model to determine the sentiment category of the target text.
[0045] Figure 2B A method for detecting watermarks in text provided in an embodiment of the present application is as follows: Figure 2B As shown, the method includes:
[0046] Step S201: using a long short-term memory network to convert the acquired first feature vector into a second feature vector, wherein the first feature vector includes a sample word vector and a sentiment tendency vector;
[0047] like Figure 2A As shown, each word in the sentence is converted into a corresponding word vector 201; the sentiment tendency information to be judged is converted into a corresponding sentiment tendency vector 202. Here, a large amount of sample words and sentiment tendency information are input. Sample words and sentiment tendency information can be obtained according to the actual needs of the text to be processed.
[0048] The text structured model is used to parse out each word in the sentence and use it as word input. The words in a sentence can be represented as {w1,w2,…,w i}, one word corresponds to one of the word vectors.
[0049] {v1,v2,…,v i} is the sentiment embedding corresponding to all words, v i ={p1,…,p M}, M is the number of sentiment polarities to be judged, for example, it can be 3, corresponding to the sentiment polarities {positive, negative, neutral}, p M is the probability corresponding to each sentiment polarity, and the sum is 1.
[0050] After connecting the word vector 201 and the sentiment vector 202, the first feature vector w is obtained T v.
[0051] Long Short-Term Memory (LSTM) is a time recurrent neural network designed to solve the long-term dependency problem of general recurrent neural networks (RNN). All RNNs have a chain form of repeated neural network modules. Due to its unique design structure, LSTM is suitable for processing and predicting important events with very long intervals and delays in time series. The word information of emotional tendency and the dynamically changing sentence emotional information are embedded in the training process of the LSTM network, so that the LSTM can select the most suitable emotional polarity at the moment through context information.
[0052] like Figure 2A As shown, the first feature vector w after connecting the word vector 201 and the sentiment vector 202 Tv is input into the long short-term memory network (LSTM) to extract the current stage of each sentence and obtain the second feature vector.
[0053] Step S202: using a normalization layer to normalize the first feature vector to obtain a sentence sentiment vector;
[0054] like Figure 2A As shown, the first eigenvector w T v is normalized (Softmax) 205 to obtain the sentence sentiment vector 203, h = {h1, h2, ..., h i That is, the sentence sentiment of each sentence at the current stage is extracted using the following formula (1) to obtain the sentence sentiment vector 203.
[0055] h i =Softmax(w i T v i ) (1).
[0056] Step S203: using a fully connected layer to perform a linear transformation on the second feature vector and the sentence sentiment vector to obtain a third feature vector, so that the number of dimensions of the third feature vector is the same as the number of sentiment polarities to be determined;
[0057] The fully connected layers (FC) act as a "classifier" in the entire network, that is, they integrate the highly abstract features after multiple convolutions. Here, the output of the last layer of the long short-term memory network is linearly transformed through the fully connected layer so that the number of dimensions of the second feature vector is the same as the number of emotional polarities to be judged.
[0058] like Figure 2A As shown, in the last layer of the long short-term memory network 204, the second feature vector of the last stage and the sentence sentiment vector 203 of the whole stage are combined, h = {h1, h2, ..., h i The output is linearly transformed through the fully connected layer FC so that its vector length is the same as the sentiment polarity to be judged.
[0059] Step S204: using a normalization layer to normalize the third feature vector to complete pre-training of the text sentiment model;
[0060] Here, the normalization (softmax) layer can be used to normalize the second feature vector to complete the pre-training of the text sentiment model. The softmax layer is generally the last layer of the classification network, which outputs a feature vector with the same length as the number of categories, and then outputs the probability that the vector connected by the word and the sentiment belongs to each category.
[0061] like Figure 2A As shown, a normalization (Softmax) layer 205 is used to take the most likely emotional feature as the output of the model, and the following formula (2) is used to represent the probability of the output belonging to each category.
[0062] f=[f1,f2,…,f M ] (2);
[0063] Among them, M is the number of sentiment polarities that need to be judged.
[0064] In this way, pre-training of the text sentiment model can be achieved.
[0065] Step S205, extracting the emotional features of the text to be processed by using the text emotional model;
[0066] Here, the pre-trained text sentiment model can be used to extract the sentiment features of the text to be processed.
[0067] Step S206: binarize the emotion feature to obtain the emotion feature mask;
[0068] Considering the high computational cost of feature data, the acquired text sentiment features are binarized to obtain a text sentiment feature mask that is easy to calculate.
[0069] Step S207: if it is determined that the text to be processed has a watermark mark, obtaining a ciphertext watermark of the text to be processed, wherein the ciphertext watermark is formed by embedding the emotion feature mask into the text to be processed according to a conversion rule;
[0070] Step S208, determining the matching degree between the emotion feature mask and the ciphertext watermark;
[0071] Step S209: perform ciphertext watermark detection on the text to be processed according to the matching degree.
[0072] In the embodiment of the present application, the text sentiment feature extraction method based on the long short-term memory network is combined with word embedding and sentiment embedding, and the improved long short-term memory network is used to perform fine-grained sentiment analysis to extract text sentiment features; the watermark embedding method based on text sentiment features masks the text sentiment features that can characterize the text content and implicitly embeds them into the text. In this way, the text sentiment model extraction accuracy is improved from the two aspects of word embedding and sentiment embedding, and the text sentiment features are extracted using the improved text sentiment model based on the long short-term memory network. Even if there are multiple sentiment tendencies in the text at the same time, the text sentiment model can extract the true sentiment features of the text, which improves the accuracy and robustness of the text watermark; using the watermark embedding method based on text sentiment features, the masked text features are small in size and low in computational cost, which improves processing efficiency and reduces the amount of redundant data carried. At the same time, the processing method of separating the text content from the text watermark ensures the transparency and security of the text watermark.
[0073] The present application provides a method for embedding a watermark into text without a watermark, the method comprising:
[0074] Step S211, obtaining the plaintext watermark of the text to be processed;
[0075] The main purpose of embedding a plain text watermark is to clarify copyright and prevent illegal use. The content of the plain text watermark can be customized according to actual needs.
[0076] Step S212: if it is determined that the text to be processed does not have a watermark mark, embed the plain text watermark in the text to be processed;
[0077] In this step, a watermark algorithm based on discrete wavelet transformation can be used to embed the plaintext watermark.
[0078] Step S213, converting the emotion feature mask into a first zero width control field according to a single code conversion rule;
[0079] Unicode, also known as the unified code or the universal code, is an industry standard in the field of computer science, including character sets, encoding schemes, etc. Unicode was created to address the limitations of traditional character encoding schemes. It sets a unified and unique binary code for each character in each language to meet the requirements of text conversion and processing across languages and platforms. Because computers can only process numbers, if you want to process text, you must first convert the text into numbers before processing it.
[0080] Unicode zero-width control fields are special Unicode fields. They are invisible and non-printable control fields that exist on the page and are mainly used to adjust the display format of characters. This method is simple to implement and consumes little time and space.
[0081] Here, because the emotion feature mask is composed of 0 and 1, the emotion feature mask is converted into the corresponding Unicode encoding to obtain the first zero-width control field.
[0082] Step S214, embedding the first zero-width control field into a first specific position of the text to be processed;
[0083] The first specific position may be the tail of each page of the text to be processed. Here, the first zero-width control field is embedded in the tail of each page of the text to be processed to form an invisible ciphertext watermark.
[0084] Step S215, obtaining the watermark identifier of the text to be processed;
[0085] The watermark flag content of the text to be processed can be the logo information of the creator and owner of the text, which is used to protect the rights and interests of the legal owner of the text.
[0086] Step S216, converting the watermark identifier into a second zero-width control field according to a single code conversion rule;
[0087] Step S217: embed the second zero-width control field into a second specific position of the text to be processed, and output the text embedded with the watermark.
[0088] The first specific position may be the head of each page of the text to be processed. Here, the second zero-width control field is embedded in the tail of each page of the text to be processed to form a watermark mark containing the identification information of the creator and owner of the text.
[0089] In the embodiment of the present application, the plain text watermark is firstly embedded into the text to be processed, the emotional feature mask is then embedded into the text to be processed as a cipher text watermark, and finally the watermark identifier is embedded into the text to be processed, so as to add a watermark to the text without a watermark. In this way, adding three types of watermarks with different functions to the text without watermarks can effectively protect the rights and interests of the legal owner of the text.
[0090] Figure 3 A method for detecting watermarks in text provided in an embodiment of the present application, wherein the text to be processed includes at least one page of text, and the matching degree is a set of matching values of the text to be processed, such as Figure 3 As shown, the method includes:
[0091] Step S301, extracting the emotional feature mask of the text to be processed;
[0092] Input the text of page i into the text sentiment model of step S403 to obtain the text sentiment feature f of page i i ;
[0093] Traverse all pages of the text to obtain the text sentiment features of the entire text. The following formula (3) represents the text sentiment feature set of the entire text.
[0094] F={f1,f2,…,f i ,…,f n} (3);
[0095] Where n represents the total number of pages of text.
[0096] Considering the high computational cost of feature data, the text sentiment features are binarized to obtain a text sentiment feature mask that is easy to calculate. The following formula (4) represents the text sentiment feature mask set of the entire text.
[0097] Mask={mask1,mask2,…,mask i ,…,mask n} (4);
[0098] Among them, mask i Represents the sentiment feature mask of the i-th page of text.
[0099] Step S302: when it is determined that the text to be processed has a watermark mark, obtaining a ciphertext watermark of the text to be processed, wherein the ciphertext watermark is formed by embedding the emotion feature mask into the text to be processed according to a conversion rule;
[0100] Step S303, using the square formula of the binary norm to determine the matching value of the sentiment feature mask of each page of the text to be processed and the ciphertext watermark of each page of the text to be processed, to obtain the matching value of each page of the text to be processed;
[0101] Calculate the sentiment feature mask of the text on page i i With ciphertext watermark mark i Match value match i , the following formula (5) is the formula for calculating the square of the second norm of the matching value.
[0102]
[0103] Among them, match i is the ciphertext watermark match value for the i-th page of text, match i The larger it is, the more similar the emotional characteristics reflected by the text content of page i are to the ciphertext watermark.
[0104] Step S304: determining the matching value of each page of the to-be-processed text as a matching value in the matching value set of the to-be-processed text;
[0105] Traverse all pages of the text to obtain the set of ciphertext watermark matching values for the entire text:
[0106] Match={match1,match2,…,match i ,…,match n}.
[0107] Step S305: When any matching value in the matching value set is greater than a first threshold, determining that the to-be-processed text is embedded with a ciphertext watermark;
[0108] Setting the match d is the first threshold, match d You can take the empirical value of 0.05;
[0109] When there is a match i ≥match d , that is, if the ciphertext watermark matching value of a certain page in the text is greater than the first threshold, it indicates that the text has been embedded with a ciphertext watermark. The number of pages of the text is looped, and the relationship between the ciphertext watermark matching value of each page and the watermark identification interference threshold is compared to determine whether the text is embedded with a ciphertext watermark.
[0110] When there is no match i ≥match d When , that is, the ciphertext watermark matching values of all pages in the text are less than the watermark interference threshold, it indicates that the text is not embedded with a text watermark. The watermark may be interfered by channel noise, resampling, lossy compression, etc. during transmission, and the watermark of the input text is incorrectly marked. It is necessary to re-embed the watermark in the processed text.
[0111] Step S306: When each matching value in the matching value set is greater than the second threshold, determine that the text to be processed passes the text watermark detection, wherein the second threshold is greater than the first threshold.
[0112] Setting the match t is the second threshold, match t You can take the experience value of 0.8;
[0113] When match i ≥match t When , that is, the ciphertext watermark matching values of all pages in the text are greater than the second threshold, it indicates that the text is securely transmitted, that is, the text has been embedded with a ciphertext watermark.
[0114] Step S307: if any matching value in the matching value set is less than the second threshold, determine that the text to be processed is a text that fails the ciphertext watermark detection;
[0115] When there is a matchi <match t When , that is, there is a page in the text whose ciphertext watermark matching value is less than the ciphertext watermark tampering threshold, indicating that the text may have been tampered with during transmission, and the text to be processed is determined to be the text that has not passed the ciphertext watermark detection.
[0116] Step S308: issuing a tampering warning for the text that fails the ciphertext watermark detection to indicate that there is a risk of tampering with the text to be processed.
[0117] In the embodiment of the present application, a multiple threshold screening mechanism is used. Under a certain degree of interference or attack, the text watermark model can correctly complete the watermark embedding or detection function, and can issue a tampering warning for texts with a tendency to be tampered. In this way, under a certain degree of interference or attack, the text watermark can still play a role, thereby improving the robustness of the text watermark.
[0118] Figure 4 A method for detecting watermarks in text provided in an embodiment of the present application is as follows: Figure 4 As shown, the method includes:
[0119] Step S401, input the text to be processed;
[0120] The text to be processed needs to have page number attributes, such as pdf, doc and other types of text;
[0121] Step S402: pre-training text sentiment model;
[0122] In order to improve the stability and efficiency of feature calculation, this step requires pre-training of the feature model. Considering the characteristics of text data, this step improves a text sentiment model based on the long short-term memory network model. The model design is as follows: Figure 2A shown.
[0123] Each word in the sentence is input as a word vector 201; the emotional tendency information to be judged is input as an emotional embedding vector 202; after connecting the word vector 201 and the emotional vector 202, the first feature vector w is obtained. T v; input the first eigenvector into the long short-term memory network to extract the sentiment feature and obtain the second eigenvector; normalize the first eigenvector to obtain the sentence sentiment vector 203; input the second eigenvector and the sentence sentiment vector into the fully connected layer for linear transformation to obtain the third eigenvector, so that the number of dimensions of the third eigenvector is the same as the number of sentiment polarities to be judged; finally, take the most likely sentiment feature f as the output of the model through a normalization (Softmax) layer 205.
[0124] In this way, with the trained sentiment feature model, the target text represented by the fusion vector can be input into the long short-term memory network model to determine the sentiment category of the target text.
[0125] Step S403, calculating text sentiment features;
[0126] Obtain text sentiment features, input the text of page i into the text sentiment model of step S403, and obtain the text sentiment features f of page i i .
[0127] Traverse all pages of the text to obtain the text sentiment features of the entire text. The following formula (3) represents the text sentiment feature set of the entire text.
[0128] F={f1,f2,…,f i ,…,f n} (3);
[0129] Where n represents the total number of pages of text.
[0130] Step S404: generating a text sentiment feature mask;
[0131] Considering the high cost of calculating feature data, the text sentiment feature obtained in step S403 is binarized to obtain a text sentiment feature mask that is easy to calculate. The following formula (4) represents the text sentiment feature mask set of the entire text.
[0132] Mask={mask1,mask2,…,mask i ,…,mask n} (4);
[0133] Among them, mask i Represents the sentiment feature mask of the i-th page of text.
[0134] Step S405: Detect whether there is a watermark mark;
[0135] Decode the Unicode zero-width control field in the text header according to the conversion rule to obtain the text watermark flag;
[0136] When Flag is not empty, it indicates that the text has been embedded with a text watermark, and the process goes to step S405 to enter the watermark detection process;
[0137] When Flag is empty, it indicates that the text has not been embedded with a text watermark and enters the watermark embedding process.
[0138] Step S406: embedding a plain text watermark;
[0139] The main purpose of embedding a plaintext watermark is to clarify copyright and prevent illegal use. The plaintext watermark content can be customized and no mandatory restrictions are imposed here. This step can use a watermark algorithm based on discrete wavelet transforms to complete plaintext watermark embedding.
[0140] Step S407, embedding a ciphertext watermark;
[0141] Mask i According to the conversion rules, replace it with a Unicode zero-width control field and embed it at the end of each page to form an invisible ciphertext watermark; traverse all pages of the text and embed a ciphertext watermark for each page;
[0142] Step S408: embedding a watermark mark;
[0143] Set the text watermark Flag. The Flag content is the mark information of the creator and owner of the text to protect the rights and interests of the legal owner of the text. Replace the Flag with a Unicode zero-width control field and embed it into the text header.
[0144] Step S409, outputting watermark text;
[0145] After the above steps S405, S406 and S407, the watermark embedding is completed and the watermark text is output.
[0146] Step S410, matching the ciphertext watermark to obtain a matching value;
[0147] Decode the Unicode zero-width control field at the end of each page according to the conversion rules to obtain the ciphertext watermark mark of the i-th page of the text i ;
[0148] Calculate the sentiment feature mask of the text on page i i With ciphertext watermark mark i Match value match i , the following formula (5) is the formula for calculating the matching value.
[0149]
[0150] Among them, match i is the ciphertext watermark match value for the i-th page of text, match i The larger it is, the more similar the emotional characteristics reflected by the text content of page i and the ciphertext watermark are;
[0151] Traverse all pages of the text to obtain the set of ciphertext watermark matching values for the entire text:
[0152] Match={match1,match2,…,match i ,…,match n}.
[0153] Step S411, determining whether the matching value is greater than the interference threshold;
[0154] Determine whether the match value is greater than the interference threshold (first threshold), set match d is the watermark interference threshold, match d Take the empirical value 0.05;
[0155] When there is a match i ≥match d , that is, there is a ciphertext watermark matching value of a certain page in the text that is greater than the watermark identification interference threshold, indicating that the text has been embedded with a text watermark, and then go to step 503;
[0156] When there is no match i ≥match d When the ciphertext watermark matching values of all pages in the text are less than the watermark interference threshold, it indicates that the text is not embedded with a text watermark. The watermark may be interfered by channel noise, resampling, lossy compression, etc. during transmission, and the watermark of the input text is incorrectly marked, and the watermark needs to be re-embedded.
[0157] Step S412: determine whether the matching value is greater than a tampering threshold (a second threshold);
[0158] Setting the match t is the tampering threshold of the ciphertext watermark, match t Take the experience value 0.8;
[0159] When match i ≥match t When , the ciphertext watermark matching values of all pages in the text are greater than the ciphertext watermark tampering threshold, indicating that the text is safely transmitted;
[0160] When there is a match i <match t When , that is, there is a page in the text whose ciphertext watermark matching value is less than the ciphertext watermark tampering threshold, indicating that the text may have been tampered with during transmission;
[0161] Step S413, outputting the text to be processed;
[0162] According to step S412, it is determined that the input text to be processed has not been tampered with, and the input text is directly output through watermark detection;
[0163] Step S414: issuing a text tampering warning;
[0164] It is determined in step S412 that the input text to be processed has a risk of being tampered with and fails the watermark detection, and a text tampering warning is issued.
[0165] The embodiment of the present application provides a text watermark model based on sentiment features. When the text to be processed is input, the sentiment features of the text can be extracted using the text sentiment model, and the text can be embedded into the text to generate a watermark text; the text with the embedded watermark can automatically detect the watermark, and issue a tampering warning for the text with a risk of tampering. The text sentiment feature extraction method based on the long short-term memory network combines word embedding and sentiment embedding, and uses the improved long short-term memory network to perform fine-grained sentiment analysis to extract text sentiment features; the watermark embedding method based on text sentiment features masks the text sentiment features that can characterize the text content and implicitly embeds them into the text; the multiple threshold screening mechanism enables the text watermark model to correctly complete the watermark embedding or detection function under a certain degree of interference or attack, and can issue a tampering warning for text with a tendency to be tampered. In this way, the improved text sentiment model based on long short-term memory network is used to extract text sentiment features. Even if there are multiple sentiment tendencies in the text at the same time, the text sentiment model can extract the real sentiment features of the text, thereby improving the accuracy and robustness of the text watermark. Using the watermark embedding method based on text sentiment features, the masked text features are small in size and have low computational cost, thereby improving processing efficiency and reducing the amount of redundant data carried. At the same time, the processing method of separating text content from text watermarks ensures the transparency and security of text watermarks. Using the multiple threshold screening mechanism, the text watermark can still play a role under a certain degree of interference or attack, thereby improving the robustness of the text watermark.
[0166] Based on the foregoing embodiments, the embodiments of the present application provide a device for detecting watermarks in texts. The device includes the modules included and can be implemented by a processor in a computer device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.
[0167] Figure 5 A schematic diagram of the structure of the text watermark embedding and detection device provided in the embodiment of the present application is shown in FIG. Figure 5 As shown, the device 500 includes an extraction module 501, a first acquisition module 502, a determination module 503 and a detection module 504, wherein:
[0168] Extraction module 501, used for extracting the emotion feature mask of the text to be processed;
[0169] The first acquisition module 502 is used to acquire the ciphertext watermark of the text to be processed when it is determined that the text to be processed has a watermark mark, wherein the ciphertext watermark is formed by embedding the emotion feature mask into the text to be processed according to a conversion rule;
[0170] A determination module 503, used to determine the matching degree between the emotion feature mask and the ciphertext watermark;
[0171] The detection module 504 is used to perform ciphertext watermark detection on the text to be processed according to the matching degree.
[0172] Based on the aforementioned embodiment, the extraction module includes an extraction submodule and a binarization processing module, wherein the extraction submodule is used to extract the emotional features of the text to be processed using a text emotional model; the binarization processing module is used to binarize the emotional features to obtain the emotional feature mask.
[0173] Based on the aforementioned embodiment, the extraction module also includes a conversion submodule, a first normalization processing submodule, a linear transformation module and a second normalization processing submodule, wherein the conversion submodule is used to use a long short-term memory network to convert the acquired first feature vector into a second feature vector, wherein the first feature vector includes sample words and emotional tendency information; the first normalization submodule is used to normalize the first feature vector to obtain a sentence sentiment vector; the linear transformation submodule is used to input the second feature vector and the sentence sentiment vector into a fully connected layer for linear transformation to obtain a third feature vector, so that the number of dimensions of the third feature vector is the same as the number of emotional polarities that need to be judged; the second normalization processing submodule is used to normalize the third feature vector to complete the pre-training of the text sentiment model.
[0174] Based on the aforementioned embodiment, the device also includes a second acquisition module, a first embedding module, a first conversion module, a second embedding module, a third acquisition module, a second conversion module and a third embedding module, wherein the second acquisition module is used to acquire the plaintext watermark of the text to be processed; the first embedding module is used to embed the plaintext watermark in the text to be processed when it is determined that there is no watermark identifier in the text to be processed; the first conversion module is used to convert the emotional feature mask into a first zero-width control field according to a single code conversion rule; the second embedding module is used to embed the first zero-width control field into a first specific position of the text to be processed; the third acquisition module is used to acquire the watermark identifier of the text to be processed; the second conversion module is used to convert the watermark identifier into a second zero-width control field according to a single code conversion rule; the third embedding module is used to embed the second zero-width control field into a second specific position of the text to be processed, and output the text embedded with the watermark.
[0175] Based on the aforementioned embodiment, the text to be processed includes at least one page of text, the matching degree is a set of matching values of the text to be processed, and the determination module includes: a first determination submodule and a second determination submodule, wherein the first determination submodule is used to determine the matching value of the sentiment feature mask of each page of the text to be processed and the ciphertext watermark of each page of the text to be processed by using the square formula of the bi-norm to obtain the matching value of each page of the text to be processed; the second determination submodule is used to determine the matching value of each page of the text to be processed as a matching value in the matching value set of the text to be processed.
[0176] Based on the aforementioned embodiment, the detection module includes a third determination submodule, a fourth determination submodule, a fifth determination submodule and a tampering warning module, wherein the third determination submodule is used to determine that the text to be processed is embedded with a ciphertext watermark when any matching value in the matching value set is greater than a first threshold; the fourth determination submodule is used to determine that the text to be processed passes the text watermark detection when each matching value in the matching value set is greater than the second threshold, wherein the second threshold is greater than the first threshold; the fifth determination submodule is used to determine that the text to be processed is a text that fails the ciphertext watermark detection when any matching value in the matching value set is less than the second threshold; the tampering warning module is used to issue a tampering warning for the text that fails the ciphertext watermark detection to prompt that the text to be processed is at risk of tampering.
[0177] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0178] It should be noted that in the embodiments of the present application, if the above-mentioned text watermark embedding and detection method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable an electronic device (which can be a mobile phone, a tablet computer, a laptop computer, a desktop computer, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0179] Correspondingly, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the method for detecting a watermark in a text provided in the above embodiment are implemented.
[0180] Correspondingly, an embodiment of the present application provides a computer device, Figure 6 A schematic diagram of a hardware entity of a computer device according to an embodiment of the present application is shown in FIG. Figure 6 As shown, the hardware entity of the device 600 includes: a memory 601 and a processor 602, wherein the memory 601 stores a computer program that can be run on the processor 602, and the processor 602 implements the steps of detecting watermarks in texts provided in the above embodiment when executing the program.
[0181] The memory 601 is configured to store instructions and applications executable by the processor 602, and can also cache data to be processed or processed by the processor 602 and various modules in the computer device 600 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0182] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0183] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.
[0184] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0185] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0186] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0187] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0188] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0189] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a mobile phone, tablet computer, laptop computer, desktop computer, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, magnetic disks or optical disks.
[0190] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0191] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0192] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0193] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for detecting a watermark in a text, the method comprising: Extract the sentiment feature mask of the text to be processed; In the case where it is determined that the text to be processed has a watermark mark, obtaining a ciphertext watermark of the text to be processed, wherein the ciphertext watermark is formed by embedding the emotion feature mask into the text to be processed according to a conversion rule; Determining a degree of match between the emotion feature mask and the ciphertext watermark; The ciphertext watermark detection is performed on the text to be processed according to the matching degree.
2. The method according to claim 1, characterized in that The step of extracting the emotional feature mask of the text to be processed includes: Extracting emotional features of the text to be processed using a text emotional model; The emotional feature is binarized to obtain the emotional feature mask.
3. The method according to claim 2, characterized in that The text sentiment model is trained by the following method: The first feature vector obtained is converted into a second feature vector using a long short-term memory network; wherein the first feature vector includes a sample word vector and a sentiment tendency vector; Using a normalization layer to normalize the first feature vector to obtain a sentence sentiment vector; Using a fully connected layer to perform a linear transformation on the second feature vector and the sentence sentiment vector to obtain a third feature vector, so that the number of dimensions of the third feature vector is the same as the number of sentiment polarities to be judged; The third feature vector is normalized by using the normalization layer to complete the pre-training of the text sentiment model.
4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Obtaining the plaintext watermark of the text to be processed; If it is determined that the text to be processed does not have a watermark mark, embedding the plaintext watermark in the text to be processed; Converting the emotion feature mask into a first zero-width control field according to a single code conversion rule; Embedding the first zero-width control field at a first specific position of the text to be processed; Obtaining a watermark identifier of the text to be processed; Convert the watermark identifier into a second zero-width control field according to a single code conversion rule; The second zero-width control field is embedded in a second specific position of the text to be processed, and the text embedded with the watermark is output.
5. The method according to any one of claims 1 to 3, characterized in that: The text to be processed includes at least one page of text, the matching degree is a set of matching values of the text to be processed, and the determining of the matching degree between the emotion feature mask and the ciphertext watermark includes: Determine the matching value of the sentiment feature mask of each page of the text to be processed and the ciphertext watermark of each page of the text to be processed by using the square formula of the bi-norm, and obtain the matching value of each page of the text to be processed; The matching value of each page of the to-be-processed text is determined as a matching value in the matching value set of the to-be-processed text.
6. The method according to claim 5, characterized in that The performing ciphertext watermark detection on the to-be-processed text according to the matching degree includes: When any matching value in the matching value set is greater than a first threshold, determining that the to-be-processed text is embedded with a ciphertext watermark; In the case where each matching value in the matching value set is greater than a second threshold, it is determined that the text to be processed passes the text watermark detection, wherein the second threshold is greater than the first threshold.
7. The method according to claim 6, characterized in that The method further comprises: When any matching value in the matching value set is less than the second threshold, determining that the text to be processed is text that fails to pass the ciphertext watermark detection; A tampering warning is issued for the text that fails the ciphertext watermark detection to indicate that there is a risk of tampering with the text to be processed.
8. A device for detecting a watermark in a text, the device comprising: An extraction module, used to extract the sentiment feature mask of the text to be processed; An acquisition module, used for acquiring a ciphertext watermark of the text to be processed when it is determined that the text to be processed has a watermark mark, wherein the ciphertext watermark is formed by embedding the emotion feature mask into the text to be processed according to a conversion rule; A determination module, used to determine the matching degree between the emotion feature mask and the ciphertext watermark; A detection module is used to perform ciphertext watermark detection on the text to be processed according to the matching degree.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, wherein: When the processor executes the program, the steps in the method according to any one of claims 1 to 7 are implemented.
10. A storage medium, characterized in that: Executable instructions are stored, which are used to cause a processor to execute and implement the steps in any one of the methods described in claims 1 to 7.