yazodi commited on
Commit
62a72a7
·
verified ·
1 Parent(s): 868788c

Upload 7 files

Browse files
Files changed (7) hide show
  1. Codenames AI Assistant .ipynb +314 -0
  2. NOte.txt +35 -0
  3. README.md +42 -20
  4. app.py +55 -0
  5. config.json +14 -0
  6. model.txt +3 -0
  7. sample_input.json +0 -0
Codenames AI Assistant .ipynb ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "9b7d6163-bb7b-44f9-8ca2-fb20e588efac",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stdout",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "Collecting gensim\n",
14
+ " Using cached gensim-4.3.3-cp312-cp312-win_amd64.whl.metadata (8.2 kB)\n",
15
+ "Requirement already satisfied: numpy in c:\\programdata\\anaconda3\\lib\\site-packages (2.1.3)\n",
16
+ "Collecting numpy\n",
17
+ " Using cached numpy-1.26.4-cp312-cp312-win_amd64.whl.metadata (61 kB)\n",
18
+ "Collecting scipy<1.14.0,>=1.7.0 (from gensim)\n",
19
+ " Using cached scipy-1.13.1-cp312-cp312-win_amd64.whl.metadata (60 kB)\n",
20
+ "Collecting smart-open>=1.8.1 (from gensim)\n",
21
+ " Using cached smart_open-7.1.0-py3-none-any.whl.metadata (24 kB)\n",
22
+ "Requirement already satisfied: wrapt in c:\\programdata\\anaconda3\\lib\\site-packages (from smart-open>=1.8.1->gensim) (1.17.0)\n",
23
+ "Using cached gensim-4.3.3-cp312-cp312-win_amd64.whl (24.0 MB)\n",
24
+ "Using cached numpy-1.26.4-cp312-cp312-win_amd64.whl (15.5 MB)\n",
25
+ "Downloading scipy-1.13.1-cp312-cp312-win_amd64.whl (45.9 MB)\n",
26
+ " ---------------------------------------- 0.0/45.9 MB ? eta -:--:--\n",
27
+ " ---------------------------------------- 0.0/45.9 MB ? eta -:--:--\n",
28
+ " ---------------------------------------- 0.5/45.9 MB 3.4 MB/s eta 0:00:14\n",
29
+ " --------------------------------------- 0.8/45.9 MB 2.0 MB/s eta 0:00:23\n",
30
+ " - -------------------------------------- 1.3/45.9 MB 2.3 MB/s eta 0:00:20\n",
31
+ " - -------------------------------------- 1.8/45.9 MB 2.3 MB/s eta 0:00:20\n",
32
+ " -- ------------------------------------- 2.4/45.9 MB 2.2 MB/s eta 0:00:20\n",
33
+ " -- ------------------------------------- 2.6/45.9 MB 2.3 MB/s eta 0:00:20\n",
34
+ " -- ------------------------------------- 3.1/45.9 MB 2.2 MB/s eta 0:00:20\n",
35
+ " --- ------------------------------------ 3.7/45.9 MB 2.2 MB/s eta 0:00:19\n",
36
+ " --- ------------------------------------ 4.2/45.9 MB 2.2 MB/s eta 0:00:19\n",
37
+ " --- ------------------------------------ 4.5/45.9 MB 2.2 MB/s eta 0:00:19\n",
38
+ " ---- ----------------------------------- 5.0/45.9 MB 2.2 MB/s eta 0:00:19\n",
39
+ " ---- ----------------------------------- 5.5/45.9 MB 2.2 MB/s eta 0:00:19\n",
40
+ " ----- ---------------------------------- 5.8/45.9 MB 2.2 MB/s eta 0:00:19\n",
41
+ " ----- ---------------------------------- 6.3/45.9 MB 2.2 MB/s eta 0:00:18\n",
42
+ " ----- ---------------------------------- 6.8/45.9 MB 2.2 MB/s eta 0:00:18\n",
43
+ " ------ --------------------------------- 7.3/45.9 MB 2.2 MB/s eta 0:00:18\n",
44
+ " ------ --------------------------------- 7.6/45.9 MB 2.2 MB/s eta 0:00:18\n",
45
+ " ------- -------------------------------- 8.1/45.9 MB 2.2 MB/s eta 0:00:18\n",
46
+ " ------- -------------------------------- 8.7/45.9 MB 2.2 MB/s eta 0:00:17\n",
47
+ " ------- -------------------------------- 9.2/45.9 MB 2.2 MB/s eta 0:00:17\n",
48
+ " -------- ------------------------------- 9.4/45.9 MB 2.2 MB/s eta 0:00:17\n",
49
+ " -------- ------------------------------- 10.0/45.9 MB 2.2 MB/s eta 0:00:17\n",
50
+ " --------- ------------------------------ 10.5/45.9 MB 2.2 MB/s eta 0:00:17\n",
51
+ " --------- ------------------------------ 10.7/45.9 MB 2.2 MB/s eta 0:00:16\n",
52
+ " --------- ------------------------------ 11.3/45.9 MB 2.2 MB/s eta 0:00:16\n",
53
+ " ---------- ----------------------------- 11.8/45.9 MB 2.2 MB/s eta 0:00:16\n",
54
+ " ---------- ----------------------------- 12.3/45.9 MB 2.2 MB/s eta 0:00:16\n",
55
+ " ---------- ----------------------------- 12.6/45.9 MB 2.2 MB/s eta 0:00:16\n",
56
+ " ----------- ---------------------------- 13.1/45.9 MB 2.1 MB/s eta 0:00:16\n",
57
+ " ----------- ---------------------------- 13.4/45.9 MB 2.2 MB/s eta 0:00:16\n",
58
+ " ------------ --------------------------- 13.9/45.9 MB 2.1 MB/s eta 0:00:15\n",
59
+ " ------------ --------------------------- 14.4/45.9 MB 2.2 MB/s eta 0:00:15\n",
60
+ " ------------ --------------------------- 14.7/45.9 MB 2.2 MB/s eta 0:00:15\n",
61
+ " ------------- -------------------------- 15.2/45.9 MB 2.2 MB/s eta 0:00:15\n",
62
+ " ------------- -------------------------- 15.7/45.9 MB 2.2 MB/s eta 0:00:14\n",
63
+ " ------------- -------------------------- 16.0/45.9 MB 2.2 MB/s eta 0:00:14\n",
64
+ " -------------- ------------------------- 16.5/45.9 MB 2.2 MB/s eta 0:00:14\n",
65
+ " -------------- ------------------------- 17.0/45.9 MB 2.2 MB/s eta 0:00:14\n",
66
+ " --------------- ------------------------ 17.3/45.9 MB 2.2 MB/s eta 0:00:14\n",
67
+ " --------------- ------------------------ 17.8/45.9 MB 2.2 MB/s eta 0:00:14\n",
68
+ " --------------- ------------------------ 18.4/45.9 MB 2.2 MB/s eta 0:00:13\n",
69
+ " ---------------- ----------------------- 18.9/45.9 MB 2.1 MB/s eta 0:00:13\n",
70
+ " ---------------- ----------------------- 19.1/45.9 MB 2.2 MB/s eta 0:00:13\n",
71
+ " ----------------- ---------------------- 19.7/45.9 MB 2.2 MB/s eta 0:00:13\n",
72
+ " ----------------- ---------------------- 20.2/45.9 MB 2.2 MB/s eta 0:00:12\n",
73
+ " ----------------- ---------------------- 20.4/45.9 MB 2.2 MB/s eta 0:00:12\n",
74
+ " ------------------ --------------------- 21.0/45.9 MB 2.2 MB/s eta 0:00:12\n",
75
+ " ------------------ --------------------- 21.5/45.9 MB 2.2 MB/s eta 0:00:12\n",
76
+ " ------------------ --------------------- 21.8/45.9 MB 2.2 MB/s eta 0:00:12\n",
77
+ " ------------------- -------------------- 22.3/45.9 MB 2.2 MB/s eta 0:00:11\n",
78
+ " ------------------- -------------------- 22.8/45.9 MB 2.2 MB/s eta 0:00:11\n",
79
+ " -------------------- ------------------- 23.3/45.9 MB 2.2 MB/s eta 0:00:11\n",
80
+ " -------------------- ------------------- 23.6/45.9 MB 2.2 MB/s eta 0:00:11\n",
81
+ " --------------------- ------------------ 24.1/45.9 MB 2.2 MB/s eta 0:00:11\n",
82
+ " --------------------- ------------------ 24.6/45.9 MB 2.2 MB/s eta 0:00:10\n",
83
+ " --------------------- ------------------ 24.9/45.9 MB 2.2 MB/s eta 0:00:10\n",
84
+ " ---------------------- ----------------- 25.4/45.9 MB 2.2 MB/s eta 0:00:10\n",
85
+ " ---------------------- ----------------- 26.0/45.9 MB 2.2 MB/s eta 0:00:10\n",
86
+ " ---------------------- ----------------- 26.2/45.9 MB 2.2 MB/s eta 0:00:10\n",
87
+ " ----------------------- ---------------- 26.7/45.9 MB 2.2 MB/s eta 0:00:09\n",
88
+ " ----------------------- ---------------- 27.3/45.9 MB 2.2 MB/s eta 0:00:09\n",
89
+ " ----------------------- ---------------- 27.5/45.9 MB 2.2 MB/s eta 0:00:09\n",
90
+ " ------------------------ --------------- 27.8/45.9 MB 2.2 MB/s eta 0:00:09\n",
91
+ " ------------------------ --------------- 28.3/45.9 MB 2.1 MB/s eta 0:00:09\n",
92
+ " ------------------------- -------------- 28.8/45.9 MB 2.1 MB/s eta 0:00:08\n",
93
+ " ------------------------- -------------- 29.1/45.9 MB 2.1 MB/s eta 0:00:08\n",
94
+ " ------------------------- -------------- 29.6/45.9 MB 2.1 MB/s eta 0:00:08\n",
95
+ " -------------------------- ------------- 29.9/45.9 MB 2.1 MB/s eta 0:00:08\n",
96
+ " -------------------------- ------------- 30.4/45.9 MB 2.1 MB/s eta 0:00:08\n",
97
+ " -------------------------- ------------- 30.7/45.9 MB 2.1 MB/s eta 0:00:08\n",
98
+ " --------------------------- ------------ 31.2/45.9 MB 2.1 MB/s eta 0:00:07\n",
99
+ " --------------------------- ------------ 31.7/45.9 MB 2.1 MB/s eta 0:00:07\n",
100
+ " --------------------------- ------------ 32.0/45.9 MB 2.1 MB/s eta 0:00:07\n",
101
+ " ---------------------------- ----------- 32.2/45.9 MB 2.1 MB/s eta 0:00:07\n",
102
+ " ---------------------------- ----------- 32.8/45.9 MB 2.1 MB/s eta 0:00:07\n",
103
+ " ----------------------------- ---------- 33.3/45.9 MB 2.1 MB/s eta 0:00:06\n",
104
+ " ----------------------------- ---------- 33.6/45.9 MB 2.1 MB/s eta 0:00:06\n",
105
+ " ----------------------------- ---------- 34.1/45.9 MB 2.1 MB/s eta 0:00:06\n",
106
+ " ----------------------------- ---------- 34.3/45.9 MB 2.1 MB/s eta 0:00:06\n",
107
+ " ------------------------------ --------- 34.6/45.9 MB 2.1 MB/s eta 0:00:06\n",
108
+ " ------------------------------ --------- 35.1/45.9 MB 2.1 MB/s eta 0:00:06\n",
109
+ " ------------------------------- -------- 35.7/45.9 MB 2.1 MB/s eta 0:00:05\n",
110
+ " ------------------------------- -------- 35.9/45.9 MB 2.1 MB/s eta 0:00:05\n",
111
+ " ------------------------------- -------- 36.2/45.9 MB 2.1 MB/s eta 0:00:05\n",
112
+ " ------------------------------- -------- 36.7/45.9 MB 2.1 MB/s eta 0:00:05\n",
113
+ " -------------------------------- ------- 37.0/45.9 MB 2.1 MB/s eta 0:00:05\n",
114
+ " -------------------------------- ------- 37.5/45.9 MB 2.1 MB/s eta 0:00:05\n",
115
+ " --------------------------------- ------ 38.0/45.9 MB 2.1 MB/s eta 0:00:04\n",
116
+ " --------------------------------- ------ 38.3/45.9 MB 2.1 MB/s eta 0:00:04\n",
117
+ " --------------------------------- ------ 38.8/45.9 MB 2.1 MB/s eta 0:00:04\n",
118
+ " ---------------------------------- ----- 39.1/45.9 MB 2.1 MB/s eta 0:00:04\n",
119
+ " ---------------------------------- ----- 39.6/45.9 MB 2.1 MB/s eta 0:00:04\n",
120
+ " ---------------------------------- ----- 39.8/45.9 MB 2.1 MB/s eta 0:00:03\n",
121
+ " ----------------------------------- ---- 40.4/45.9 MB 2.1 MB/s eta 0:00:03\n",
122
+ " ----------------------------------- ---- 40.6/45.9 MB 2.1 MB/s eta 0:00:03\n",
123
+ " ----------------------------------- ---- 41.2/45.9 MB 2.1 MB/s eta 0:00:03\n",
124
+ " ------------------------------------ --- 41.4/45.9 MB 2.1 MB/s eta 0:00:03\n",
125
+ " ------------------------------------ --- 41.9/45.9 MB 2.1 MB/s eta 0:00:02\n",
126
+ " ------------------------------------ --- 42.2/45.9 MB 2.1 MB/s eta 0:00:02\n",
127
+ " ------------------------------------- -- 42.7/45.9 MB 2.1 MB/s eta 0:00:02\n",
128
+ " ------------------------------------- -- 43.0/45.9 MB 2.1 MB/s eta 0:00:02\n",
129
+ " ------------------------------------- -- 43.3/45.9 MB 2.1 MB/s eta 0:00:02\n",
130
+ " -------------------------------------- - 43.8/45.9 MB 2.1 MB/s eta 0:00:02\n",
131
+ " -------------------------------------- - 44.3/45.9 MB 2.1 MB/s eta 0:00:01\n",
132
+ " -------------------------------------- - 44.6/45.9 MB 2.1 MB/s eta 0:00:01\n",
133
+ " --------------------------------------- 45.1/45.9 MB 2.1 MB/s eta 0:00:01\n",
134
+ " --------------------------------------- 45.4/45.9 MB 2.1 MB/s eta 0:00:01\n",
135
+ " --------------------------------------- 45.9/45.9 MB 2.1 MB/s eta 0:00:01\n",
136
+ " ---------------------------------------- 45.9/45.9 MB 2.0 MB/s eta 0:00:00\n",
137
+ "Downloading smart_open-7.1.0-py3-none-any.whl (61 kB)\n",
138
+ "Installing collected packages: smart-open, numpy, scipy, gensim\n",
139
+ " Attempting uninstall: numpy\n",
140
+ " Found existing installation: numpy 2.1.3\n",
141
+ " Uninstalling numpy-2.1.3:\n",
142
+ " Successfully uninstalled numpy-2.1.3\n",
143
+ " Attempting uninstall: scipy\n",
144
+ " Found existing installation: scipy 1.15.1\n",
145
+ " Uninstalling scipy-1.15.1:\n",
146
+ " Successfully uninstalled scipy-1.15.1\n",
147
+ "Successfully installed gensim-4.3.3 numpy-1.26.4 scipy-1.13.1 smart-open-7.1.0\n"
148
+ ]
149
+ },
150
+ {
151
+ "name": "stderr",
152
+ "output_type": "stream",
153
+ "text": [
154
+ " WARNING: Failed to remove contents in a temporary directory 'C:\\Users\\LGR\\AppData\\Local\\Temp\\pip-uninstall-bzrgm1pe'.\n",
155
+ " You can safely remove it manually.\n",
156
+ " WARNING: Failed to remove contents in a temporary directory 'C:\\ProgramData\\anaconda3\\Lib\\site-packages\\~~mpy.libs'.\n",
157
+ " You can safely remove it manually.\n",
158
+ "ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
159
+ "tensorflow-intel 2.18.0 requires ml-dtypes<0.5.0,>=0.4.0, but you have ml-dtypes 0.5.1 which is incompatible.\n",
160
+ "tensorflow-intel 2.18.0 requires tensorboard<2.19,>=2.18, but you have tensorboard 2.19.0 which is incompatible.\n",
161
+ "bokeh 3.6.2 requires tornado>=6.2, but you have tornado 6.1 which is incompatible.\n",
162
+ "scikit-image 0.25.0 requires pillow>=10.1, but you have pillow 9.5.0 which is incompatible.\n"
163
+ ]
164
+ }
165
+ ],
166
+ "source": [
167
+ "!pip install gensim numpy"
168
+ ]
169
+ },
170
+ {
171
+ "cell_type": "code",
172
+ "execution_count": 2,
173
+ "id": "a6600c17-fb8e-4e8c-a6a1-d25084447144",
174
+ "metadata": {},
175
+ "outputs": [],
176
+ "source": [
177
+ "import gensim.downloader as api\n",
178
+ "\n",
179
+ "# Bu satır modeli ilk kez indirir ve önbelleğe alır\n",
180
+ "model = api.load(\"word2vec-google-news-300\")"
181
+ ]
182
+ },
183
+ {
184
+ "cell_type": "code",
185
+ "execution_count": 3,
186
+ "id": "6d55403c-62fc-4d07-9306-ca11593bcaa2",
187
+ "metadata": {},
188
+ "outputs": [
189
+ {
190
+ "data": {
191
+ "text/plain": [
192
+ "0.05226295"
193
+ ]
194
+ },
195
+ "execution_count": 3,
196
+ "metadata": {},
197
+ "output_type": "execute_result"
198
+ }
199
+ ],
200
+ "source": [
201
+ "# En benzer kelimeleri getir\n",
202
+ "model.most_similar(\"spy\")\n",
203
+ "\n",
204
+ "# İki kelime arasındaki benzerlik\n",
205
+ "model.similarity(\"dog\", \"cat\")\n",
206
+ "model.similarity(\"dog\", \"explosion\")"
207
+ ]
208
+ },
209
+ {
210
+ "cell_type": "markdown",
211
+ "id": "e56a26c9-a705-4e54-83e2-331e03586f36",
212
+ "metadata": {},
213
+ "source": [
214
+ "AI Strateji Fonksiyonu: oner_ipucu()\n",
215
+ "Bu fonksiyon:\n",
216
+ "\n",
217
+ "Hedef kelimelere yakın\n",
218
+ "\n",
219
+ "Yasaklı kelimelere uzak\n",
220
+ "olan en iyi ipucunu seçecek."
221
+ ]
222
+ },
223
+ {
224
+ "cell_type": "code",
225
+ "execution_count": 4,
226
+ "id": "8d01664b-2ca0-407c-a51c-55f19ec5615f",
227
+ "metadata": {},
228
+ "outputs": [],
229
+ "source": [
230
+ "def oner_ipucu(hedefler, yasaklar, model, aday_kelimeler=None, top_n=1):\n",
231
+ " from numpy import mean\n",
232
+ "\n",
233
+ " # Hedef ve yasaklı kelimeleri dışlayacağımız bir set\n",
234
+ " filtre = set(hedefler + yasaklar)\n",
235
+ "\n",
236
+ " if aday_kelimeler is None:\n",
237
+ " aday_kelimeler = list(model.key_to_index.keys())\n",
238
+ "\n",
239
+ " en_iyi_ipucu = None\n",
240
+ " en_iyi_skor = -float(\"inf\")\n",
241
+ "\n",
242
+ " for kelime in aday_kelimeler:\n",
243
+ " if kelime in filtre:\n",
244
+ " continue # hedef ya da yasaklılardan biri zaten, geç\n",
245
+ "\n",
246
+ " try:\n",
247
+ " hedef_skor = mean([model.similarity(kelime, h) for h in hedefler if h in model])\n",
248
+ " yasak_skor = mean([model.similarity(kelime, y) for y in yasaklar if y in model])\n",
249
+ " toplam_skor = hedef_skor - yasak_skor\n",
250
+ "\n",
251
+ " if toplam_skor > en_iyi_skor:\n",
252
+ " en_iyi_skor = toplam_skor\n",
253
+ " en_iyi_ipucu = kelime\n",
254
+ "\n",
255
+ " except KeyError:\n",
256
+ " continue\n",
257
+ "\n",
258
+ " return en_iyi_ipucu\n",
259
+ "\n"
260
+ ]
261
+ },
262
+ {
263
+ "cell_type": "code",
264
+ "execution_count": 5,
265
+ "id": "a24840d8-ecfe-4119-a25a-514e9ec42a55",
266
+ "metadata": {},
267
+ "outputs": [
268
+ {
269
+ "name": "stdout",
270
+ "output_type": "stream",
271
+ "text": [
272
+ "🔍 Geliştirilmiş Önerilen ipucu: cats\n"
273
+ ]
274
+ }
275
+ ],
276
+ "source": [
277
+ "hedefler = [\"dog\", \"cat\", \"fish\"]\n",
278
+ "yasaklar = [\"bomb\", \"knife\", \"gun\"]\n",
279
+ "\n",
280
+ "ipucu = oner_ipucu(hedefler, yasaklar, model)\n",
281
+ "print(\"🔍 Geliştirilmiş Önerilen ipucu:\", ipucu)\n"
282
+ ]
283
+ },
284
+ {
285
+ "cell_type": "code",
286
+ "execution_count": null,
287
+ "id": "b56df5e1-eb56-4a4b-83a4-172476551353",
288
+ "metadata": {},
289
+ "outputs": [],
290
+ "source": []
291
+ }
292
+ ],
293
+ "metadata": {
294
+ "kernelspec": {
295
+ "display_name": "Python 3 (ipykernel)",
296
+ "language": "python",
297
+ "name": "python3"
298
+ },
299
+ "language_info": {
300
+ "codemirror_mode": {
301
+ "name": "ipython",
302
+ "version": 3
303
+ },
304
+ "file_extension": ".py",
305
+ "mimetype": "text/x-python",
306
+ "name": "python",
307
+ "nbconvert_exporter": "python",
308
+ "pygments_lexer": "ipython3",
309
+ "version": "3.12.9"
310
+ }
311
+ },
312
+ "nbformat": 4,
313
+ "nbformat_minor": 5
314
+ }
NOte.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Proje Özeti: Codenames AI Assistant
2
+ Oyunda bir “spymaster” olarak çalışan yapay zeka modeli, elindeki kelimelere bakarak takımına ipuçları (tek bir kelime) vermeye çalışır. Amaç:
3
+ 🔹 Hedef kelimelerle ilişkili bir ipucu bulmak
4
+ 🔹 Rakip veya yasak kelimelere yaklaşmamak
5
+
6
+
7
+
8
+
9
+ 💡 Teknik Bileşenler:
10
+ Bileşen Açıklama
11
+ Embedding Word2Vec / FastText / GloVe
12
+ Benzerlik Ölçümü Cosine Similarity
13
+ Strateji Maksimum hedef benzerliği + minimum rakip/assassin uzaklığı
14
+ Arayüz Streamlit (görsel oyun tahtası + AI önerisi)
15
+
16
+
17
+
18
+ 🧠 Yapay Zeka Ne Yapacak?
19
+ Hedef kelimeler listesi verilecek
20
+
21
+ Yasaklı kelimeler (rakip + assassin) de belirtilecek
22
+
23
+ Model, embedding'ler üzerinden tüm kelimeleri tarayacak
24
+
25
+ Hem hedeflere en yakın, hem de yasaklılara en uzak olan en iyi ipucuyu önerecek
26
+
27
+ 📂 Başlangıç Planı:
28
+ ✅ Proje dosyası oluştur (codenames_ai)
29
+
30
+ Word2Vec vektörleri indir (hazır model)
31
+
32
+ Basit örnekle strateji algoritması geliştir
33
+
34
+ Streamlit arayüzü (girdi: hedef + yasaklı kelimeler → çıktı: ipucu)
35
+
README.md CHANGED
@@ -1,20 +1,42 @@
1
- ---
2
- title: Codenames AI Assistant
3
- emoji: 🚀
4
- colorFrom: red
5
- colorTo: red
6
- sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
- pinned: false
11
- short_description: Streamlit template space
12
- license: mit
13
- ---
14
-
15
- # Welcome to Streamlit!
16
-
17
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
18
-
19
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
20
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: "Codenames AI Assistant"
3
+ emoji: 🧠
4
+ colorFrom: blue
5
+ colorTo: red
6
+ sdk: streamlit
7
+ app_file: app.py
8
+ pinned: true
9
+ tags:
10
+ - nlp
11
+ - word2vec
12
+ - strategy
13
+ - ai
14
+ - streamlit
15
+ - game
16
+ license: mit
17
+ ---
18
+
19
+ # 🧠 Codenames AI Assistant
20
+
21
+ Bu proje, **Codenames** oyununda hedef kelimelere en uygun **tek kelimelik ipucu**yu bulmaya çalışan bir yapay zeka strateji aracıdır.
22
+ Word2Vec modeli ile anlamsal benzerlik hesaplanır, hedeflere yakın, yasaklara uzak en iyi kelime önerilir.
23
+
24
+ ## 🔍 Kullanılan Teknikler
25
+
26
+ - Gensim ile önceden eğitilmiş `word2vec-google-news-300`
27
+ - Cosine benzerliği
28
+ - Stratejik kelime seçimi
29
+
30
+ ## 🧩 Nasıl Çalışır?
31
+
32
+ - Hedef ve yasaklı kelimeleri gir
33
+ - AI, en alakalı ve güvenli kelimeyi önerir
34
+ - Model eğitimi yoktur (hazır embedding kullanılır)
35
+
36
+ ## 🧠 Örnek
37
+
38
+ ```python
39
+ hedefler = ["dog", "cat", "fish"]
40
+ yasaklar = ["bomb", "knife", "gun"]
41
+ ipucu = oner_ipucu(hedefler, yasaklar, model)
42
+ print(ipucu) # animal gibi bir sonuç dönebilir
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import gensim.downloader as api
3
+ import numpy as np
4
+ import string
5
+ import re
6
+
7
+ # 🔹 AI ipucu önerici
8
+ def oner_ipucu(hedefler, yasaklar, model, aday_kelimeler=None):
9
+ filtre = set(hedefler + yasaklar)
10
+ if aday_kelimeler is None:
11
+ aday_kelimeler = list(model.key_to_index.keys())
12
+
13
+ en_iyi_ipucu = None
14
+ en_iyi_skor = -float("inf")
15
+
16
+ for kelime in aday_kelimeler:
17
+ if kelime in filtre:
18
+ continue
19
+ try:
20
+ hedef_skor = np.mean([model.similarity(kelime, h) for h in hedefler if h in model])
21
+ yasak_skor = np.mean([model.similarity(kelime, y) for y in yasaklar if y in model])
22
+ toplam_skor = hedef_skor - yasak_skor
23
+ if toplam_skor > en_iyi_skor:
24
+ en_iyi_skor = toplam_skor
25
+ en_iyi_ipucu = kelime
26
+ except KeyError:
27
+ continue
28
+
29
+ return en_iyi_ipucu
30
+
31
+ # 🧠 Word2Vec modeli yükle (ilk seferde indirir)
32
+ @st.cache_resource
33
+ def load_model():
34
+ return api.load("word2vec-google-news-300")
35
+
36
+ model = load_model()
37
+
38
+ # 🎯 Uygulama Başlığı
39
+ st.title("🧠 Codenames AI Assistant")
40
+ st.subheader("💡 Yapay Zeka ile Stratejik İpucu Önerici")
41
+
42
+ # 🎯 Girdiler
43
+ hedef_input = st.text_input("🎯 Hedef kelimeler (virgülle ayırın)", "dog, cat, fish")
44
+ yasak_input = st.text_input("⛔ Yasaklı kelimeler (virgülle ayırın)", "bomb, knife, gun")
45
+
46
+ # Buton
47
+ if st.button("🔍 En iyi ipucuyu öner"):
48
+ hedefler = [w.strip().lower() for w in hedef_input.split(",")]
49
+ yasaklar = [w.strip().lower() for w in yasak_input.split(",")]
50
+
51
+ ipucu = oner_ipucu(hedefler, yasaklar, model)
52
+ if ipucu:
53
+ st.success(f"🎯 Önerilen İpucu: **{ipucu}**")
54
+ else:
55
+ st.error("Uygun ipucu bulunamadı. Kelimeleri kontrol edin.")
config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```json
2
+ {
3
+ "model_type": "embedding",
4
+ "library_name": "gensim",
5
+ "pipeline_tag": "text-classification",
6
+ "tags": [
7
+ "nlp",
8
+ "word2vec",
9
+ "streamlit",
10
+ "codenames",
11
+ "game",
12
+ "strategy"
13
+ ]
14
+ }
model.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ model internetten yüklenir.
2
+ import gensim.downloader as api
3
+ model = api.load("word2vec-google-news-300")
sample_input.json ADDED
File without changes