Avoid duplicated themes code [Python]
Avoid duplicated themes
The duplicated themes are realy annoying. Here is working python code to remove them. It can be converted to php and put into the right file of the ludum dare source code (did not find it yesterday). Maybe add a second page after a theme was suggested, which tells the user which similar themes exists or if there is exactly the same theme already there.
https://pastebin.com/94a0NSau
Usage
Input:
"The world is not enough"
Output:
Representative version of theme: world not enough
Representative themes which have an important word in common: ['loving whole world', 'enough enough', 'world not enough']
Theme is duplicated: True
Explanation
suggested_themes are themes which are already in the database:
suggested_themes = ["Loving the whole world", "The dog is evil", "Enough is enough", "And the world is not enough ..."]
mytheme is a new theme the user want to suggest.
mytheme = "The world is not enough"
cleanTheme creates a more representative string of the theme. It makes it lower case, removes are spaces, "and"s "or"s, etc.
clean_theme = cleanTheme(mytheme)
findSimilarThemes checks if a theme in representative form is kind of in the database already.
matchingthemes = findSimilarThemes(cleantheme,suggestedthemesclean)
checkForDuplicateTheme checks if there is a representative theme which matches the new theme (representative) exactly
isduplicate = checkForDuplicateTheme(cleantheme, suggestedthemesclean)