Dictionary generates word list and keyword list
Added code to generate a list of keywords and frequencies for all cards. Added the CSV output files.
This commit is contained in:
parent
21a52cc5c2
commit
40f12289a2
3 changed files with 1299 additions and 0 deletions
|
|
@ -31,7 +31,21 @@ def word_list(card):
|
|||
return words
|
||||
|
||||
|
||||
def keyword_list(card):
|
||||
if 'booster' not in card or card['booster'] is False:
|
||||
return []
|
||||
if 'type_line' not in card:
|
||||
return []
|
||||
if card['set_type'] in ['funny', 'vanguard', 'memorabilia']:
|
||||
return []
|
||||
if 'oracle_text' not in card:
|
||||
return []
|
||||
if 'keywords' not in card:
|
||||
return []
|
||||
return card['keywords']
|
||||
|
||||
d = {}
|
||||
k = {}
|
||||
for card in data:
|
||||
if 'oracle_text' in card:
|
||||
card_words = word_list(card)
|
||||
|
|
@ -40,11 +54,26 @@ for card in data:
|
|||
d[word] = 1
|
||||
else:
|
||||
d[word] += 1
|
||||
card_keywords = keyword_list(card)
|
||||
for keyword in card_keywords:
|
||||
if keyword not in k:
|
||||
k[keyword] = 1
|
||||
else:
|
||||
k[keyword] += 1
|
||||
|
||||
|
||||
|
||||
|
||||
f_oracle_cards.close()
|
||||
|
||||
output = open('mtgdict.csv', "w+", encoding='utf8')
|
||||
output.write('word,frequency\n')
|
||||
for word in d:
|
||||
output.write(f"{word},{d[word]}\n")
|
||||
output.close()
|
||||
|
||||
k_output = open('mtgkeywords.csv', 'w+', encoding='utf8')
|
||||
k_output.write('keyword,frequency\n')
|
||||
for keyword in k:
|
||||
k_output.write(f"{keyword},{k[keyword]}\n")
|
||||
k_output.close()
|
||||
|
|
|
|||
1059
mtgdict.csv
Normal file
1059
mtgdict.csv
Normal file
File diff suppressed because it is too large
Load diff
211
mtgkeywords.csv
Normal file
211
mtgkeywords.csv
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
keyword,frequency
|
||||
Enchant,875
|
||||
Flying,1565
|
||||
Adapt,12
|
||||
Horsemanship,26
|
||||
Landwalk,114
|
||||
Swampwalk,39
|
||||
Kicker,132
|
||||
Enrage,16
|
||||
Domain,27
|
||||
Cycling,199
|
||||
Bloodthirst,14
|
||||
Trample,403
|
||||
Flash,227
|
||||
Prowess,39
|
||||
Revolt,16
|
||||
First strike,211
|
||||
Fight,62
|
||||
Multikicker,9
|
||||
Awaken,13
|
||||
Hexproof,51
|
||||
Heroic,41
|
||||
Islandwalk,27
|
||||
Scry,166
|
||||
Exalted,29
|
||||
Menace,77
|
||||
Cohort,9
|
||||
Mountainwalk,17
|
||||
Flashback,84
|
||||
Haste,285
|
||||
Reach,128
|
||||
Bestow,29
|
||||
Renown,18
|
||||
Forestwalk,24
|
||||
Cascade,8
|
||||
Equip,232
|
||||
Devoid,98
|
||||
Protection,165
|
||||
Amass,22
|
||||
Vigilance,215
|
||||
Addendum,9
|
||||
Morbid,17
|
||||
Cumulative upkeep,79
|
||||
Threshold,81
|
||||
Indestructible,51
|
||||
Graft,13
|
||||
Assist,16
|
||||
Manifest,15
|
||||
Defender,220
|
||||
Rebound,20
|
||||
Madness,30
|
||||
Infect,41
|
||||
Evoke,13
|
||||
Escape,22
|
||||
Overload,14
|
||||
Clash,25
|
||||
Double strike,41
|
||||
Channel,10
|
||||
Bushido,34
|
||||
Modular,12
|
||||
Sunburst,14
|
||||
Mill,231
|
||||
Partner,26
|
||||
Reinforce,2
|
||||
Will of the council,9
|
||||
Flanking,27
|
||||
Chroma,9
|
||||
Ripple,5
|
||||
Ninjutsu,6
|
||||
Undying,13
|
||||
Surveil,17
|
||||
Suspend,45
|
||||
Exert,22
|
||||
Conspire,9
|
||||
Landcycling,11
|
||||
Basic landcycling,4
|
||||
Typecycling,13
|
||||
Tribute,11
|
||||
Landfall,73
|
||||
Megamorph,25
|
||||
Vanishing,13
|
||||
Shroud,32
|
||||
Retrace,10
|
||||
Dash,17
|
||||
Dethrone,7
|
||||
Lifelink,119
|
||||
Ascend,23
|
||||
Affinity,18
|
||||
Metalcraft,27
|
||||
Unleash,13
|
||||
Convoke,45
|
||||
Entwine,24
|
||||
Ingest,9
|
||||
Deathtouch,107
|
||||
Hidden agenda,15
|
||||
Shadow,34
|
||||
Monstrosity,23
|
||||
Transmute,13
|
||||
Mentor,13
|
||||
Delve,23
|
||||
Delirium,37
|
||||
Mutate,30
|
||||
Spell mastery,15
|
||||
Fear,32
|
||||
Kinship,12
|
||||
Melee,6
|
||||
Grandeur,5
|
||||
Support,11
|
||||
Adamant,17
|
||||
Evolve,13
|
||||
Radiance,8
|
||||
Echo,44
|
||||
Morph,126
|
||||
Level Up,18
|
||||
Fading,16
|
||||
Proliferate,26
|
||||
Explore,13
|
||||
Changeling,31
|
||||
Split second,10
|
||||
Persist,19
|
||||
Afterlife,10
|
||||
Intimidate,17
|
||||
Spectacle,10
|
||||
Scavenge,11
|
||||
Bolster,19
|
||||
Meld,3
|
||||
Amplify,9
|
||||
Buyback,39
|
||||
Epic,5
|
||||
Improvise,13
|
||||
Riot,11
|
||||
Soulshift,26
|
||||
Living weapon,8
|
||||
Battalion,12
|
||||
Cipher,11
|
||||
Legendary landwalk,2
|
||||
Raid,29
|
||||
Unearth,17
|
||||
Miracle,7
|
||||
Phasing,12
|
||||
Swampcycling,1
|
||||
Constellation,25
|
||||
Goad,5
|
||||
Splice,29
|
||||
Crew,29
|
||||
Rampage,12
|
||||
Soulbond,17
|
||||
Companion,10
|
||||
Champion,11
|
||||
Surge,11
|
||||
Fabricate,14
|
||||
Bloodrush,12
|
||||
Council's dilemma,6
|
||||
Banding,23
|
||||
Detain,11
|
||||
Outlast,8
|
||||
Annihilator,8
|
||||
Afflict,9
|
||||
Fateful hour,6
|
||||
Exploit,11
|
||||
Extort,8
|
||||
Forestcycling,2
|
||||
Dredge,11
|
||||
Ferocious,19
|
||||
Inspired,19
|
||||
Forecast,8
|
||||
Devour,10
|
||||
Converge,11
|
||||
Rally,14
|
||||
Strive,17
|
||||
Investigate,23
|
||||
Hellbent,15
|
||||
Populate,6
|
||||
Storm,14
|
||||
Fateseal,1
|
||||
Imprint,19
|
||||
Escalate,8
|
||||
Recover,7
|
||||
Wither,24
|
||||
Eternalize,9
|
||||
Wizardcycling,1
|
||||
Hideaway,3
|
||||
Emerge,10
|
||||
Formidable,12
|
||||
Totem armor,11
|
||||
Haunt,10
|
||||
Transform,4
|
||||
Hexproof from,2
|
||||
Skulk,8
|
||||
Undergrowth,12
|
||||
Desertwalk,1
|
||||
Slivercycling,1
|
||||
Battle Cry,6
|
||||
Fortify,1
|
||||
Provoke,8
|
||||
Transfigure,1
|
||||
Assemble,1
|
||||
Embalm,13
|
||||
Plainswalk,4
|
||||
Jump-start,10
|
||||
Islandcycling,2
|
||||
Prowl,7
|
||||
Lieutenant,1
|
||||
Mountaincycling,1
|
||||
Replicate,6
|
||||
Nonbasic landwalk,1
|
||||
Parley,4
|
||||
Sweep,4
|
||||
Aura Swap,1
|
||||
Gravestorm,1
|
||||
Plainscycling,2
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue