From bbae407b327a1050de026b598d8d7e1e0ef5d297 Mon Sep 17 00:00:00 2001 From: naidenov-alex Date: Tue, 2 Nov 2021 12:05:06 +0300 Subject: [PATCH 1/7] add filter words by corpus or vocabulary --- data/utils.py | 8 ++++++-- the_hat_game/game.py | 20 +++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/data/utils.py b/data/utils.py index 7cd2b2a..3b5dcae 100644 --- a/data/utils.py +++ b/data/utils.py @@ -28,7 +28,7 @@ def sent_2_words(sent: str) -> List[str]: return words -def corpus_to_words(file_path: str, vocab_path: str = str(VOCAB_PATH)): +def corpus_to_words(file_path: str): my_counter: Counter = Counter() with open(file_path, "r", encoding="utf-8") as fl: for sent in tqdm(fl, desc="Precess file"): @@ -38,7 +38,10 @@ def corpus_to_words(file_path: str, vocab_path: str = str(VOCAB_PATH)): min_count = max([10, max_cnt / 100]) selected_words = [word for word, count in my_counter.items() if (min_count < count <= max_cnt)] + return selected_words + +def save_words(selected_words, vocab_path: str = str(VOCAB_PATH)): with open(vocab_path, "w", encoding="utf-8") as fl: for w in selected_words: fl.write(w + "\n") @@ -177,7 +180,8 @@ def add_new_text(bucket_name=BUCKET_SPLIT_TEXTS, destination_bucket_name=BUCKET_ to_copy = sorted(set(all_files) - set(copied_files))[0] print(to_copy) download_blob(bucket_name, to_copy, DATA_PATH / to_copy) - corpus_to_words(DATA_PATH / to_copy) + words = corpus_to_words(DATA_PATH / to_copy) + save_words(words) copy_blob(bucket_name, to_copy, destination_bucket_name, to_copy) diff --git a/the_hat_game/game.py b/the_hat_game/game.py index c634853..80a4a9f 100644 --- a/the_hat_game/game.py +++ b/the_hat_game/game.py @@ -13,6 +13,7 @@ import the_hat_game.nltk_setup # noqa: F401 from the_hat_game.loggers import c_handler, logger from the_hat_game.players import RemotePlayer +from data.utils import corpus_to_words class Game: @@ -24,6 +25,8 @@ def __init__( n_rounds, n_explain_words, n_guessing_words, + corpus_path=None, + vocab_path=None, random_state=None, ): assert len(players) >= 2 @@ -36,6 +39,15 @@ def __init__( self.n_guessing_words = n_guessing_words self.random_state = random_state self.stemmer = SnowballStemmer("english") + if corpus_path is not None: + assert vocab_path is None, "corpus and vocabulary cannot be defined at the same time" + self.used_words = corpus_to_words(corpus_path) + elif vocab_path is not None: + with open(vocab_path, encoding="utf-8") as f: + words = f.readlines() + self.used_words = [word.strip() for word in words] + else: + self.used_words = None def remove_repeated_words(self, words): unique_words = [] @@ -54,9 +66,11 @@ def remove_same_rooted_words(self, word, word_list): cleared_word_list = [w for w in word_list if self.stemmer.stem(w) != root] return cleared_word_list - @staticmethod - def remove_non_existing_words(words): - existing_words = [w for w in words if len(wordnet.synsets(w)) > 0] + def remove_non_existing_words(self, words): + if self.used_words is not None: + existing_words = [w for w in words if w in self.used_words] + else: + existing_words = [w for w in words if len(wordnet.synsets(w)) > 0] return existing_words def create_word_list(self, player, word, n_words): From e500864c690f8d319443a39f874796dde9797969 Mon Sep 17 00:00:00 2001 From: naidenov-alex Date: Tue, 2 Nov 2021 12:13:25 +0300 Subject: [PATCH 2/7] refactoring --- the_hat_game/game.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/the_hat_game/game.py b/the_hat_game/game.py index 80a4a9f..7f00bfb 100644 --- a/the_hat_game/game.py +++ b/the_hat_game/game.py @@ -29,6 +29,19 @@ def __init__( vocab_path=None, random_state=None, ): + """Main class for Game. + params: + - players: list of AbstractPlayer - players in the game + - words: list of str - all used words in the game + - criteria: 'hard' of 'soft' - game criteria + - n_rounds: int - number of rounds + - n_explain_words: int - number of words for explaining + - n_guessing_words: int - number of words for guessing + - corpus_path: str - path for the corpus to create vocabulary (for criteria='hard') + - vocab_path: str - path for vocabulary (for criteria='hard') + NOTE: only corpus_path or vocab_path must be defined + NOTE: if vocabulary is not defined nltk.wordnet will be used for filter not existing words + """ assert len(players) >= 2 assert criteria in ("hard", "soft") self.players = players From 9ef46a1e587ce28d065e2a11b743f7c21174bb1d Mon Sep 17 00:00:00 2001 From: naidenov-alex Date: Tue, 2 Nov 2021 12:05:06 +0300 Subject: [PATCH 3/7] add filter words by corpus or vocabulary --- data/utils.py | 8 ++++++-- the_hat_game/game.py | 20 +++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/data/utils.py b/data/utils.py index 7cd2b2a..3b5dcae 100644 --- a/data/utils.py +++ b/data/utils.py @@ -28,7 +28,7 @@ def sent_2_words(sent: str) -> List[str]: return words -def corpus_to_words(file_path: str, vocab_path: str = str(VOCAB_PATH)): +def corpus_to_words(file_path: str): my_counter: Counter = Counter() with open(file_path, "r", encoding="utf-8") as fl: for sent in tqdm(fl, desc="Precess file"): @@ -38,7 +38,10 @@ def corpus_to_words(file_path: str, vocab_path: str = str(VOCAB_PATH)): min_count = max([10, max_cnt / 100]) selected_words = [word for word, count in my_counter.items() if (min_count < count <= max_cnt)] + return selected_words + +def save_words(selected_words, vocab_path: str = str(VOCAB_PATH)): with open(vocab_path, "w", encoding="utf-8") as fl: for w in selected_words: fl.write(w + "\n") @@ -177,7 +180,8 @@ def add_new_text(bucket_name=BUCKET_SPLIT_TEXTS, destination_bucket_name=BUCKET_ to_copy = sorted(set(all_files) - set(copied_files))[0] print(to_copy) download_blob(bucket_name, to_copy, DATA_PATH / to_copy) - corpus_to_words(DATA_PATH / to_copy) + words = corpus_to_words(DATA_PATH / to_copy) + save_words(words) copy_blob(bucket_name, to_copy, destination_bucket_name, to_copy) diff --git a/the_hat_game/game.py b/the_hat_game/game.py index c634853..80a4a9f 100644 --- a/the_hat_game/game.py +++ b/the_hat_game/game.py @@ -13,6 +13,7 @@ import the_hat_game.nltk_setup # noqa: F401 from the_hat_game.loggers import c_handler, logger from the_hat_game.players import RemotePlayer +from data.utils import corpus_to_words class Game: @@ -24,6 +25,8 @@ def __init__( n_rounds, n_explain_words, n_guessing_words, + corpus_path=None, + vocab_path=None, random_state=None, ): assert len(players) >= 2 @@ -36,6 +39,15 @@ def __init__( self.n_guessing_words = n_guessing_words self.random_state = random_state self.stemmer = SnowballStemmer("english") + if corpus_path is not None: + assert vocab_path is None, "corpus and vocabulary cannot be defined at the same time" + self.used_words = corpus_to_words(corpus_path) + elif vocab_path is not None: + with open(vocab_path, encoding="utf-8") as f: + words = f.readlines() + self.used_words = [word.strip() for word in words] + else: + self.used_words = None def remove_repeated_words(self, words): unique_words = [] @@ -54,9 +66,11 @@ def remove_same_rooted_words(self, word, word_list): cleared_word_list = [w for w in word_list if self.stemmer.stem(w) != root] return cleared_word_list - @staticmethod - def remove_non_existing_words(words): - existing_words = [w for w in words if len(wordnet.synsets(w)) > 0] + def remove_non_existing_words(self, words): + if self.used_words is not None: + existing_words = [w for w in words if w in self.used_words] + else: + existing_words = [w for w in words if len(wordnet.synsets(w)) > 0] return existing_words def create_word_list(self, player, word, n_words): From a21ce009554197c26450923b7784d25983ae9efa Mon Sep 17 00:00:00 2001 From: naidenov-alex Date: Tue, 2 Nov 2021 12:13:25 +0300 Subject: [PATCH 4/7] refactoring --- the_hat_game/game.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/the_hat_game/game.py b/the_hat_game/game.py index 80a4a9f..7f00bfb 100644 --- a/the_hat_game/game.py +++ b/the_hat_game/game.py @@ -29,6 +29,19 @@ def __init__( vocab_path=None, random_state=None, ): + """Main class for Game. + params: + - players: list of AbstractPlayer - players in the game + - words: list of str - all used words in the game + - criteria: 'hard' of 'soft' - game criteria + - n_rounds: int - number of rounds + - n_explain_words: int - number of words for explaining + - n_guessing_words: int - number of words for guessing + - corpus_path: str - path for the corpus to create vocabulary (for criteria='hard') + - vocab_path: str - path for vocabulary (for criteria='hard') + NOTE: only corpus_path or vocab_path must be defined + NOTE: if vocabulary is not defined nltk.wordnet will be used for filter not existing words + """ assert len(players) >= 2 assert criteria in ("hard", "soft") self.players = players From de1c37f4e9d6547ce35a45006eb21394e8861400 Mon Sep 17 00:00:00 2001 From: Oleg Polivin Date: Tue, 9 Nov 2021 09:47:55 +0100 Subject: [PATCH 5/7] Introduce GAME_SCOPE to avoid dependency on Google Credentials (#23) * remove dependency on google storage * Modified return of LocalFasttextPlayer, added time and code fields * Modifications for better separation of settings and code * Better division of server vs local games * Moved players into the main func * delete empty server_settings.py from server folder * Further separation of GAME_SCOPES * Separation of flask_app players and Hat Game players --- GameRun_Demo.ipynb | 975 +++----------------- flask_app/app.json | 1 - flask_app/app.py | 1 - flask_app/player.py | 17 + run_game.py | 34 +- run_text_update.py | 2 +- {data => server}/__init__.py | 0 data/utils.py => server/data.py | 4 +- the_hat_game/google.py => server/players.py | 20 +- server/storage.py | 11 + settings.py | 35 +- settings_server.py | 36 + the_hat_game/game.py | 10 +- the_hat_game/loggers.py | 3 - the_hat_game/players.py | 2 + 15 files changed, 254 insertions(+), 897 deletions(-) rename {data => server}/__init__.py (100%) rename data/utils.py => server/data.py (97%) rename the_hat_game/google.py => server/players.py (52%) create mode 100644 server/storage.py create mode 100644 settings_server.py diff --git a/GameRun_Demo.ipynb b/GameRun_Demo.ipynb index da553cb..3585737 100644 --- a/GameRun_Demo.ipynb +++ b/GameRun_Demo.ipynb @@ -23,8 +23,12 @@ "name": "stderr", "output_type": "stream", "text": [ - "/Users/aguschin/.local/share/virtualenvs/the-hat-game-gitlab-5E7X0_QA/lib/python3.8/site-packages/google/auth/_default.py:70: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a \"quota exceeded\" or \"API not enabled\" error. We recommend you rerun `gcloud auth application-default login` and make sure a quota project is added. Or you can use service accounts instead. For more information about service accounts, see https://cloud.google.com/docs/authentication/\n", - " warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)\n" + "[nltk_data] Downloading package wordnet to\n", + "[nltk_data] /Users/olegpolivin/nltk_data...\n", + "[nltk_data] Package wordnet is already up-to-date!\n", + "[nltk_data] Downloading package punkt to\n", + "[nltk_data] /Users/olegpolivin/nltk_data...\n", + "[nltk_data] Package punkt is already up-to-date!\n" ] } ], @@ -37,7 +41,6 @@ "from sklearn.metrics.pairwise import cosine_similarity\n", "from tqdm import tqdm\n", "\n", - "from data.utils import merge_all_files\n", "from the_hat_game.game import Game\n", "from the_hat_game.players import PlayerDefinition, AbstractPlayer, RemotePlayer\n", "\n", @@ -83,7 +86,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|███████████████████████████████████| 20017/20017 [00:07<00:00, 2650.21it/s]\n" + "100%|██████████████████████████████████████████████████████████████████████████████████████████████████| 20017/20017 [00:02<00:00, 7542.79it/s]\n" ] } ], @@ -107,7 +110,7 @@ "name": "stdout", "output_type": "stream", "text": [ - " 6046669 texts/20-newsgroups.txt\n" + " 6046669 texts/20-newsgroups.txt\r\n" ] } ], @@ -150,12 +153,39 @@ "execution_count": 7, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Read 7M words\n", + "Number of words: 72228\n", + "Number of labels: 0\n", + "Progress: 100.0% words/sec/thread: 178952 lr: 0.000000 avg.loss: 1.811777 ETA: 0h 0m 0s 8.5% words/sec/thread: 154469 lr: 0.045733 avg.loss: 1.986145 ETA: 0h 1m 9s 29.3% words/sec/thread: 190170 lr: 0.035336 avg.loss: 1.855177 ETA: 0h 0m43s 37.6% words/sec/thread: 191334 lr: 0.031216 avg.loss: 1.841427 ETA: 0h 0m38s 56.3% words/sec/thread: 179810 lr: 0.021848 avg.loss: 1.848673 ETA: 0h 0m28s 73.0% words/sec/thread: 180225 lr: 0.013486 avg.loss: 1.845630 ETA: 0h 0m17s 81.3% words/sec/thread: 180140 lr: 0.009373 avg.loss: 1.848708 ETA: 0h 0m12s 89.9% words/sec/thread: 179037 lr: 0.005073 avg.loss: 1.832059 ETA: 0h 0m 6s words/sec/thread: 178427 lr: 0.004913 avg.loss: 1.831022 ETA: 0h 0m 6s 90.7% words/sec/thread: 177622 lr: 0.004655 avg.loss: 1.829071 ETA: 0h 0m 6s\n", + "Read 7M words\n", + "Number of words: 72228\n", + "Number of labels: 0\n", + "Progress: 100.0% words/sec/thread: 310643 lr: 0.000000 avg.loss: 1.774640 ETA: 0h 0m 0s 20.9% words/sec/thread: 326761 lr: 0.039553 avg.loss: 2.123074 ETA: 0h 0m28s 43.6% words/sec/thread: 350520 lr: 0.028192 avg.loss: 1.940951 ETA: 0h 0m18s 47.9% words/sec/thread: 343707 lr: 0.026072 avg.loss: 1.927252 ETA: 0h 0m17s 59.9% words/sec/thread: 339867 lr: 0.020063 avg.loss: 1.878824 ETA: 0h 0m13s 71.3% words/sec/thread: 333075 lr: 0.014372 avg.loss: 1.842295 ETA: 0h 0m10s1.805002 ETA: 0h 0m 5s 95.6% words/sec/thread: 309457 lr: 0.002210 avg.loss: 1.780559 ETA: 0h 0m 1s 97.1% words/sec/thread: 309281 lr: 0.001437 avg.loss: 1.777925 ETA: 0h 0m 1s\n", + "Read 7M words\n", + "Number of words: 72228\n", + "Number of labels: 0\n", + "Progress: 99.9% words/sec/thread: 187602 lr: 0.000062 avg.loss: 1.744509 ETA: 0h 0m 0s 3.1% words/sec/thread: 140266 lr: 0.048466 avg.loss: 2.301816 ETA: 0h 1m21s 5.8% words/sec/thread: 142947 lr: 0.047119 avg.loss: 2.067106 ETA: 0h 1m17s 40.1% words/sec/thread: 171668 lr: 0.029955 avg.loss: 1.799834 ETA: 0h 0m40s 44.9% words/sec/thread: 171473 lr: 0.027573 avg.loss: 1.798662 ETA: 0h 0m37s 45.2% words/sec/thread: 171723 lr: 0.027391 avg.loss: 1.798120 ETA: 0h 0m37s 49.4% words/sec/thread: 174142 lr: 0.025321 avg.loss: 1.796268 ETA: 0h 0m34s% words/sec/thread: 175123 lr: 0.018224 avg.loss: 1.791918 ETA: 0h 0m24s175735 lr: 0.012875 avg.loss: 1.778294 ETA: 0h 0m17s 81.4% words/sec/thread: 178726 lr: 0.009277 avg.loss: 1.783262 ETA: 0h 0m12s 93.1% words/sec/thread: 184516 lr: 0.003451 avg.loss: 1.757863 ETA: 0h 0m 4s 93.9% words/sec/thread: 184912 lr: 0.003029 avg.loss: 1.755565 ETA: 0h 0m 3s 99.7% words/sec/thread: 187503 lr: 0.000170 avg.loss: 1.744614 ETA: 0h 0m 0s" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 6min 16s, sys: 2.75 s, total: 6min 19s\n", - "Wall time: 39.9 s\n" + "CPU times: user 6min 10s, sys: 5.4 s, total: 6min 16s\n", + "Wall time: 2min 50s\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r\n", + "Progress: 100.0% words/sec/thread: 187530 lr: -0.000000 avg.loss: 1.744667 ETA: 0h 0m 0s\r\n", + "Progress: 100.0% words/sec/thread: 187529 lr: 0.000000 avg.loss: 1.744667 ETA: 0h 0m 0s\n" ] } ], @@ -215,7 +245,7 @@ { "data": { "text/plain": [ - "array([-0.06952401, 0.34956253, -1.7137849 , -1.0474566 , 0.06292222],\n", + "array([-1.5538737 , -0.27101302, 0.41967082, -0.797175 , 0.45186338],\n", " dtype=float32)" ] }, @@ -257,10 +287,11 @@ "name": "stdout", "output_type": "stream", "text": [ - "total 579968\r\n", - "-rw-r--r-- 1 aguschin staff 132M May 27 12:21 cbow.model\r\n", - "-rw-r--r-- 1 aguschin staff 42M May 27 12:21 skipgram.model\r\n", - "-rw-r--r-- 1 aguschin staff 83M May 27 12:21 skipgram2.model\r\n" + "total 2190872\r\n", + "-rw-r--r-- 1 olegpolivin staff 787M Jun 10 14:47 2021_06_05_processed.model\r\n", + "-rw-r--r-- 1 olegpolivin staff 132M Nov 9 00:03 cbow.model\r\n", + "-rw-r--r-- 1 olegpolivin staff 42M Nov 9 00:03 skipgram.model\r\n", + "-rw-r--r-- 1 olegpolivin staff 83M Nov 9 00:03 skipgram2.model\r\n" ] } ], @@ -309,7 +340,7 @@ "output_type": "stream", "text": [ "['work', 'discontent', 'probably:', 'lopid', 'gives', 'putty', 'refund', 'strangest', 'enuff', 'inovative']\n", - "['bars;', 'earnings', 'appellate', 'discoverd', 'phage']\n" + "{'word_list': ['bars;', 'earnings', 'appellate', 'discoverd', 'phage'], 'time': 1.49043, 'code': 200}\n" ] } ], @@ -332,8 +363,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "['interstate', 'robust,', 'shadow', 'one),', 'removes', 'dime', \"driver's\", 'fills.', 'drawing.', 'mice.']\n", - "['forefront', '[some', 'acoustic', 'concertina', 'press.']\n" + "['outlets.', 'outlets,', 'moot', 'perm', 'floating', 'fixing', 'PMP', 'suspension,', 'labels,', 'expensive']\n", + "{'word_list': ['et.', '+|>', 'skeletons', 'echoes', 'nn'], 'time': 0, 'code': 200}\n" ] } ], @@ -352,7 +383,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": { "scrolled": false }, @@ -368,91 +399,91 @@ "===ROUND 1===\n", "\n", "HOST: ['dings']\n", - "GUESSING PLAYER (skipgram team) to HOST: ['(long', 'orbiter', 'Pluto', 'surges', 'Titan']\n", + "GUESSING PLAYER (skipgram2 team) to HOST: ['headings', 'joints', 'astronauts.', 'launchers.', 'launchers']\n", "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['headings', 'windings', 'marks', 'joints', 'standings']\n", + "GUESSING PLAYER (skipgram team) to HOST: ['probes', 'es', 'steroid', 'extern', 'district']\n", "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['earnings', 'headings', 'copayments', 'segments', '>parts']\n", + "GUESSING PLAYER (cbow team) to HOST: ['headings', 'earnings', 'stunts', 'hinges', 'rings']\n", "HOST: False\n", "\n", "===ROUND 2===\n", "\n", "HOST: ['dings', 'near']\n", - "GUESSING PLAYER (skipgram team) to HOST: ['carbon,', 'Torx', \"Mercury's\", 'Upon', 'Driving']\n", + "GUESSING PLAYER (skipgram2 team) to HOST: ['launchers', 'rocket', 'plaques', 'windings', 'landings,']\n", "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['landings,', 'plotted', 'windings', 'ounces', 'close-up']\n", + "GUESSING PLAYER (skipgram team) to HOST: ['airport', 'Moon,', '(west', 'launched', 'coast']\n", "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['breakfasts', 'fielding', 'machbanding', 'colliding', 'centering']\n", + "GUESSING PLAYER (cbow team) to HOST: ['colliding', 'buildings,', 'fielding', 'delivering', 'buildings']\n", "HOST: False\n", "\n", "===ROUND 3===\n", "\n", "HOST: ['dings', 'near', 'pellets']\n", - "GUESSING PLAYER (skipgram team) to HOST: ['80%', 'tours', 'navy', 'rosters', 'drills']\n", + "GUESSING PLAYER (skipgram2 team) to HOST: ['\"SCHWARZENEGGER\"', 'housekeeping', '(carrying', 'navy', 'lanterns.']\n", "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['\"tail', 'ceiling', 'turnaround', 'shrine', \"'center\"]\n", + "GUESSING PLAYER (skipgram team) to HOST: ['2.5million', 'gland', 'IgA', 'Five', 'actor']\n", "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['putouts', 'arrives', 'hotels', 'fronts', 'stacks']\n", + "GUESSING PLAYER (cbow team) to HOST: ['putouts', 'stacks', 'puts', 'hotels', 'bulletins']\n", "HOST: False\n", "\n", "===ROUND 4===\n", "\n", "HOST: ['dings', 'near', 'pellets', 'prelude']\n", - "GUESSING PLAYER (skipgram team) to HOST: ['chapter.', 'lawnmower', '>4.', 'pulsars,', '12-story']\n", + "GUESSING PLAYER (skipgram2 team) to HOST: ['\"SCHWARZENEGGER\"', '>rules', 'barracks', 'parachute', 'F-holder']\n", "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: [\"'center\", 'remainder,', '\"C\"', '\"tail', '\"SCHWARZENEGGER\"']\n", + "GUESSING PLAYER (skipgram team) to HOST: ['RBC', '\"SCHWARZENEGGER\"', '>Niles', 'Passenger', 'Losing']\n", "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['collect', 'snide', 'cyanide', 'handheld', 'spy']\n", + "GUESSING PLAYER (cbow team) to HOST: [\"infringed.'\", 'disclose', 'brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza', 'diarrhea', 'elephant']\n", "HOST: False\n", "\n", "===ROUND 5===\n", "\n", "HOST: ['dings', 'near', 'pellets', 'prelude', 'th']\n", - "GUESSING PLAYER (skipgram team) to HOST: ['Thing,', 'leader????', 'pulsars,', 'DJ>', '\"Power']\n", + "GUESSING PLAYER (skipgram2 team) to HOST: ['tinnitus', 'parachute', 'kc>', 'F-holder', 'Scandinavians']\n", "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: [\"'center\", '\"SCHWARZENEGGER\"', '>center', 'F-holder', 'remainder,']\n", + "GUESSING PLAYER (skipgram team) to HOST: ['spectacular,', 'Losing', 'later),', 'mins', \"'Karla',\"]\n", "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['tackle', 'spy', 'cyanide', 'mass-market', 'sunlight']\n", + "GUESSING PLAYER (cbow team) to HOST: ['shortcomings', 'colliding', 'barehanded', 'syringe', 'barracks']\n", "HOST: False\n", "\n", "===ROUND 6===\n", "\n", "HOST: ['dings', 'near', 'pellets', 'prelude', 'th', 'ammo']\n", - "GUESSING PLAYER (skipgram team) to HOST: ['summer?', 'Thing,', 'spectacular,', 'pulsars,', 'tradeoff']\n", + "GUESSING PLAYER (skipgram2 team) to HOST: ['\"SCHWARZENEGGER\"', 'turbocharged', 'housekeeping', 'gallon', 'Oxygen']\n", "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: [\"'center\", 'greenhouse', '\"tail', '\"SCHWARZENEGGER\"', 'remainder,']\n", + "GUESSING PLAYER (skipgram team) to HOST: ['later),', 'Pentagon', 'plywood/carpet', '>>Red', 'spectacular,']\n", "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['cyanide', 'sunlight', 'control...', 'tackle', 'brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza']\n", + "GUESSING PLAYER (cbow team) to HOST: ['shortcomings', \"infringed.'\", 'diarrhea', 'disclose', 'deluxe']\n", "HOST: False\n", "\n", "===ROUND 7===\n", "\n", "HOST: ['dings', 'near', 'pellets', 'prelude', 'th', 'ammo', 'calibre']\n", - "GUESSING PLAYER (skipgram team) to HOST: ['110V,', '>both', '(3),', 'tuberculosis', 'brochure']\n", + "GUESSING PLAYER (skipgram2 team) to HOST: ['turbocharged', 'barbeque', 'landmark', 'MR\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+', 'tailgate']\n", "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['blackout', 'greenhouse', 'flashers.', 'remainder,', '\"C\"']\n", + "GUESSING PLAYER (skipgram team) to HOST: ['later;', 'close-out', 'Pentagon', 'Caps,', 'IVF-ET']\n", "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['control...', 'mass-market', '>risk', 'blasphemous', 'control:']\n", + "GUESSING PLAYER (cbow team) to HOST: ['semi', 'deluxe', 'deploy', 'disclosure', 'disclose']\n", "HOST: False\n", "\n", "===ROUND 8===\n", "\n", "HOST: ['dings', 'near', 'pellets', 'prelude', 'th', 'ammo', 'calibre', 'mile']\n", - "GUESSING PLAYER (skipgram team) to HOST: ['(3),', '110V,', 'tuberculosis', '|is', 'brochure']\n", + "GUESSING PLAYER (skipgram2 team) to HOST: ['turbocharged', 'MR\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+', 'barbeque', 'landmark', 'tailgate']\n", "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['greenhouse', 'blackout', 'flashers.', 'remainder,', '\"C\"']\n", + "GUESSING PLAYER (skipgram team) to HOST: ['later;', 'IVF-ET', 'Euclidean', 'ndet_loop.c:687:', \"'Karla',\"]\n", "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['mass-market', 'seminar', 'inhibitor', 'target)', 'whitespace']\n", + "GUESSING PLAYER (cbow team) to HOST: ['deluxe', 'deploy', 'seminar', 'brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza', 'semi']\n", "HOST: False\n", "\n", "===ROUND 9===\n", "\n", "HOST: ['dings', 'near', 'pellets', 'prelude', 'th', 'ammo', 'calibre', 'mile', 'corollas']\n", - "GUESSING PLAYER (skipgram team) to HOST: ['\"SCHWARZENEGGER\"', 'Mars?', ':a', '(3),', 'Cavalier,']\n", + "GUESSING PLAYER (skipgram2 team) to HOST: ['turbocharged', 'MR\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+R\\\\O+', 'gallon', \"'B'\", 'axel']\n", "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['bingo', 'greenhouse', 'flashers.', 'fibreglass', 'Zodiacal']\n", + "GUESSING PLAYER (skipgram team) to HOST: ['km,', '\"Power', 'Hasbani', 'Euclidean', 'Mk']\n", "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza', 'mass-market', 'cyanide', 'transformer', 'karma']\n", + "GUESSING PLAYER (cbow team) to HOST: ['brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza', 'mass-market', 'bulletin', 'seminar', 'tin']\n", "HOST: False\n", "\n", "\n", @@ -481,8 +512,8 @@ " \n", " \n", " Explanation for \"billion\" (HerokuOrg team)\n", - " Guess (skipgram team)\n", " Guess (skipgram2 team)\n", + " Guess (skipgram team)\n", " Guess (cbow team)\n", " \n", " \n", @@ -490,65 +521,65 @@ " \n", " 0\n", " [dings]\n", - " [(long, orbiter, Pluto, surges, Titan]\n", - " [headings, windings, marks, joints, standings]\n", - " [earnings, headings, copayments, segments, >parts]\n", + " [headings, joints, astronauts., launchers., launchers]\n", + " [probes, es, steroid, extern, district]\n", + " [headings, earnings, stunts, hinges, rings]\n", " \n", " \n", " 1\n", " [dings, near]\n", - " [carbon,, Torx, Mercury's, Upon, Driving]\n", - " [landings,, plotted, windings, ounces, close-up]\n", - " [breakfasts, fielding, machbanding, colliding, centering]\n", + " [launchers, rocket, plaques, windings, landings,]\n", + " [airport, Moon,, (west, launched, coast]\n", + " [colliding, buildings,, fielding, delivering, buildings]\n", " \n", " \n", " 2\n", " [dings, near, pellets]\n", - " [80%, tours, navy, rosters, drills]\n", - " [\"tail, ceiling, turnaround, shrine, 'center]\n", - " [putouts, arrives, hotels, fronts, stacks]\n", + " [\"SCHWARZENEGGER\", housekeeping, (carrying, navy, lanterns.]\n", + " [2.5million, gland, IgA, Five, actor]\n", + " [putouts, stacks, puts, hotels, bulletins]\n", " \n", " \n", " 3\n", " [dings, near, pellets, prelude]\n", - " [chapter., lawnmower, >4., pulsars,, 12-story]\n", - " ['center, remainder,, \"C\", \"tail, \"SCHWARZENEGGER\"]\n", - " [collect, snide, cyanide, handheld, spy]\n", + " [\"SCHWARZENEGGER\", >rules, barracks, parachute, F-holder]\n", + " [RBC, \"SCHWARZENEGGER\", >Niles, Passenger, Losing]\n", + " [infringed.', disclose, brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza, diarrhea, elephant]\n", " \n", " \n", " 4\n", " [dings, near, pellets, prelude, th]\n", - " [Thing,, leader????, pulsars,, DJ>, \"Power]\n", - " ['center, \"SCHWARZENEGGER\", >center, F-holder, remainder,]\n", - " [tackle, spy, cyanide, mass-market, sunlight]\n", + " [tinnitus, parachute, kc>, F-holder, Scandinavians]\n", + " [spectacular,, Losing, later),, mins, 'Karla',]\n", + " [shortcomings, colliding, barehanded, syringe, barracks]\n", " \n", " \n", " 5\n", " [dings, near, pellets, prelude, th, ammo]\n", - " [summer?, Thing,, spectacular,, pulsars,, tradeoff]\n", - " ['center, greenhouse, \"tail, \"SCHWARZENEGGER\", remainder,]\n", - " [cyanide, sunlight, control..., tackle, brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza]\n", + " [\"SCHWARZENEGGER\", turbocharged, housekeeping, gallon, Oxygen]\n", + " [later),, Pentagon, plywood/carpet, >>Red, spectacular,]\n", + " [shortcomings, infringed.', diarrhea, disclose, deluxe]\n", " \n", " \n", " 6\n", " [dings, near, pellets, prelude, th, ammo, calibre]\n", - " [110V,, >both, (3),, tuberculosis, brochure]\n", - " [blackout, greenhouse, flashers., remainder,, \"C\"]\n", - " [control..., mass-market, >risk, blasphemous, control:]\n", + " [turbocharged, barbeque, landmark, MR\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+, tailgate]\n", + " [later;, close-out, Pentagon, Caps,, IVF-ET]\n", + " [semi, deluxe, deploy, disclosure, disclose]\n", " \n", " \n", " 7\n", " [dings, near, pellets, prelude, th, ammo, calibre, mile]\n", - " [(3),, 110V,, tuberculosis, |is, brochure]\n", - " [greenhouse, blackout, flashers., remainder,, \"C\"]\n", - " [mass-market, seminar, inhibitor, target), whitespace]\n", + " [turbocharged, MR\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+, barbeque, landmark, tailgate]\n", + " [later;, IVF-ET, Euclidean, ndet_loop.c:687:, 'Karla',]\n", + " [deluxe, deploy, seminar, brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza, semi]\n", " \n", " \n", " 8\n", " [dings, near, pellets, prelude, th, ammo, calibre, mile, corollas]\n", - " [\"SCHWARZENEGGER\", Mars?, :a, (3),, Cavalier,]\n", - " [bingo, greenhouse, flashers., fibreglass, Zodiacal]\n", - " [brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza, mass-market, cyanide, transformer, karma]\n", + " [turbocharged, MR\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+, gallon, 'B', axel]\n", + " [km,, \"Power, Hasbani, Euclidean, Mk]\n", + " [brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza, mass-market, bulletin, seminar, tin]\n", " \n", " \n", "\n", @@ -566,38 +597,38 @@ "7 [dings, near, pellets, prelude, th, ammo, calibre, mile] \n", "8 [dings, near, pellets, prelude, th, ammo, calibre, mile, corollas] \n", "\n", - " Guess (skipgram team) \\\n", - "0 [(long, orbiter, Pluto, surges, Titan] \n", - "1 [carbon,, Torx, Mercury's, Upon, Driving] \n", - "2 [80%, tours, navy, rosters, drills] \n", - "3 [chapter., lawnmower, >4., pulsars,, 12-story] \n", - "4 [Thing,, leader????, pulsars,, DJ>, \"Power] \n", - "5 [summer?, Thing,, spectacular,, pulsars,, tradeoff] \n", - "6 [110V,, >both, (3),, tuberculosis, brochure] \n", - "7 [(3),, 110V,, tuberculosis, |is, brochure] \n", - "8 [\"SCHWARZENEGGER\", Mars?, :a, (3),, Cavalier,] \n", + " Guess (skipgram2 team) \\\n", + "0 [headings, joints, astronauts., launchers., launchers] \n", + "1 [launchers, rocket, plaques, windings, landings,] \n", + "2 [\"SCHWARZENEGGER\", housekeeping, (carrying, navy, lanterns.] \n", + "3 [\"SCHWARZENEGGER\", >rules, barracks, parachute, F-holder] \n", + "4 [tinnitus, parachute, kc>, F-holder, Scandinavians] \n", + "5 [\"SCHWARZENEGGER\", turbocharged, housekeeping, gallon, Oxygen] \n", + "6 [turbocharged, barbeque, landmark, MR\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+, tailgate] \n", + "7 [turbocharged, MR\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+, barbeque, landmark, tailgate] \n", + "8 [turbocharged, MR\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+R\\O+, gallon, 'B', axel] \n", "\n", - " Guess (skipgram2 team) \\\n", - "0 [headings, windings, marks, joints, standings] \n", - "1 [landings,, plotted, windings, ounces, close-up] \n", - "2 [\"tail, ceiling, turnaround, shrine, 'center] \n", - "3 ['center, remainder,, \"C\", \"tail, \"SCHWARZENEGGER\"] \n", - "4 ['center, \"SCHWARZENEGGER\", >center, F-holder, remainder,] \n", - "5 ['center, greenhouse, \"tail, \"SCHWARZENEGGER\", remainder,] \n", - "6 [blackout, greenhouse, flashers., remainder,, \"C\"] \n", - "7 [greenhouse, blackout, flashers., remainder,, \"C\"] \n", - "8 [bingo, greenhouse, flashers., fibreglass, Zodiacal] \n", + " Guess (skipgram team) \\\n", + "0 [probes, es, steroid, extern, district] \n", + "1 [airport, Moon,, (west, launched, coast] \n", + "2 [2.5million, gland, IgA, Five, actor] \n", + "3 [RBC, \"SCHWARZENEGGER\", >Niles, Passenger, Losing] \n", + "4 [spectacular,, Losing, later),, mins, 'Karla',] \n", + "5 [later),, Pentagon, plywood/carpet, >>Red, spectacular,] \n", + "6 [later;, close-out, Pentagon, Caps,, IVF-ET] \n", + "7 [later;, IVF-ET, Euclidean, ndet_loop.c:687:, 'Karla',] \n", + "8 [km,, \"Power, Hasbani, Euclidean, Mk] \n", "\n", - " Guess (cbow team) \n", - "0 [earnings, headings, copayments, segments, >parts] \n", - "1 [breakfasts, fielding, machbanding, colliding, centering] \n", - "2 [putouts, arrives, hotels, fronts, stacks] \n", - "3 [collect, snide, cyanide, handheld, spy] \n", - "4 [tackle, spy, cyanide, mass-market, sunlight] \n", - "5 [cyanide, sunlight, control..., tackle, brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza] \n", - "6 [control..., mass-market, >risk, blasphemous, control:] \n", - "7 [mass-market, seminar, inhibitor, target), whitespace] \n", - "8 [brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza, mass-market, cyanide, transformer, karma] " + " Guess (cbow team) \n", + "0 [headings, earnings, stunts, hinges, rings] \n", + "1 [colliding, buildings,, fielding, delivering, buildings] \n", + "2 [putouts, stacks, puts, hotels, bulletins] \n", + "3 [infringed.', disclose, brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza, diarrhea, elephant] \n", + "4 [shortcomings, colliding, barehanded, syringe, barracks] \n", + "5 [shortcomings, infringed.', diarrhea, disclose, deluxe] \n", + "6 [semi, deluxe, deploy, disclosure, disclose] \n", + "7 [deluxe, deploy, seminar, brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza, semi] \n", + "8 [brownbladerunnersugarcubeselectronicblaylockpowersspikeleekatebushhamcornpizza, mass-market, bulletin, seminar, tin] " ] }, "metadata": {}, @@ -607,571 +638,14 @@ "name": "stderr", "output_type": "stream", "text": [ - "HOST to EXPLAINING PLAYER (skipgram team): the word is \"money\"\n", - "EXPLAINING PLAYER (skipgram team) to HOST: my wordlist is ['cleanest', 'closely.', 'frustrating', 'diet,', 'constantly.', 'visible,', 'aiming', 'counter.', 'noise.', 'chant']\n", - "HOST TO EXPLAINING PLAYER (skipgram team): cleaning your word list. Now the list is ['cleanest', 'closely', 'frustrating', 'diet', 'constantly', 'visible', 'aiming', 'counter', 'noise', 'chant']\n", + "HOST to EXPLAINING PLAYER (skipgram2 team): the word is \"money\"\n", + "EXPLAINING PLAYER (skipgram2 team) to HOST: my wordlist is ['taxes.', 'pay.', 'paying', 'money.', 'spend', 'spending.', 'guards', 'insure', 'pay', 'bank.']\n", + "HOST TO EXPLAINING PLAYER (skipgram2 team): cleaning your word list. Now the list is ['taxes', 'pay', 'paying', 'spend', 'spending', 'guards', 'insure', 'bank']\n", "\n", "===ROUND 1===\n", "\n", - "HOST: ['cleanest']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['cleanest', 'easing', 'blocking', 'flattery', 'flattering']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['cleanly', 'constantly.', 'x-rays', 'unused', 'constantly,']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['weakest', 'cleanse', 'closest', 'template', 'seal']\n", - "HOST: False\n", - "\n", - "===ROUND 2===\n", - "\n", - "HOST: ['cleanest', 'closely']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['>cases', 'disposable', 'reconditioned', 'damaging', 'visions']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['scenarios', 'apparently', '>>also', 'liscenced', 'successful,']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['invisible', 'desperately', 'closely', 'visible', 'hideous']\n", - "HOST: False\n", - "\n", - "===ROUND 3===\n", - "\n", - "HOST: ['cleanest', 'closely', 'frustrating']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['prongs', '>>>the', 'parting', 'arcing', '>figures']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['eliminated.', 'goodies', 'memorize', 'discover', 'most.']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['frustrating', 'abroad', 'dismantling', 'exaggerating', 'concentrating']\n", - "HOST: False\n", - "\n", - "===ROUND 4===\n", - "\n", - "HOST: ['cleanest', 'closely', 'frustrating', 'diet']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['visions', 'floggings', 'smuggled', 'safe', 'legalizing']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['2%.', 'spectacle', 'goodies', 'eliminated.', 'many).']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['abroad', 'passive-aggressive', 'eliminate', 'brightest', 'cleansing\"']\n", - "HOST: False\n", - "\n", - "===ROUND 5===\n", - "\n", - "HOST: ['cleanest', 'closely', 'frustrating', 'diet', 'constantly']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['>>>two', 'arcing', 'floggings', 'smuggled', 'remedy']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['goodies', 'x-rays', 'one-half', 'many).', 'successful,']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['abroad', 'torture', 'desperately', 'incontrovertibly', 'prolong']\n", - "HOST: False\n", - "\n", - "===ROUND 6===\n", - "\n", - "HOST: ['cleanest', 'closely', 'frustrating', 'diet', 'constantly', 'visible']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['smuggled', 'safe', 'legalizing', 'arcing', 'trapping']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['goodies', 'x-rays', '2%.', 'one-half', 'successful,']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['passive-aggressive', 'intrusive', 'incontrovertibly', 'invisible', 'abroad']\n", - "HOST: False\n", - "\n", - "===ROUND 7===\n", - "\n", - "HOST: ['cleanest', 'closely', 'frustrating', 'diet', 'constantly', 'visible', 'aiming']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['comb', '>>>two', 'smuggled', 'arcing', '>pay']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['x-rays', 'goodies', '>(which', '>>>a', '2%.']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['dismantling', 'concentrating', 'cleansing\"', 'abroad', 'exaggerating']\n", - "HOST: False\n", - "\n", - "===ROUND 8===\n", - "\n", - "HOST: ['cleanest', 'closely', 'frustrating', 'diet', 'constantly', 'visible', 'aiming', 'counter']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['parting', 'arcing', 'comb', '>>>two', 'than']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['one-half', 'goodies', 'x-rays', 'JFK', 'EKG']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['abroad', 'torture', 'hand-held', 'seminar', 'passive-aggressive']\n", - "HOST: False\n", - "\n", - "===ROUND 9===\n", - "\n", - "HOST: ['cleanest', 'closely', 'frustrating', 'diet', 'constantly', 'visible', 'aiming', 'counter', 'noise']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['parting', 'legit', 'spit', 'prongs', '>figures']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['one-half', 'JFK', 'x-rays', 'CJF>', 'goodies']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['abroad', 'torture', 'passive-aggressive', 'furniture', 'seminar']\n", - "HOST: False\n", - "\n", - "===ROUND 10===\n", - "\n", - "HOST: ['cleanest', 'closely', 'frustrating', 'diet', 'constantly', 'visible', 'aiming', 'counter', 'noise', 'chant']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['comb', '>pay', 'outweighs', '>>>two', 'pains']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['one-half', 'JFK', 'CJF>', 'many).', 'goodies']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['abroad', 'torture', 'passive-aggressive', 'seminar', 'surpass']\n", - "HOST: False\n", - "\n", - "\n", - "SCORES: {'skipgram team': 0}\n" + "HOST: ['taxes']\n" ] - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
Explanation for \"money\" (skipgram team)Guess (HerokuOrg team)Guess (skipgram2 team)Guess (cbow team)
0[cleanest][cleanest, easing, blocking, flattery, flattering][cleanly, constantly., x-rays, unused, constantly,][weakest, cleanse, closest, template, seal]
1[cleanest, closely][>cases, disposable, reconditioned, damaging, visions][scenarios, apparently, >>also, liscenced, successful,][invisible, desperately, closely, visible, hideous]
2[cleanest, closely, frustrating][prongs, >>>the, parting, arcing, >figures][eliminated., goodies, memorize, discover, most.][frustrating, abroad, dismantling, exaggerating, concentrating]
3[cleanest, closely, frustrating, diet][visions, floggings, smuggled, safe, legalizing][2%., spectacle, goodies, eliminated., many).][abroad, passive-aggressive, eliminate, brightest, cleansing\"]
4[cleanest, closely, frustrating, diet, constantly][>>>two, arcing, floggings, smuggled, remedy][goodies, x-rays, one-half, many)., successful,][abroad, torture, desperately, incontrovertibly, prolong]
5[cleanest, closely, frustrating, diet, constantly, visible][smuggled, safe, legalizing, arcing, trapping][goodies, x-rays, 2%., one-half, successful,][passive-aggressive, intrusive, incontrovertibly, invisible, abroad]
6[cleanest, closely, frustrating, diet, constantly, visible, aiming][comb, >>>two, smuggled, arcing, >pay][x-rays, goodies, >(which, >>>a, 2%.][dismantling, concentrating, cleansing\", abroad, exaggerating]
7[cleanest, closely, frustrating, diet, constantly, visible, aiming, counter][parting, arcing, comb, >>>two, than][one-half, goodies, x-rays, JFK, EKG][abroad, torture, hand-held, seminar, passive-aggressive]
8[cleanest, closely, frustrating, diet, constantly, visible, aiming, counter, noise][parting, legit, spit, prongs, >figures][one-half, JFK, x-rays, CJF>, goodies][abroad, torture, passive-aggressive, furniture, seminar]
9[cleanest, closely, frustrating, diet, constantly, visible, aiming, counter, noise, chant][comb, >pay, outweighs, >>>two, pains][one-half, JFK, CJF>, many)., goodies][abroad, torture, passive-aggressive, seminar, surpass]
\n", - "
" - ], - "text/plain": [ - " Explanation for \"money\" (skipgram team) \\\n", - "0 [cleanest] \n", - "1 [cleanest, closely] \n", - "2 [cleanest, closely, frustrating] \n", - "3 [cleanest, closely, frustrating, diet] \n", - "4 [cleanest, closely, frustrating, diet, constantly] \n", - "5 [cleanest, closely, frustrating, diet, constantly, visible] \n", - "6 [cleanest, closely, frustrating, diet, constantly, visible, aiming] \n", - "7 [cleanest, closely, frustrating, diet, constantly, visible, aiming, counter] \n", - "8 [cleanest, closely, frustrating, diet, constantly, visible, aiming, counter, noise] \n", - "9 [cleanest, closely, frustrating, diet, constantly, visible, aiming, counter, noise, chant] \n", - "\n", - " Guess (HerokuOrg team) \\\n", - "0 [cleanest, easing, blocking, flattery, flattering] \n", - "1 [>cases, disposable, reconditioned, damaging, visions] \n", - "2 [prongs, >>>the, parting, arcing, >figures] \n", - "3 [visions, floggings, smuggled, safe, legalizing] \n", - "4 [>>>two, arcing, floggings, smuggled, remedy] \n", - "5 [smuggled, safe, legalizing, arcing, trapping] \n", - "6 [comb, >>>two, smuggled, arcing, >pay] \n", - "7 [parting, arcing, comb, >>>two, than] \n", - "8 [parting, legit, spit, prongs, >figures] \n", - "9 [comb, >pay, outweighs, >>>two, pains] \n", - "\n", - " Guess (skipgram2 team) \\\n", - "0 [cleanly, constantly., x-rays, unused, constantly,] \n", - "1 [scenarios, apparently, >>also, liscenced, successful,] \n", - "2 [eliminated., goodies, memorize, discover, most.] \n", - "3 [2%., spectacle, goodies, eliminated., many).] \n", - "4 [goodies, x-rays, one-half, many)., successful,] \n", - "5 [goodies, x-rays, 2%., one-half, successful,] \n", - "6 [x-rays, goodies, >(which, >>>a, 2%.] \n", - "7 [one-half, goodies, x-rays, JFK, EKG] \n", - "8 [one-half, JFK, x-rays, CJF>, goodies] \n", - "9 [one-half, JFK, CJF>, many)., goodies] \n", - "\n", - " Guess (cbow team) \n", - "0 [weakest, cleanse, closest, template, seal] \n", - "1 [invisible, desperately, closely, visible, hideous] \n", - "2 [frustrating, abroad, dismantling, exaggerating, concentrating] \n", - "3 [abroad, passive-aggressive, eliminate, brightest, cleansing\"] \n", - "4 [abroad, torture, desperately, incontrovertibly, prolong] \n", - "5 [passive-aggressive, intrusive, incontrovertibly, invisible, abroad] \n", - "6 [dismantling, concentrating, cleansing\", abroad, exaggerating] \n", - "7 [abroad, torture, hand-held, seminar, passive-aggressive] \n", - "8 [abroad, torture, passive-aggressive, furniture, seminar] \n", - "9 [abroad, torture, passive-aggressive, seminar, surpass] " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "HOST to EXPLAINING PLAYER (skipgram2 team): the word is \"percent\"\n", - "EXPLAINING PLAYER (skipgram2 team) to HOST: my wordlist is ['percent.', 'percent,', 'civic', 'mixture', '7.3', 'mixture,', '20-39', '7.3.', 'temper', '42%']\n", - "HOST TO EXPLAINING PLAYER (skipgram2 team): cleaning your word list. Now the list is ['civic', 'mixture', 'temper']\n", - "\n", - "===ROUND 1===\n", - "\n", - "HOST: ['civic']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['civic', 'o-rings', '2-3', 'hotdogs', 'breeze']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram team) to HOST: ['pregnancy.', 'accidental,', 'hospital.', 'froze', 'bleachers']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['pelvic', 'approximately']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram team) to HOST: ['deadline', '15-day', 'Goering', 'attendance', 'circles']\n", - "HOST: False\n", - "GUESSING PLAYER (cbow team) to HOST: ['polynomial', 'symposium', 'titanium', 'temperature', 'fatal']\n", - "HOST: False\n", - "\n", - "\n", - "SCORES: {'skipgram2 team': 0}\n" - ] - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
Explanation for \"percent\" (skipgram2 team)Guess (HerokuOrg team)Guess (skipgram team)Guess (cbow team)
0[civic][civic, o-rings, 2-3, hotdogs, breeze][pregnancy., accidental,, hospital., froze, bleachers][pelvic, <of, perpetual, civil, civility]
1[civic, mixture][chassis, yielding, loaner, averaging, light\"][cocktail, (carrying, Oilers., gravel, parachute][homicides/population, population!, population, chromaticity, civility]
2[civic, mixture, temper][subway, $2-billion, 80%, interstates, >approximately][deadline, 15-day, Goering, attendance, circles][polynomial, symposium, titanium, temperature, fatal]
\n", - "
" - ], - "text/plain": [ - " Explanation for \"percent\" (skipgram2 team) \\\n", - "0 [civic] \n", - "1 [civic, mixture] \n", - "2 [civic, mixture, temper] \n", - "\n", - " Guess (HerokuOrg team) \\\n", - "0 [civic, o-rings, 2-3, hotdogs, breeze] \n", - "1 [chassis, yielding, loaner, averaging, light\"] \n", - "2 [subway, $2-billion, 80%, interstates, >approximately] \n", - "\n", - " Guess (skipgram team) \\\n", - "0 [pregnancy., accidental,, hospital., froze, bleachers] \n", - "1 [cocktail, (carrying, Oilers., gravel, parachute] \n", - "2 [deadline, 15-day, Goering, attendance, circles] \n", - "\n", - " Guess (cbow team) \n", - "0 [pelvic, million']\n", - "HOST TO EXPLAINING PLAYER (cbow team): cleaning your word list. Now the list is ['pillion', 'trillion', 'billion', 'bills', 'zillion', 'million']\n", - "\n", - "===ROUND 1===\n", - "\n", - "HOST: ['pillion']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['pillion', 'crawl', 'ouch', 'gloves', 'players:']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram team) to HOST: ['slid', 'lock,', 'inch.', 'wheel,', 'bikes']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['deck,', 'nd', '(how', 'pockets', 'ticks']\n", - "HOST: False\n", - "\n", - "===ROUND 2===\n", - "\n", - "HOST: ['pillion', 'trillion']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['showroom', 'saddle', 'chatter', 'headline', 'spot']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram team) to HOST: ['nanosecond,', '4-door', 'scoreboard', 'Too', 'strobe']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['pigs', 'all-round', 'towers', '20-30', '>both']\n", - "HOST: False\n", - "\n", - "===ROUND 3===\n", - "\n", - "HOST: ['pillion', 'trillion', 'billion']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['ranged', 'lighters', 'dining', 'cruiser', 'seating']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram team) to HOST: ['finals,', 'bolts', 'walkman', 'Saab', 'Saturn.']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['billion.', '$1billion', 'zillion', 'pigs', 'all-round']\n", - "HOST: False\n", - "\n", - "===ROUND 4===\n", - "\n", - "HOST: ['pillion', 'trillion', 'billion', 'bills']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['boiler', 'taxi', 'bracelet', 'road;', 'overhauled']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram team) to HOST: ['line:', '2-door', 'sedan,', 'gimick,', 'turnaround']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['all-round', '>both', 'goons', 'breakaway', 'With']\n", - "HOST: False\n", - "\n", - "===ROUND 5===\n", - "\n", - "HOST: ['pillion', 'trillion', 'billion', 'bills', 'zillion']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['opening', 'bracelet', 'gearing', 'fire-breathing', 'folds']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram team) to HOST: ['2-door', 'eg', 'Thing.', 'line:', 'Saab']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['billion.', '>both', '$1billion', 'zillion', 'all-round']\n", - "HOST: False\n", - "\n", - "===ROUND 6===\n", - "\n", - "HOST: ['pillion', 'trillion', 'billion', 'bills', 'zillion', 'million']\n", - "GUESSING PLAYER (HerokuOrg team) to HOST: ['bracelet', 'paced', 'opening', 'casings', 'week']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram team) to HOST: ['guitar', 'Thing.', 'Turns', 'line:', 'turnaround']\n", - "HOST: False\n", - "GUESSING PLAYER (skipgram2 team) to HOST: ['zillion', '700.000', 'breakaway', 'billion.', '$1billion']\n", - "HOST: False\n", - "\n", - "\n", - "SCORES: {'cbow team': 0}\n" - ] - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
Explanation for \"dollar\" (cbow team)Guess (HerokuOrg team)Guess (skipgram team)Guess (skipgram2 team)
0[pillion][pillion, crawl, ouch, gloves, players:][slid, lock,, inch., wheel,, bikes][deck,, nd, (how, pockets, ticks]
1[pillion, trillion][showroom, saddle, chatter, headline, spot][nanosecond,, 4-door, scoreboard, Too, strobe][pigs, all-round, towers, 20-30, >both]
2[pillion, trillion, billion][ranged, lighters, dining, cruiser, seating][finals,, bolts, walkman, Saab, Saturn.][billion., $1billion, zillion, pigs, all-round]
3[pillion, trillion, billion, bills][boiler, taxi, bracelet, road;, overhauled][line:, 2-door, sedan,, gimick,, turnaround][all-round, >both, goons, breakaway, With]
4[pillion, trillion, billion, bills, zillion][opening, bracelet, gearing, fire-breathing, folds][2-door, eg, Thing., line:, Saab][billion., >both, $1billion, zillion, all-round]
5[pillion, trillion, billion, bills, zillion, million][bracelet, paced, opening, casings, week][guitar, Thing., Turns, line:, turnaround][zillion, 700.000, breakaway, billion., $1billion]
\n", - "
" - ], - "text/plain": [ - " Explanation for \"dollar\" (cbow team) \\\n", - "0 [pillion] \n", - "1 [pillion, trillion] \n", - "2 [pillion, trillion, billion] \n", - "3 [pillion, trillion, billion, bills] \n", - "4 [pillion, trillion, billion, bills, zillion] \n", - "5 [pillion, trillion, billion, bills, zillion, million] \n", - "\n", - " Guess (HerokuOrg team) \\\n", - "0 [pillion, crawl, ouch, gloves, players:] \n", - "1 [showroom, saddle, chatter, headline, spot] \n", - "2 [ranged, lighters, dining, cruiser, seating] \n", - "3 [boiler, taxi, bracelet, road;, overhauled] \n", - "4 [opening, bracelet, gearing, fire-breathing, folds] \n", - "5 [bracelet, paced, opening, casings, week] \n", - "\n", - " Guess (skipgram team) \\\n", - "0 [slid, lock,, inch., wheel,, bikes] \n", - "1 [nanosecond,, 4-door, scoreboard, Too, strobe] \n", - "2 [finals,, bolts, walkman, Saab, Saturn.] \n", - "3 [line:, 2-door, sedan,, gimick,, turnaround] \n", - "4 [2-door, eg, Thing., line:, Saab] \n", - "5 [guitar, Thing., Turns, line:, turnaround] \n", - "\n", - " Guess (skipgram2 team) \n", - "0 [deck,, nd, (how, pockets, ticks] \n", - "1 [pigs, all-round, towers, 20-30, >both] \n", - "2 [billion., $1billion, zillion, pigs, all-round] \n", - "3 [all-round, >both, goons, breakaway, With] \n", - "4 [billion., >both, $1billion, zillion, all-round] \n", - "5 [zillion, 700.000, breakaway, billion., $1billion] " - ] - }, - "metadata": {}, - "output_type": "display_data" } ], "source": [ @@ -1202,185 +676,20 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "=== Team scores in each game ===\n" - ] - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
HerokuOrg teamskipgram teamskipgram2 teamcbow team
game
00.00.00.00.0
10.00.00.00.0
20.00.00.00.0
30.00.00.00.0
\n", - "
" - ], - "text/plain": [ - " HerokuOrg team skipgram team skipgram2 team cbow team\n", - "game \n", - "0 0.0 0.0 0.0 0.0\n", - "1 0.0 0.0 0.0 0.0\n", - "2 0.0 0.0 0.0 0.0\n", - "3 0.0 0.0 0.0 0.0" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "=== Team scores, summary ===\n" - ] - }, - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
explainingguessingtotal
HerokuOrg team000.0
cbow team000.0
skipgram team000.0
skipgram2 team000.0
\n", - "
" - ], - "text/plain": [ - " explaining guessing total\n", - "HerokuOrg team 0 0 0.0\n", - "cbow team 0 0 0.0\n", - "skipgram team 0 0 0.0\n", - "skipgram2 team 0 0 0.0" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "game.report_results(each_game=True)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { + "interpreter": { + "hash": "f12fbffe58efe8e6061d3a78c38aa10df599e2b27c9fdd1f2495d635fc409b3e" + }, "kernelspec": { - "display_name": "Python 3", - "language": "python", + "display_name": "Python 3.8.5 64-bit ('hatgame': conda)", "name": "python3" }, "language_info": { diff --git a/flask_app/app.json b/flask_app/app.json index 7542cb5..8abbcbf 100644 --- a/flask_app/app.json +++ b/flask_app/app.json @@ -4,4 +4,3 @@ "repository": "https://github.com/production-ml/the-hat-game", "keywords": ["hat-game", "machine-learning", "software-engineering"] } - \ No newline at end of file diff --git a/flask_app/app.py b/flask_app/app.py index 3a04439..7aea78b 100644 --- a/flask_app/app.py +++ b/flask_app/app.py @@ -3,7 +3,6 @@ import random from flask import Flask, render_template, request - from player import LocalDummyPlayer app = Flask(__name__) diff --git a/flask_app/player.py b/flask_app/player.py index e866a21..367fa99 100644 --- a/flask_app/player.py +++ b/flask_app/player.py @@ -18,3 +18,20 @@ def explain(self, word, n_words): def guess(self, words, n_words): return "I guess it's a word, but don't have any idea which one!".split()[:n_words] + + +class LocalFasttextPlayer(AbstractPlayer): + def __init__(self, model): + self.model = model + + def find_words_for_sentence(self, sentence, n_closest): + neighbours = self.model.get_nearest_neighbors(sentence) + words = [word for similariry, word in neighbours][:n_closest] + return words + + def explain(self, word, n_words): + return self.find_words_for_sentence(word, n_words) + + def guess(self, words, n_words): + words_for_sentence = self.find_words_for_sentence(" ".join(words), n_words) + return words_for_sentence diff --git a/run_game.py b/run_game.py index 432bb8e..062c101 100644 --- a/run_game.py +++ b/run_game.py @@ -8,13 +8,18 @@ import numpy as np import pandas as pd -from data.utils import upload_blob -from settings import BUCKET_LOGS, CRITERIA, N_EXPLAIN_WORDS, N_GUESSING_WORDS, VOCAB_PATH +from flask_app.player import LocalDummyPlayer, LocalFasttextPlayer # noqa: F401 +from settings import CRITERIA, GAME_SCOPE, N_EXPLAIN_WORDS, N_GUESSING_WORDS from the_hat_game.game import Game -from the_hat_game.google import get_players from the_hat_game.loggers import logger from the_hat_game.players import PlayerDefinition, RemotePlayer +if GAME_SCOPE == "GLOBAL": + from settings_server import GLOBAL_VOCAB_PATH as VOCAB_PATH +else: + from settings import LOCAL_VOCAB_PATH as VOCAB_PATH + + if __name__ == "__main__": # # read all words @@ -48,12 +53,19 @@ WORDS.extend(words) print(f"Words we will use for the game: {sorted(WORDS)[:10]}") - data = get_players() + if GAME_SCOPE == "GLOBAL": + from server.players import get_global_players - players = [ - PlayerDefinition(row["Team name"], RemotePlayer(row["Team IP or URL (with port if necessary)"])) - for i, row in data.iterrows() - ] + players = get_global_players() + else: + players = [] # [...manually defined list...] + # Example: + player = LocalDummyPlayer() + players = [ + PlayerDefinition("HerokuOrg team", RemotePlayer("https://obscure-everglades-02893.herokuapp.com")), + # PlayerDefinition('Your trained remote player', RemotePlayer('http://35.246.139.13/')), + PlayerDefinition("Local Player", player), + ] # shuffle players np.random.shuffle(players) @@ -75,7 +87,11 @@ game.report_results() print(f"Game started at {game_start}. Game lasted for {game_end - game_start}") - upload_blob(BUCKET_LOGS, logfile, str(Path(logfile).name)) + if GAME_SCOPE == "GLOBAL": + from server.data import upload_blob + from settings_server import BUCKET_LOGS + + upload_blob(BUCKET_LOGS, logfile, str(Path(logfile).name)) logger.removeHandler(single_handler) diff --git a/run_text_update.py b/run_text_update.py index c48398e..8d65eae 100644 --- a/run_text_update.py +++ b/run_text_update.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta from time import sleep -from data.utils import add_new_text +from server.data import add_new_text def main(): diff --git a/data/__init__.py b/server/__init__.py similarity index 100% rename from data/__init__.py rename to server/__init__.py diff --git a/data/utils.py b/server/data.py similarity index 97% rename from data/utils.py rename to server/data.py index 3b5dcae..707a220 100644 --- a/data/utils.py +++ b/server/data.py @@ -14,7 +14,9 @@ from nltk.tokenize import word_tokenize from tqdm.auto import tqdm -from settings import BUCKET_DAILY, BUCKET_SPLIT_TEXTS, DATA_PATH, STORAGE_CLIENT, VOCAB_PATH +from settings_server import BUCKET_DAILY, BUCKET_SPLIT_TEXTS, DATA_PATH +from settings_server import GLOBAL_VOCAB_PATH as VOCAB_PATH +from settings_server import STORAGE_CLIENT STOP_WORDS = stopwords.words("english") LEMMATIZER = WordNetLemmatizer() diff --git a/the_hat_game/google.py b/server/players.py similarity index 52% rename from the_hat_game/google.py rename to server/players.py index 87e19bf..f8a15ce 100644 --- a/the_hat_game/google.py +++ b/server/players.py @@ -6,21 +6,14 @@ from google.oauth2.credentials import Credentials from googleapiclient.discovery import build -from the_hat_game.utils import get_project_root +from settings_server import COLUMN_IP, COLUMN_TEAM, SAMPLE_RANGE_NAME, SAMPLE_SPREADSHEET_ID, SCOPES, TOKEN_PATH +from the_hat_game.players import PlayerDefinition, RemotePlayer -# If modifying these scopes, delete the file token.json. -SCOPES = ["https://www.googleapis.com/auth/spreadsheets"] -# The ID and range of a sample spreadsheet. -SAMPLE_SPREADSHEET_ID = "1yHJ98wX3rPQeWdAEqXEHo4nU3z3Q60sGS4qlAwRP6Oo" -SAMPLE_RANGE_NAME = "Form Responses 1!A:D" +def get_global_players(): - -def get_players(): - token_path = get_project_root() / "credentials" / "token_write.json" - - if os.path.exists(token_path): - credentials = Credentials.from_authorized_user_file(str(token_path), SCOPES) + if os.path.exists(TOKEN_PATH): + credentials = Credentials.from_authorized_user_file(str(TOKEN_PATH), SCOPES) service = build("sheets", "v4", credentials=credentials) sheet = service.spreadsheets() result = sheet.values().get(spreadsheetId=SAMPLE_SPREADSHEET_ID, range=SAMPLE_RANGE_NAME).execute() @@ -28,4 +21,5 @@ def get_players(): df = pd.DataFrame(values[1:], columns=values[0]) - return df + players = [PlayerDefinition(row[COLUMN_TEAM], RemotePlayer(row[COLUMN_IP])) for i, row in df.iterrows()] + return players diff --git a/server/storage.py b/server/storage.py new file mode 100644 index 0000000..84598ea --- /dev/null +++ b/server/storage.py @@ -0,0 +1,11 @@ +from google.cloud import storage + + +def get_storage(project_id): + """Function to define where game artifacts are stored. + game_scope could be "GLOBAL" or "LOCAL". + If game_scope is "GLOBAL", artifacts are stored on the Google server. + If game_scope is "LOCAL", artifacts are stored locally. + """ + storage_client = storage.Client(project=project_id) + return storage_client diff --git a/settings.py b/settings.py index 110bb99..2bdb3b0 100644 --- a/settings.py +++ b/settings.py @@ -1,39 +1,12 @@ +"""Settings for the Hat Game.""" + import os from pathlib import Path - CWD = Path(os.getcwd()) -DATA_PATH = CWD / "texts" -PROJECT_GCS_ID = "mlops-dvc-demo" -BUCKET_SPLIT_TEXTS = "dmia-mlops-texts-vault" -BUCKET_LOGS = "dmia-mlops-logs" -BUCKET_DAILY = "dmia-mlops-texts" -VOCAB_PATH = CWD / "vocab" / "vocab.txt" - -try: - from google.cloud import storage - STORAGE_CLIENT = storage.Client(project=PROJECT_GCS_ID) -except: - pass - -HIDE_WARNINGS = False - +GAME_SCOPE = "LOCAL" # Could be "GLOBAL" or "LOCAL" +LOCAL_VOCAB_PATH = CWD / "text_samples" / "nouns_top_50.txt" N_EXPLAIN_WORDS = 10 N_GUESSING_WORDS = 5 N_ROUNDS = 1 CRITERIA = "soft" - -SCOPE = [ - "https://spreadsheets.google.com/feeds", - "https://www.googleapis.com/auth/drive", -] - - -SPREADSHEET = "2019-12 DMIA Hat (Responses)" - - -def set_environ(): - os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = str(CWD / "credentials" / "bucket_storage.json") - - -set_environ() diff --git a/settings_server.py b/settings_server.py new file mode 100644 index 0000000..bfe6255 --- /dev/null +++ b/settings_server.py @@ -0,0 +1,36 @@ +"""Settings to launch the Hat Game on a server.""" + +import os +from pathlib import Path + +from server.storage import get_storage +from the_hat_game.utils import get_project_root + +CWD = Path(os.getcwd()) +DATA_PATH = CWD / "texts" +GLOBAL_VOCAB_PATH = CWD / "vocab" / "vocab.txt" +PROJECT_GCS_ID = "mlops-dvc-demo" +BUCKET_SPLIT_TEXTS = "dmia-mlops-texts-vault" +BUCKET_LOGS = "dmia-mlops-logs" +BUCKET_DAILY = "dmia-mlops-texts" +STORAGE_CLIENT = get_storage(PROJECT_GCS_ID) + +# If modifying these scopes, delete the file token.json. +SCOPES = ["https://www.googleapis.com/auth/spreadsheets"] + +# The ID and range of a sample spreadsheet. +SAMPLE_SPREADSHEET_ID = "1yHJ98wX3rPQeWdAEqXEHo4nU3z3Q60sGS4qlAwRP6Oo" +SAMPLE_RANGE_NAME = "Form Responses 1!A:D" + +TOKEN_PATH = get_project_root() / "credentials" / "token_write.json" +HIDE_WARNINGS = False + +COLUMN_TEAM = "Team name" +COLUMN_IP = "Team IP or URL (with port if necessary)" + + +def set_environ(): + os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = str(CWD / "credentials" / "bucket_storage.json") + + +set_environ() diff --git a/the_hat_game/game.py b/the_hat_game/game.py index 7f00bfb..51e0b5d 100644 --- a/the_hat_game/game.py +++ b/the_hat_game/game.py @@ -168,15 +168,15 @@ def play_round(self, explaining_player, guessing_players, word, sentence): for player in guessing_players: player_results = {} player_dict = players_guesses[player.name] - guessed_words = player_dict['word_list'] + guessed_words = player_dict["word_list"] guessed = self.check_criteria(word, guessed_words) logger.info(f"GUESSING PLAYER ({player.name}) to HOST: {guessed_words}") # logger.info(f"RESPONSE_TIME: {player_dict['time']}, RESPONSE_CODE: {player_dict['code']}") logger.info(f"HOST: {guessed}") game_round.update({f"Guess ({player.name})": guessed_words}) player_results["guessed"] = guessed - player_results["response_time"] = player_dict['time'] - player_results["response_200"] = player_dict['code'] == 200 + player_results["response_time"] = player_dict["time"] + player_results["response_200"] = player_dict["code"] == 200 results[player.name] = player_results return game_round, results @@ -207,7 +207,9 @@ def play(self, explaining_player, guessing_players, word, criteria): player_results = results_round.get(player.name, dict()) for metric in player_results.keys(): if metric != "guessed": - metrics[(player.name, metric)] = metrics.get((player.name, metric), list()) + [player_results[metric]] + metrics[(player.name, metric)] = metrics.get((player.name, metric), list()) + [ + player_results[metric] + ] for player in guessing_players[:]: if (player.name not in success_rounds) and results_round.get(player.name, dict()).get("guessed", False): success_rounds[player.name] = iround diff --git a/the_hat_game/loggers.py b/the_hat_game/loggers.py index f5704ec..2d5059e 100644 --- a/the_hat_game/loggers.py +++ b/the_hat_game/loggers.py @@ -2,9 +2,6 @@ import pandas as pd -# from data.utils import upload_blob -# from settings import BUCKET_LOGS - common_log_filename = "logs/game_run.log" current_log_filename = "logs/game run {}.log".format(pd.Timestamp.now().strftime("%Y-%m-%d %H_%M_%S")) diff --git a/the_hat_game/players.py b/the_hat_game/players.py index fbeb965..2a80bc9 100644 --- a/the_hat_game/players.py +++ b/the_hat_game/players.py @@ -9,6 +9,7 @@ PlayerDefinition = namedtuple("PlayerDefinition", ["name", "api"]) + def validate_word_list(word_list): if not isinstance(word_list, list): return False @@ -21,6 +22,7 @@ def validate_word_list(word_list): class ValidationError(Exception): pass + class AbstractPlayer: def __init__(self): raise NotImplementedError() From 26e6f0dea108fb1bc3278772596bf488e0e6fb1d Mon Sep 17 00:00:00 2001 From: "naidenov.aleksei" Date: Sun, 28 Nov 2021 13:16:52 +0300 Subject: [PATCH 6/7] update whitelist with words for guessing --- the_hat_game/game.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/the_hat_game/game.py b/the_hat_game/game.py index 51e0b5d..de34064 100644 --- a/the_hat_game/game.py +++ b/the_hat_game/game.py @@ -32,7 +32,7 @@ def __init__( """Main class for Game. params: - players: list of AbstractPlayer - players in the game - - words: list of str - all used words in the game + - words: list of str - all used words for guessing - criteria: 'hard' of 'soft' - game criteria - n_rounds: int - number of rounds - n_explain_words: int - number of words for explaining @@ -54,13 +54,19 @@ def __init__( self.stemmer = SnowballStemmer("english") if corpus_path is not None: assert vocab_path is None, "corpus and vocabulary cannot be defined at the same time" - self.used_words = corpus_to_words(corpus_path) + self.whitelist = corpus_to_words(corpus_path) elif vocab_path is not None: with open(vocab_path, encoding="utf-8") as f: - words = f.readlines() - self.used_words = [word.strip() for word in words] + vocab_words = f.readlines() + self.whitelist = [word.strip() for word in vocab_words] else: - self.used_words = None + self.whitelist = None + # add all words for guessing to non-empty whitelist + if self.whitelist is not None: + self.whitelist += [ + word for word in self.words + if word not in self.whitelist + ] def remove_repeated_words(self, words): unique_words = [] @@ -80,8 +86,8 @@ def remove_same_rooted_words(self, word, word_list): return cleared_word_list def remove_non_existing_words(self, words): - if self.used_words is not None: - existing_words = [w for w in words if w in self.used_words] + if self.whitelist is not None: + existing_words = [w for w in words if w in self.whitelist] else: existing_words = [w for w in words if len(wordnet.synsets(w)) > 0] return existing_words From 0481ab441bc6c77a95e00abb49d55c9507053672 Mon Sep 17 00:00:00 2001 From: "naidenov.aleksei" Date: Sun, 28 Nov 2021 13:17:49 +0300 Subject: [PATCH 7/7] add the_hat_game/data.py --- the_hat_game/data.py | 32 ++++++++++++++++++++++++++++++++ the_hat_game/game.py | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 the_hat_game/data.py diff --git a/the_hat_game/data.py b/the_hat_game/data.py new file mode 100644 index 0000000..28ae721 --- /dev/null +++ b/the_hat_game/data.py @@ -0,0 +1,32 @@ +import re +from collections import Counter +from typing import List + +from nltk.corpus import stopwords +from nltk.stem import WordNetLemmatizer +from nltk.tokenize import word_tokenize +from tqdm.auto import tqdm + +STOP_WORDS = stopwords.words("english") +LEMMATIZER = WordNetLemmatizer() + + +def sent_2_words(sent: str) -> List[str]: + sent = sent.lower() + sent = re.sub("[^a-z]+", " ", sent) + words = word_tokenize(sent) + words = [LEMMATIZER.lemmatize(word) for word in words if ((word not in STOP_WORDS) and len(word.strip()) > 3)] + return words + + +def corpus_to_words(file_path: str): + my_counter: Counter = Counter() + with open(file_path, "r", encoding="utf-8") as fl: + for sent in tqdm(fl, desc="Precess file"): + my_counter.update(sent_2_words(sent)) + + max_cnt = max(count for word, count in my_counter.items()) / 10 + min_count = max([10, max_cnt / 100]) + + selected_words = [word for word, count in my_counter.items() if (min_count < count <= max_cnt)] + return selected_words diff --git a/the_hat_game/game.py b/the_hat_game/game.py index de34064..3208a58 100644 --- a/the_hat_game/game.py +++ b/the_hat_game/game.py @@ -13,7 +13,7 @@ import the_hat_game.nltk_setup # noqa: F401 from the_hat_game.loggers import c_handler, logger from the_hat_game.players import RemotePlayer -from data.utils import corpus_to_words +from the_hat_game.data import corpus_to_words class Game: