How to remove highly similar content? You can do whatever you want! For example, the following three jokes are almost the same, but the differences between individual symbols and line breaks are different. Suppose there are 0.3 million pieces of data, of which tens of thousands have high similarity. How can I filter the data? Yes... how to remove content with high similarity? You can do whatever you want!
For example, the following three jokes are almost the same, but the differences between individual symbols and line breaks are different. Suppose there are 0.3 million pieces of data, of which tens of thousands have high similarity. How can I filter the data?
You can do whatever you want, preferably PHP, MySQL, and clients.
Brother was invited to attend the previous wedding and sat down at a table with a bunch of strangers. A buddy asked me who was the bride? I replied, I just want to see where I used to fight! People who did not expect a table raise their glasses:
Everyone is a comrade-in-arms. Cheers. Have a drink and discuss combat experience later!
Brother was invited to attend the previous wedding and sat down at a table with a bunch of strangers. A buddy asked me, "Who is the bride ?" I replied, I just want to see where I used to fight!
People who did not think of a table raise their glasses: "Everyone is a comrade-in-arms. Cheers. Have a drink more and discuss combat experience later !"
Brother was invited to attend the previous wedding and sat down at a table with a bunch of strangers. A buddy asked me who was the bride? I replied, I just want to see where I used to fight! I didn't expect the man at the desk to raise his glass: everyone is a comrade-in-arms. Cheers, have more drinks, and discuss combat experience later!
Reply content:
How to remove highly similar content? You can do whatever you want!
For example, the following three jokes are almost the same, but the differences between individual symbols and line breaks are different. Suppose there are 0.3 million pieces of data, of which tens of thousands have high similarity. How can I filter the data?
You can do whatever you want, preferably PHP, MySQL, and clients.
Brother was invited to attend the previous wedding and sat down at a table with a bunch of strangers. A buddy asked me who was the bride? I replied, I just want to see where I used to fight! People who did not expect a table raise their glasses:
Everyone is a comrade-in-arms. Cheers. Have a drink and discuss combat experience later!
Brother was invited to attend the previous wedding and sat down at a table with a bunch of strangers. A buddy asked me, "Who is the bride ?" I replied, I just want to see where I used to fight!
People who did not think of a table raise their glasses: "Everyone is a comrade-in-arms. Cheers. Have a drink more and discuss combat experience later !"
Brother was invited to attend the previous wedding and sat down at a table with a bunch of strangers. A buddy asked me who was the bride? I replied, I just want to see where I used to fight! I didn't expect the man at the desk to raise his glass: everyone is a comrade-in-arms. Cheers, have more drinks, and discuss combat experience later!
Answer-only similarity Processing
Andsimilar_text()Compared to functions,levenshtein()The function is faster,similar_text()Functions can provide more accurate results with fewer necessary modifications, and can be used when the speed is pursued with less precision and the length of a string is limited.levenshtein()Function, andsimilar_text()Poor Support for Chinese Characters
Finally, let's keep a new one: using cosine theorem + word segmentation to calculate Text Similarity. PHP version
Https://github.com/xiaobeicn/text-similarity-php
Use it directly if the requirement is not highsimilar_textRight, DEMO: http://3v4l.org/iBXvC
If there are only a few more punctuation marks and line breaks, you can remove those symbols, line breaks, and then compare the md5 value of the string. Of course, this will not work if the order of the text increases greatly.
To put it bluntly, the abstract algorithm is not enough for word segmentation. It also requires part-of-speech analysis to leave nouns and verbs for more accurate features.
I will give you a solution that I think is the most reliable.
(1) divide parts of speech in an article. Only verbs and nouns are retained, such
Brother was invited to attend the previous wedding and sat down at a table with a bunch of strangers. A buddy asked me who was the bride? I replied, I just want to see where I used to fight! People who did not expect a table raise their glasses:
Everyone is a comrade-in-arms. Cheers. Have a drink and discuss combat experience later!
I think this article is characterized by experienced comrades in the Battle of The Wedding Bride
(2) You need many examples, such as 10000 articles. Based on the 10 thousand articles, we roughly infer all the words that may be important in the entire 0.3 million text, based on experience, this vocabulary will exceed if not processed.
(3) Use the feature extraction algorithm to streamline the vocabulary. As for how to extract features, at least the course of tobacco and liquor students will talk about mathematics. In this way, you will reduce the number of words to about 3000.
(4) use these 3000 words to represent each text, such as w1 = ,..... 0 ,.. 1, 0... 1 .. 0...] we do not consider word frequency. Such a data structure can be easily converted to a string using bitmap.
(5) deduplicate all text using the Hash table
This is the most efficient, but there must be an error, because Feature Extraction itself is the process of reducing the amount of information, in exchange for the fastest speed, but can achieve any new article, the process of Word Segmentation is negligible, which is almost the time complexity of O (1 ).
Another idea is provided: after removing all punctuation marks, spaces, and line breaks, use the dynamic programming algorithm to calculate the "edit distance/Levenshtein distance" (that is, the string s1 is transformed to get the minimum number of times s2 is edited, one edit operation can be to add, delete, or modify a character ). It is easy to implement and the efficiency is good (about O (N ^ 2) where N is the string length)
This algorithm seems to be a classic algorithm used in the informatics competition. You can find the "string editing distance" (which is also available in Wikipedia). If you do not want to use a library, you can consider this method.
What I want to talk about is the editing distance, which is already mentioned above.
Http://www.cnblogs.com/liangxiaxu/archive/2012/05/05/2484972.html
Cosine theorem and simhash are both good. The latter was invented by Google.