nielsdejong / neo4j-playlist-builder

A tool to dynamically generate Spotify playlists using Neo4j graph data science.
Apache License 2.0
9 stars 4 forks source link

Playlist Naming Issue - Playlist Parameters Questions #4

Open technomorph opened 2 years ago

technomorph commented 2 years ago

I was having this before when I had it working. Was getting this error: See Output. (Trimmed from Naming Playlists)

Naming playlists...

Traceback (most recent call last):
  File "/Volumes/Panko/zz Programming Transfers/Machine Learning/Neo 4J/neo4j-playlist-builder/neo4j_spotify_playlist_builder.py", line 338, in <module>
    load_graph_using_spotify_api()
  File "/Volumes/Panko/zz Programming Transfers/Machine Learning/Neo 4J/neo4j-playlist-builder/neo4j_spotify_playlist_builder.py", line 69, in load_graph_using_spotify_api
    name_playlists_based_on_keywords(neo4j)
  File "/Volumes/Panko/zz Programming Transfers/Machine Learning/Neo 4J/neo4j-playlist-builder/neo4j_spotify_playlist_builder.py", line 93, in name_playlists_based_on_keywords
    neo4j.run("""    
  File "/Users/djk-tel/Library/Python/3.9/lib/python/site-packages/neo4j/work/simple.py", line 217, in run
    self._autoResult._run(query, parameters, self._config.database, self._config.default_access_mode, self._bookmarks, **kwparameters)
  File "/Users/djk-tel/Library/Python/3.9/lib/python/site-packages/neo4j/work/result.py", line 101, in _run
    self._attach()
  File "/Users/djk-tel/Library/Python/3.9/lib/python/site-packages/neo4j/work/result.py", line 202, in _attach
    self._connection.fetch_message()
  File "/Users/djk-tel/Library/Python/3.9/lib/python/site-packages/neo4j/io/_bolt4x0.py", line 330, in fetch_message
    response.on_failure(summary_metadata or {})
  File "/Users/djk-tel/Library/Python/3.9/lib/python/site-packages/neo4j/io/_bolt4x0.py", line 529, in on_failure
    raise Neo4jError.hydrate(**metadata)
neo4j.exceptions.ConstraintError: Node(516) already exists with label `Playlist` and property `name` = '[NPB G-Funk] Southern Hyphy Hardcore - active, lively'

I had originally solved this by adding the names that would pop up in the already exists error: IE for this one I would add "hyphy", "hardcore" to the list and try again. Currently my list is pretty long like this: filtered_keywords = '"and", "rap", "hip", "hop", "new", "coast", "gangster", "west", "funk", "g", "pop"'

I still noticed that after got over the exists error that many playlists were being named very similar just swapped names:

[NPB G-Funk] Hardcore Hyphy Southern - active, cheerful [NPB G-Funk] Southern Hyphy Hardcore - active, lively [NPB G-Funk] Hardcore Trap Hyphy - energetic, lively

Here Hardcore is used 3 times, Hyphy x 3, Southern x 2. Is there anyway that could store a array that has names already used (even its index uses in playlist name) and not use them for the naming?


PLAYLIST LIMITS QUESTIONS

could you explain a bit more the

Cut off for playlists to be grouped as 'misc'

min_playlist_size

min size for playlists to be chopped up in smaller ones.

playlist_split_limit

Number of keywords to use in dynamic playlist names.

playlist_keywords_count = 3


Does this only affect the name of the playlist or does it also affect the criteria for the playlists? playlist_keywords_count = 3

nielsdejong commented 2 years ago

hi @technomorph, that's an interesting finding. Most likely you are generating several distinct playlists with the same name as generated by the keyword. As a temporary fix you could do something like:

SET p.name = \"""" + playlist_prefix + """ \" + apoc.text.capitalizeAll(name) + " - " + energy +", " + mood + rand()

on line 109.

Here's what the other configuration variables do:

Hope this helps, Niels