A text similarity calculation and deduplication method, system, medium and device

Through Sbert + noun entity recognition + keyword extraction + word2vec model, combined with stop word removal and custom thesaurus, the problem of insufficient accuracy in text similarity calculation in the field of government service convenience hotlines is solved, and a more accurate deduplication effect is achieved. .

CN114818986BActive Publication Date: 2024-09-17XIAN JINXUN SHUZHI INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210612069.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-31
Publication Date
2024-09-17
Estimated Expiration
2042-05-31

AI Technical Summary

Technical Problem

Existing text similarity calculation methods lack pertinence in the field of government service convenience hotlines, resulting in insufficient accuracy and excessive noise, and cannot effectively achieve duplication detection.

Method used

The Sbert + noun entity recognition + keyword extraction + word2vec model is used, combined with stop word removal and a custom vocabulary library, to preprocess and extract features of hotline text data, and achieve text similarity deduplication through cosine similarity calculation.

Benefits of technology

Through feature fusion and feature enhancement, the accuracy of text similarity calculation is improved, and better deduplication effect is achieved, which is suitable for the field of government service convenience hotlines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114818986B
    Figure CN114818986B
Patent Text Reader

Abstract

The present invention discloses a method, system, medium and device for calculating and removing duplicates of text similarity. The method includes importing a hotline text data set into a database, and inputting it into a trained model for feature extraction, feature fusion and feature enhancement, obtaining the final features of the data and serializing and saving them; inputting the data to be calculated into the model to extract the final features; performing cosine similarity calculation with the hotline text data within the corresponding date to obtain the similarity results; and outputting the similarity results ranked top 50 for deduplication. The present invention is oriented to the government service hotline for the convenience of the people. The final sentence features of the hotline text content are extracted through the model for similarity calculation and deduplication. The method also provides a way for external calls. The model can be operated through four interfaces to realize different model functions. The method is easy to operate and has strong practicality. It is suitable for the hotline field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of text similarity, and in particular relates to a method, system, medium and device for calculating and removing duplicate text similarity. Background Art

[0002] In the era of intelligence, natural language processing technology has developed rapidly and has been widely used. In the application field, it often involves how to measure and calculate the similarity between two texts. Text similarity is widely used in many fields, such as knowledge retrieval, text duplication detection, automatic generation of text summaries, recommendation systems, text classification, machine translation, etc. Text similarity is a very important and indispensable technology in natural language processing.

[0003] Text similarity refers to the similarity between two texts. Texts are in a high-dimensional semantic space, and they need to be abstracted and decomposed in order to quantify their similarity from a mathematical perspective. Today, there are three main methods for measuring text similarity: one is the traditional method based on keyword matching, such as N-gram similarity; the second is to reduce the dimension of the text and map it to the vector space, and then use methods such as Euclidean distance and cosine similarity for calculation; the third is a method based on deep learning, such as ConvNet based on convolutional neural networks, DSSM twin tower model and other methods. At present, with the rapid development of deep learning, the method of measuring text similarity has gradually stopped using the traditional method based on keyword matching, and has basically turned to methods based on deep learning and combined with vector representation.

[0004] In the above methods, the application scope of text similarity is too broad and not targeted. Among the text similarity calculation products currently available on the market, there is no text similarity calculation method for government service hotlines. In the hotline field, text similarity technology plays a huge role. A large amount of new data flows into the hotline field every day. In the large amount of recorded hotline text data, events may be repeated. The text similarity technology applied to the hotline field can calculate the similarity of hotline texts and perform deduplication detection based on the similarity results.

[0005] In recent years, text similarity calculation methods have been continuously proposed, but most of these methods are widely used in various fields, lack accuracy and specificity. For the hotline field, these methods will introduce too much noise and the effect is not very ideal. Moreover, in the hotline field where text similarity plays a very important role, there is currently no ideal text similarity calculation method used, and a good deduplication effect cannot be achieved. Summary of the invention

[0006] The technical problem to be solved by the present invention is to provide a text similarity calculation and deduplication method, system, medium and device in view of the deficiencies in the above-mentioned prior art, which can calculate the text similarity of hotline texts based on the hotline text data set provided by the hotline field and achieve good deduplication detection effect.

[0007] The present invention adopts the following technical solutions:

[0008] A text similarity calculation and deduplication method comprises the following steps:

[0009] S1. Preprocess the hotline text dataset to obtain a dataset containing work order number, person, location, date, mobile phone number and text content;

[0010] S2, input the data set obtained in step S1 into the sbert+noun entity recognition+keyword extraction+word2vec model, initialize it by removing stop words and custom vocabulary, obtain the feature vector of the text data, and perform noun entity extraction and keyword extraction on the text data to obtain the text feature vector of each hotline text data;

[0011] S3, extract the features of the new text, input the new hotline text into the sbert+noun entity recognition+keyword extraction+word2vec model, and obtain the final feature vector of the new text;

[0012] S4, selecting the feature vector of the data volume within the set date from the text feature vector of each hotline text data obtained in step S2, and performing cosine similarity calculation between the final feature vector of the new text obtained in step S3 and the feature vector to obtain a text similarity result;

[0013] S5. Based on the text similarity result obtained in step S4, the hotline text data ranked top 50 in similarity are output to achieve deduplication of text similarity calculation.

[0014] Specifically, in step S1, the data set format is a csv file encoded in utf-8, and the work order number and hotline text content are required attributes.

[0015] Specifically, in step S2, the sentence is input into the sbert+noun entity recognition+keyword extraction+word2vec model. The sbert model uses the average pooling strategy and takes the vector after the mean as the sentence vector V s , get the global features, word2vec model gets the noun word vector V n , obtain the keyword vector V through the TFIDF algorithm k , get the local features, and transform the noun word vector V n And keyword word vector V kAverage and then sum it with the sentence vector V s Average to get the final sentence vector V n×d , n is the amount of data in the hotline text data set, d is the vector dimension, the feature vectors of all hotline text data are serialized and saved, the pickle module is used to dump the serialized data of all hotline text feature vectors, the result data stream of the feature vector is written to the file object, and the load is used to deserialize the object to restore the text feature vector of each hotline text data.

[0016] Specifically, in step S2, the noun entity extraction of the text data is specifically as follows:

[0017] Use named entity recognition to identify all entities in the hotline text. Use custom dictionaries to identify the correct entities and extract all noun entities to achieve feature enhancement.

[0018] Specifically, in step S2, keyword extraction from text data is performed as follows:

[0019] Use the TF-IDF algorithm to extract keywords, obtain the inverse document frequency IDF value through the corpus, use the hotline text corpus to train the text corpus of inverse document frequency IDF, obtain the IDF value of each word, input the text of the keywords to be extracted, calculate the word frequency TF, obtain the final TF-IDF value, sort all the words to get the keyword set and return the 10 keywords with the largest TFIDF weight to achieve feature enhancement of the hotline text.

[0020] Furthermore, the term frequency TF and inverse document frequency IDF are specifically:

[0021]

[0022]

[0023] Specifically, in step S4, the cosine similarity between two texts is calculated as follows:

[0024]

[0025] Among them, A is the feature vector of text 1, B is the feature vector of text 2, n is the dimension of the feature vector, A i is the i-th element of vector A, B i is the i-th element of vector B, and θ is the angle between the two vectors.

[0026] In a second aspect, an embodiment of the present invention provides a text similarity calculation and deduplication system, comprising:

[0027] The data module preprocesses the hotline text dataset to obtain a dataset containing the work order number, person, location, date, mobile phone number and text content;

[0028] The first feature module inputs the data set obtained by the data module into the sbert+noun entity recognition+keyword extraction+word2vec model, combines the removal of stop words and the custom vocabulary for initialization, obtains the feature vector of the text data, and performs noun entity extraction and keyword extraction on the text data to obtain the text feature vector of each hotline text data;

[0029] The second feature module extracts the features of the new text and inputs the new hotline text into the sbert+noun entity recognition+keyword extraction+word2vec model to obtain the final feature vector of the new text;

[0030] A calculation module selects a feature vector of a set date from the text feature vector of each hotline text data obtained by the first feature module, and performs cosine similarity calculation on the final feature vector of the new text obtained by the second feature module and the feature vector to obtain a text similarity result;

[0031] The similarity module outputs the top 50 hotline text data in similarity ranking based on the text similarity results obtained by the calculation module to achieve deduplication of text similarity calculation.

[0032] In a third aspect, a computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned text similarity calculation and deduplication method when executing the computer program.

[0033] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned text similarity calculation and deduplication method.

[0034] Compared with the prior art, the present invention has at least the following beneficial effects:

[0035] The invention discloses a method for calculating and deduplicating text similarity, which is aimed at a government service hotline for the convenience of the people. The method extracts sentence features, noun features and keyword features of hotline text content through a model, realizes feature fusion and feature enhancement of the text content, can screen the hotline data according to the set start date and end date, calculates cosine similarity with the required hotline text, and obtains the top 50 hotline data, which takes into account the overall semantic features and local features such as noun keywords, realizes the combination of global features and local features, enhances the features of the text content, makes the similarity calculation result more accurate, and can achieve a better deduplication effect.

[0036] Furthermore, the unified dataset encoding is utf8 encoding, which is the universal language encoding in the world. The unified file format is csv file. The dataset format requirements are formulated to achieve the purpose of unified format. The work order number and hotline text content are set as required attributes to facilitate similarity calculation and return of the work order number.

[0037] Furthermore, the sentence is input into the sbert+noun entity recognition+keyword extraction+word2vec model, and the final sentence semantic features are extracted through feature fusion enhancement, which facilitates accurate calculation of similarity.

[0038] Furthermore, by extracting noun entities from text data, the features of the noun entities are obtained, and feature enhancement is achieved based on the overall global features of the text data to obtain semantic features more accurately.

[0039] Furthermore, by extracting keywords from text data, we obtain the features of the keywords, and then perform feature fusion again on the basis of the overall global features and noun features to further refine and enhance the features, better integrate the semantic information of the text data, and emphasize key semantic information.

[0040] Furthermore, according to the TF-IDF algorithm, the term frequency TF and the inverse document frequency IDF are calculated to obtain the TFIDF value of each word in the text data, all words are sorted according to the TF-IDF value to obtain a keyword set and at most 10 keywords with the largest TFIDF weights are returned to extract suitable keywords for semantic feature enhancement.

[0041] Furthermore, cosine similarity is used to calculate the similarity of the hotline text data to obtain a similarity result, which is simple to calculate and highly accurate, so as to obtain a better similarity result for deduplication.

[0042] It can be understood that the beneficial effects of the second to fourth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.

[0043] In summary, the present invention unifies the data set format requirements, obtains features containing basic semantic information by performing overall global feature extraction on the input text data, and then extracts noun features and keyword features as local features to perform feature fusion enhancement, taking into account both global features and local features, and obtaining more, richer and more critical semantic information to achieve more accurate similarity results.

[0044] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1It is a schematic diagram of the process of the present invention;

[0046] Figure 2 It is a schematic diagram of the structure of the model of the present invention;

[0047] Figure 3 It is a schematic diagram of the system structure of the present invention;

[0048] Figure 4 A schematic diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0050] In the description of the present invention, it should be understood that the terms “include” and “comprises” indicate the presence of described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or collections thereof.

[0051] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0052] It should be further understood that the term "and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects are in an "or" relationship.

[0053] It should be understood that, although the terms first, second, third, etc. may be used to describe preset ranges, etc. in the embodiments of the present invention, these preset ranges should not be limited to these terms. These terms are only used to distinguish preset ranges from each other. For example, without departing from the scope of the embodiments of the present invention, the first preset range may also be referred to as the second preset range, and similarly, the second preset range may also be referred to as the first preset range.

[0054] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0055] Various structural schematic diagrams of the embodiments disclosed in the present invention are shown in the accompanying drawings. These figures are not drawn to scale, and some details are magnified and some details may be omitted for the purpose of clear expression. The shapes of various regions and layers shown in the figures and the relative sizes and positional relationships therebetween are only exemplary, and may deviate in practice due to manufacturing tolerances or technical limitations, and those skilled in the art may additionally design regions / layers with different shapes, sizes, and relative positions according to actual needs.

[0056] The present invention provides a method for calculating and de-duplicating text similarity for government service hotlines, which obtains and processes a hotline text data set; imports the hotline text data set into a database for storage, and inputs it into a trained model for feature extraction, feature fusion and feature enhancement, obtains the final features of the data and serializes and saves them; inputs the data to be calculated into the model to extract the final features; performs cosine similarity calculation with the hotline text data within the corresponding date to obtain similarity results; outputs the top 50 similarity results for easy de-duplication. The present invention innovatively proposes a method and system for calculating and de-duplicating hotline text similarity for the hotline field, which is oriented to government service hotlines, extracts the final sentence features of the hotline text content through a model, performs similarity calculation and de-duplication, and also provides a way for external calls, and can implement different model functions through four interface operation models, which is easy to operate, highly practical, and suitable for the hotline field.

[0057] See also Figure 1 The present invention provides a text similarity calculation and deduplication method for a government service hotline. The method preprocesses a hotline text data set to obtain a required data set in the correct format, and then stores it in a database; inputs the hotline text data into a model, uses the model to extract features from the data in the data set, and implements feature serialization and storage; performs similarity calculation on the features, obtains similarity results between the data, and returns them; is used for data set update operations for government service hotlines, adds a new data operation, and deletes a data operation; the specific steps are as follows:

[0058] S1. Data preparation and preprocessing

[0059] Obtain various types of text data in the hotline field and make the required data set, which includes six columns: work order number, person, location, date, mobile phone number, and text content. Use this data set as the input of the feature vector extraction model sbert+noun entity recognition+keyword extraction+word2vec model;

[0060] The dataset requires a csv file in utf-8 encoding. The ticket number and hotline text content are required attributes. The person, location, and mobile phone number can be empty. The default value for the date is 0000-00-00. There should be no English commas in the text content. Use Chinese commas. There should be no line breaks in the text content. There should be no line breaks. Use None to fill in empty values. The date should be in YYYY-MM-DD format or YYYYMMDD format.

[0061] S2. Data input initialization

[0062] Import the above hotline text dataset into the MySQL database and input it into the pre-trained model. Initialize it by removing stop words and using a custom vocabulary, extract features, obtain feature vectors of the text data, perform noun entity extraction and keyword extraction on the text data, implement feature enhancement and feature fusion, obtain the text feature vectors of each hotline text data and save them.

[0063] The MySQL database table is designed with six fields, corresponding to the six attributes of the data set. The maximum length of the ORDER_NO field is limited to 30 characters, the maximum length of the PERSON field is limited to 10 characters, the S_DATE format is YYYY-MM-DD or YYYYMMDD, the maximum length of the LOCATION field is limited to 70 characters, the maximum length of the PHONE field is limited to 2 characters, and the maximum length of the CALLER_CONTENT field is limited to 1000 characters.

[0064] The path of the dataset is passed in, the database is automatically logged in and the hotline data is stored. After all the data is stored, the text content of all the hotline data will be input into the pre-trained feature vector extraction model sbert+noun entity recognition+keyword extraction+word2vec model for initialization to obtain the final feature vector of the text and serialize and save the feature vectors of all the hotline texts.

[0065] The pre-trained model is sbert+noun entity recognition+keyword extraction+word2vec. The word2vec model is trained using the hotline text dataset to obtain the embedding of the word vector. Stop words and custom vocabulary can be modified by yourself. It has good scalability in the hotline field and can be generalized.

[0066] See also Figure 1 and Figure 2 , input the sentence into the model. For the hotline text dataset, the sbert model uses the average pooling strategy and takes the vector after the mean as the sentence embedding sentence vector V s , get the global features, word2vec gets the word vector Noun embeddingV n , TFIDF algorithm obtains the keyword word vector KeywordembeddingV k , get the local features, and transform the noun word vector V n And keyword word vector V k Average and then sum it with the sentence vector V s Average to achieve feature fusion and feature enhancement, and get the final sentence vector final embeddingV n×d , where n is the amount of data in the hotline text dataset, d is the vector dimension, which is set to 512, and the sentence vectors of all hotline text data are serialized and saved.

[0067] Serialize and save all feature vectors. Use the pickle module dump to serialize the feature vectors of all calculated text data. Write the resulting data stream to a file object and serialize it in binary form for long-term storage. Use load to deserialize the object and restore the feature vectors of all text.

[0068] Use named entity recognition to identify all entities in the hotline text. Use custom dictionaries to identify the correct entities and extract all noun entities for feature enhancement.

[0069] Use the TF-IDF algorithm to extract keywords. The calculation formulas for TF (term frequency) and IDF (inverse document frequency) are as follows:

[0070]

[0071]

[0072] The IDF value is calculated through the corpus. The IDF text corpus is trained using the hotline text corpus to obtain the IDF value of each word. The text of the keywords to be extracted is input, the word frequency TF is calculated, and the final TF-IDF value is obtained.

[0073] The specific TF-IDF value is:

[0074] TF-IDF=TF×IDF

[0075] All words are sorted to obtain a keyword set and the 10 keywords with the largest TFIDF weights are returned to achieve another feature enhancement of the hotline text.

[0076] S3, extract the features of the new text, input a new hotline text, and use the trained model to obtain the final feature vector of the text;

[0077] Through the similarity calculation interface, a new hotline text data is passed from the outside to the model to extract the features of the new hotline text. The specific extraction method is as follows: Figure 2 As shown, the final feature vector V of the new hotline text is obtained new .

[0078] S4. Text similarity calculation

[0079] The final feature vector of the new text is calculated by cosine similarity with the feature vectors of all hotline texts within the specified date to obtain the text similarity result;

[0080] Through similarity calculation, not only a new hotline text data is passed from the outside to the feature vector extraction model sbert+noun entity recognition+keyword extraction+word2vec model, but also the start date and end date can be passed in, and the data within the date in the database can be filtered to obtain the data volume N to be compared. date , the final feature vector V of the new hotline text new And the amount of data N date The eigenvector of The cosine similarity is calculated pairwise to obtain the similarity result.

[0081] The cosine similarity is calculated as follows:

[0082]

[0083] Among them, A is the feature vector of text 1, B is the feature vector of text 2, n is the dimension of the feature vector, A i is the i-th element of vector A, B i is the i-th element of vector B, and θ is the angle between the two vectors.

[0084] S5, Top50 similarity output.

[0085] Based on the calculation result of the text similarity obtained in step S4, the work order numbers and text contents of the hotline text data with the top 50 similarities are output to meet the deduplication requirement.

[0086] See also Figure 3In another embodiment of the present invention, a text similarity calculation and deduplication system for a government service hotline is provided. The system can be used to implement the above-mentioned text similarity calculation and deduplication method for a government service hotline. Specifically, the text similarity calculation and deduplication system for a government service hotline includes a data module, a first feature module, a second feature module, a calculation module and a similarity module.

[0087] Among them, the data module preprocesses the hotline text data set to obtain a data set containing the work order number, person, location, date, mobile phone number and text content;

[0088] The first feature module inputs the data set obtained by the data module into the sbert+noun entity recognition+keyword extraction+word2vec model, combines the removal of stop words and the custom vocabulary for initialization, obtains the feature vector of the text data, and performs noun entity extraction and keyword extraction on the text data to obtain the text feature vector of each hotline text data;

[0089] The second feature module extracts the features of the new text and inputs the new hotline text into the sbert+noun entity recognition+keyword extraction+word2vec model to obtain the final feature vector of the new text;

[0090] A calculation module selects a feature vector of a set date from the text feature vector of each hotline text data obtained by the first feature module, and performs cosine similarity calculation on the final feature vector of the new text obtained by the second feature module and the feature vector to obtain a text similarity result;

[0091] The similarity module outputs the top 50 hotline text data in similarity ranking based on the text similarity results obtained by the calculation module to achieve deduplication of text similarity calculation.

[0092] This system provides four interfaces, including:

[0093] The dataset update interface is used to update the hotline text dataset and pass in the path of the new hotline text dataset for update;

[0094] Similarity calculation interface, used to calculate the similarity between a hotline text to be calculated and all hotline texts within a specified date and output the top 50 hotline texts with similarity rankings. Enter a hotline text to be calculated and the start date and end date for calculation;

[0095] Add a new data interface to add a new data to the database and extract its features to obtain its feature vector serialization and save it. Pass in a new hotline text, including six attributes: work order number, person, location, date, mobile phone number, and text content, to add data;

[0096] The interface for deleting a data entry is used to delete a data entry from the database and its feature vector. The work order number of the data to be deleted is passed in to delete the data.

[0097] In another embodiment of the present invention, a terminal device is provided, the terminal device includes a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc., which are the computing core and control core of the terminal, which are suitable for implementing one or more instructions, and are specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding functions; the processor described in the embodiment of the present invention can be used for the operation of the text similarity calculation deduplication method, including:

[0098] The hotline text dataset is preprocessed to obtain a dataset containing work order numbers, people, locations, dates, mobile phone numbers and text content; the dataset is input into the sbert+noun entity recognition+keyword extraction+word2vec model, and initialized by removing stop words and custom vocabulary to obtain the feature vector of the text data, and noun entity extraction and keyword extraction are performed on the text data to obtain the text feature vector of each hotline text data; the features of the new text are extracted, and the new hotline text is input into the sbert+noun entity recognition+keyword extraction+word2vec model to obtain the final feature vector of the new text; the feature vector of the data volume within the set date is selected from the text feature vector of each hotline text data, and the cosine similarity between the final feature vector of the new text and the feature vector is calculated to obtain the text similarity result; the hotline text data ranked top 50 in similarity are output to achieve deduplication of text similarity calculation.

[0099] In another embodiment of the present invention, the present invention further provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a terminal device for storing programs and data. It can be understood that the computer-readable storage medium here can include both the built-in storage medium in the terminal device and the extended storage medium supported by the terminal device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory, or a non-volatile memory (Non-Volatile Memory), such as at least one disk memory.

[0100] The processor may load and execute one or more instructions stored in a computer-readable storage medium to implement the corresponding steps of the text similarity calculation and deduplication method in the above embodiment; the processor may load and execute the following steps:

[0101] The hotline text dataset is preprocessed to obtain a dataset containing work order numbers, people, locations, dates, mobile phone numbers and text content; the dataset is input into the sbert+noun entity recognition+keyword extraction+word2vec model, and initialized by removing stop words and custom vocabulary to obtain the feature vector of the text data, and noun entity extraction and keyword extraction are performed on the text data to obtain the text feature vector of each hotline text data; the features of the new text are extracted, and the new hotline text is input into the sbert+noun entity recognition+keyword extraction+word2vec model to obtain the final feature vector of the new text; the feature vector of the data volume within the set date is selected from the text feature vector of each hotline text data, and the cosine similarity between the final feature vector of the new text and the feature vector is calculated to obtain the text similarity result; the hotline text data ranked top 50 in similarity are output to achieve deduplication of text similarity calculation.

[0102] See also Figure 4 The computer device 60 of this embodiment includes: a processor 61, a memory 62, and a computer program 63 stored in the memory 62 and executable on the processor 61. When the computer program 63 is executed by the processor 61, the text similarity calculation and deduplication method in the embodiment is implemented. To avoid repetition, it is not described one by one here. Alternatively, when the computer program 63 is executed by the processor 61, the functions of each model / unit in the text similarity calculation and deduplication system in the embodiment are implemented. To avoid repetition, it is not described one by one here.

[0103] The computer device 60 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The computer device 60 may include, but is not limited to, a processor 61 and a memory 62. Those skilled in the art will appreciate that Figure 4 This is only an example of the computer device 60 and does not constitute a limitation of the computer device 60. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the computer device may also include input and output devices, network access devices, buses, etc.

[0104] The processor 61 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0105] The memory 62 may be an internal storage unit of the computer device 60, such as a hard disk or memory of the computer device 60. The memory 62 may also be an external storage device of the computer device 60, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the computer device 60.

[0106] Furthermore, the memory 62 may include both an internal storage unit of the computer device 60 and an external storage device. The memory 62 is used to store computer programs and other programs and data required by the computer device. The memory 62 may also be used to temporarily store data that has been output or is to be output.

[0107] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present invention described and shown in the drawings here can usually be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0108] Experimental verification

[0109] Because there is no labeled hotline text data, 9 sets of groundtruth were manually labeled as a small part of the benchmark hotline text data set for comparative verification of model methods and quantification of results. The specific quantification method is: in a set of data, select a hotline text as a benchmark, calculate the similarity between other hotline texts in this set of data and this hotline text, and quantify it. The hotline text labels with the same meaning are set to 1, the hotline texts with similar locations or events are set to 0.5, and the completely dissimilar ones are set to 0. The sorting weight is set to 0.9 for the same meaning, 0.5 or 0.3 for relatively similar ones, and 0.1 for completely dissimilar ones. Finally, the weighted weight of the labels in the ranking and the weights of the corresponding positions are calculated to quantify the model and compare the methods. The comparison results are shown in Table 1.

[0110] Table 1 Quantitative results of method comparison experiments

[0111]

[0112]

[0113] The total quantitative score of each group in Table 1 is 9.2 points. In order to more clearly express the quantitative results, the score is divided by 9.2 to get the percentage, and then compared with other models. The comparison results of different model methods are shown in Table 2.

[0114] Table 2 Comparison results of different model methods

[0115]

[0116] The present invention adopts the model method of Sbert+feature+keyword (average of the latter two and sbert average). The experimental results in Table 2 show that the method of Sbert+feature+keyword (average of the latter two and sbert average) performs best on the hotline text dataset compared with other experimental methods.

[0117] In summary, the present invention provides a method, system, medium and device for calculating and deduplicating text similarity, which uses global features and local features to extract semantic features of text, and fuses and enhances the features to strengthen key semantic information. The above experiments show that the text calculated by the global feature method based on SBERT and the local feature method based on noun keywords is more accurate and performs better than other methods.

[0118] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0119] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0120] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0121] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0122] The above contents are only for explaining the technical idea of ​​the present invention and cannot be used to limit the protection scope of the present invention. Any changes made on the basis of the technical solution in accordance with the technical idea proposed by the present invention shall fall within the protection scope of the claims of the present invention.

Claims

1. A text similarity calculation and deduplication method, characterized in that: The following steps are involved: S1. Preprocess the hotline text dataset to obtain a dataset containing work order number, person, location, date, mobile phone number and text content; S2. Input the data set obtained in step S1 into the sbert+noun entity recognition+keyword extraction+word2vec model, initialize it by removing stop words and custom vocabulary, obtain the feature vector of the text data, extract noun entities and keywords from the text data, obtain the text feature vector of each hotline text data, input the sentence into the sbert+noun entity recognition+keyword extraction+word2vec model, and the sbert model uses the average pooling strategy to take the vector after the mean as the sentence vector V s , get the global features, word2vec model gets the noun word vector V n , obtain the keyword vector V through the TFIDF algorithm k , get the local features, and transform the noun word vector V n And keyword word vector V k Average and then sum it with the sentence vector V s Average to get the final sentence vector V n×d , n is the amount of data in the hotline text data set, d is the vector dimension, the feature vectors of all hotline text data are serialized and saved, the pickle module is used to dump the serialized data of all hotline text feature vectors, the result data stream of the feature vector is written to the file object, and the load is used to deserialize the object to restore the text feature vector of each hotline text data; S3, extract the features of the new text, input the new hotline text into the sbert+noun entity recognition+keyword extraction+word2vec model, and obtain the final feature vector of the new text; S4, selecting the feature vector of the data volume within the set date from the text feature vector of each hotline text data obtained in step S2, and performing cosine similarity calculation between the final feature vector of the new text obtained in step S3 and the feature vector to obtain a text similarity result; S5. Based on the text similarity result obtained in step S4, the hotline text data ranked top 50 in similarity are output to achieve deduplication of text similarity calculation.

2. The text similarity calculation and deduplication method according to claim 1, characterized in that: In step S1, the data set format is a utf-8 encoded csv file, and the work order number and hotline text content are required attributes.

3. The text similarity calculation and deduplication method according to claim 1, characterized in that: In step S2, noun entity extraction is performed on the text data as follows: Use named entity recognition to identify all entities in the hotline text. Use custom dictionaries to identify the correct entities and extract all noun entities to achieve feature enhancement.

4. The text similarity calculation and deduplication method according to claim 1, characterized in that: In step S2, keyword extraction from text data is specifically performed as follows: Use the TF-IDF algorithm to extract keywords, obtain the inverse document frequency IDF value through the corpus, use the hotline text corpus to train the text corpus of inverse document frequency IDF, obtain the IDF value of each word, input the text of the keywords to be extracted, calculate the word frequency TF, obtain the final TF-IDF value, sort all the words to get the keyword set and return the 10 keywords with the largest TFIDF weight to achieve feature enhancement of the hotline text.

5. The text similarity calculation and deduplication method according to claim 4 is characterized in that: The specific terms TF and inverse document frequency IDF are:

6. The text similarity calculation and deduplication method according to claim 1, characterized in that: In step S4, the cosine similarity between two texts is calculated as follows: Among them, A is the feature vector of text 1, B is the feature vector of text 2, n is the dimension of the feature vector, A i is the i-th element of vector A, B i is the i-th element of vector B, and θ is the angle between the two vectors.

7. A text similarity calculation and deduplication system, characterized in that: include: The data module preprocesses the hotline text dataset to obtain a dataset containing the work order number, person, location, date, mobile phone number and text content; In the first feature module, the data set obtained by the data module is input into the sbert+noun entity recognition+keyword extraction+word2vec model, and the stop words and custom vocabulary are combined for initialization to obtain the feature vector of the text data. The text data is then subjected to noun entity extraction and keyword extraction to obtain the text feature vector of each hotline text data. The sentence is input into the sbert+noun entity recognition+keyword extraction+word2vec model. The sbert model uses an average pooling strategy and uses the average vector as the sentence vector V s , get the global features, word2vec model gets the noun word vector V n , obtain the keyword vector V through the TFIDF algorithm k , get the local features, and transform the noun word vector V n And keyword word vector V k Average and then sum it with the sentence vector V s Average to get the final sentence vector V n×d , n is the amount of data in the hotline text data set, d is the vector dimension, the feature vectors of all hotline text data are serialized and saved, the pickle module is used to dump the serialized data of all hotline text feature vectors, the result data stream of the feature vector is written to the file object, and the load is used to deserialize the object to restore the text feature vector of each hotline text data; The second feature module extracts the features of the new text and inputs the new hotline text into the sbert+noun entity recognition+keyword extraction+word2vec model to obtain the final feature vector of the new text; A calculation module selects a feature vector of a set date from the text feature vector of each hotline text data obtained by the first feature module, and performs cosine similarity calculation on the final feature vector of the new text obtained by the second feature module and the feature vector to obtain a text similarity result; The similarity module outputs the top 50 hotline text data in similarity ranking based on the text similarity results obtained by the calculation module to achieve deduplication of text similarity calculation.

8. A computer-readable storage medium storing one or more programs, characterized in that: The one or more programs include instructions which, when executed by a computing device, cause the computing device to perform any one of the methods according to claims 1 to 6.

9. A computing device, characterized in that include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include instructions for executing any one of the methods according to claims 1 to 6.