PHP Detect Duplicate Text

后端 未结 9 1383
夕颜
夕颜 2021-02-05 07:52

I have a site where users can put in a description about themselves.

Most users write something appropriate but some just copy/paste the same text a number of times (to

9条回答
  •  情深已故
    2021-02-05 08:28

    I think you are on the right track breaking down the string and looking at repeated words.

    Here is some code though which does not use a PCRE and leverages PHP native string functions (str_word_count and array_count_values):

    
        int(1)
        ["a"]=>
        int(6)
        ["and"]=>
        int(6)
        ["peace"]=>
        int(6)
        ["love"]=>
        int(5)
      }
      */
    

    Some tweaks might be to:

    • setup a list of common words to be ignored
    • look at order of words (previous and next), not just number of occurrences

提交回复
热议问题