Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. def get_game(names):
  2. #name = "The Lord of the Rings: The Battle for Middle-Earth"
  3. games=[]
  4. for name in names:
  5. datas= game_id_df[game_id_df.Title == name]
  6. if not datas.empty:
  7. data_index = game_id_df[game_id_df.Title == name].index[0]
  8. train_data_reviews[data_index]
  9.  
  10. new_datapoint = [train_data_reviews[data_index]]
  11. new_vec = lsa.transform(tfidf_vectorizer.transform(new_datapoint))
  12.  
  13. nn = NearestNeighbors(n_neighbors=5, metric='cosine', algorithm='brute')
  14. nn.fit(lsa_tfidf_data)
  15.  
  16. result = nn.kneighbors(new_vec)
  17.  
  18.  
  19. for r in result[1][0]:
  20. game = game_id_df.Title[r]
  21. if game not in games:
  22. games.append(game)
  23. return(games)
  24.  
  25. profile = sys.argv[1]
  26. response = req.get("https://localhost:5001/api/profile/getUserGamesNames?userId=" + profile)
  27.  
  28. data = json.loads(response.text)
  29. games_list = []
  30. for games in data['games']:
  31. games_list.append(games)
  32. list_of_games= get_game(games_list)
  33.  
  34. with open('list_of_games.txt', 'w') as f:
  35. for item in list_of_games:
  36. f.write("%s\n" % item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement