In [8]:
examples = [
  """
rainproof eligible Tahitian zweihander of the rat (level 47)
ridiculous bland ordinary katana of the myna (level 47)
sawn contraband aloof zweihander of the eel (level 6)
grievous eligible monarch rifle of the rail (level 57)
repetitious prodigal sovereign neckguard of the rail (level 6)
Jamestown profligate willow xiphos of the grouse (level 37)
tallowy hooligan's Samoan falchion of the rat (level 5)
Malawi negligent detached voulge of the eel (level 21)
rigorous handsome apathetic neckguard of the eel (level 35)
reckless arrogant yew xiphos of the grouse (level 12)
rainproof flighty unresponsive overcoat of the eel (level 14)
downbeat flighty sanguine neckguard of the wolf (level 47)
poisonous doppelganger's maple whip of the grouse (level 42)
religious standalone sanguine halberd of the wolf (level 46)
oviparous extravagant ruler's glaive of the rail (level 52)
paintball Icelandic birch cuirass of the grouse (level 21)
transcribing grandiose aloof uniform of the eel (level 1)
relentless manganese rouge armet of the wolf (level 47)
raucous candid dotted whip of the hake (level 21)
tallowy intelligent patchy quarterstaff of the hake (level 31)
ubiquitous flighty ordinary cuirass of the myna (level 23)
sawn organic uninterested dagger of the eel (level 6)
raucous Icelandic normal whip of the myna (level 13)
downbeat handheld oak halberd of the grouse (level 52)
paintball Ugandan noble zweihander of the rail (level 56)
markdown religious patriarch javelin of the rail (level 45)
roundabout Michigan mundane scimitar of the myna (level 46)
tallowy organized mundane iron-mail of the myna (level 46)
jackdaw's navigator's willow whip of the grouse (level 47)
tallowy incandescent Samoan voulge of the rat (level 51)
religious mitigating ordinary xiphos of the myna (level 3)
ubiquitous pagan Tahitian xiphos of the rat (level 6)
blithesome diligent maple scimitar of the grouse (level 13)
thunderbolt flighty monarch dagger of the rail (level 57)
reckless vegan oak dagger of the grouse (level 14)
downbeat elegant Tahitian javelin of the rat (level 15)
ruinous light tropical rifle of the rat (level 13)
markdown manganese standard dagger of the myna (level 17)
rapacious handmade ruler's zweihander of the rail (level 13)
righteous brigand's Samoan voulge of the rat (level 6)
warhawk enlightened standard mace of the myna (level 35)
religious handy patriarch glaive of the rail (level 6)
rimless handy ruby eyeshield of the wolf (level 33)
rainproof outlandish sprinkled mace of the hake (level 16)
ridiculous sandy patchy tunic of the hake (level 36)
Malawi bandit's island tunic of the rat (level 47)
rapacious light sprinkled glaive of the hake (level 15)
ravenous investigator's mediocre falchion of the myna (level 27)
ravenous outlandish ruler's glaive of the rail (level 27)
grievous wandering scarlet eyeshield of the wolf (level 6)
ravenous fumigating ruler's voulge of the rail (level 36)
oviparous propagandist's willow quarterstaff of the grouse (level 3)
raucous abandoned birch armet of the grouse (level 54)
oviparous diligent nonchalant neckguard of the eel (level 46)
markdown navigator's island xiphos of the rat (level 44)
jackdaw's handsome tropical quarterstaff of the rat (level 21)
ridiculous eligible yew neckguard of the grouse (level 15)
Jamestown demanding patriarch neckguard of the rail (level 37)
transcribing intelligent noble halberd of the rail (level 57)
uniform contraband monarch halberd of the rail (level 31)
moonbeam grandiose standard pike of the myna (level 47)
handdown religious detached glaive of the eel (level 13)
odious doppelganger's distant whip of the eel (level 56)
frivolous outlandish distant javelin of the eel (level 2)
Jamestown understandable sovereign iron-mail of the rail (level 27)
ridiculous Ugandan yew dagger of the grouse (level 57)
ubiquitous alligator speckled overcoat of the hake (level 4)
poisonous manganese emperor's quarterstaff of the rail (level 23)
tallowy pagan willow falchion of the grouse (level 21)
ominous extravagant standard bow of the myna (level 15)
relentless scandalous ordinary whip of the myna (level 45)
handdown gigantic Hawaiian yataghan of the rat (level 34)
ruthless mandatory tropical glaive of the rat (level 11)
rapacious religious sprinkled neckguard of the hake (level 36)
rainproof negligible monarch linothorax of the rail (level 54)
warhawk outlandish dotted armet of the hake (level 14)
blithesome contraband ordinary katana of the myna (level 34)
oviparous abandoned island yataghan of the rat (level 46)
reckless Michigan unresponsive rifle of the eel (level 54)
transcribing hooligan's ruler's uniform of the rail (level 21)
paintball random carmine tunic of the wolf (level 47)
Malawi alligator patriarch voulge of the rail (level 2)
blithesome Scandinavian patriarch eyeshield of the rail (level 12)
handsewn doppelganger's distant glaive of the eel (level 16)
ominous prodigal tropical overcoat of the rat (level 3)
frivolous malignant average bow of the myna (level 33)
Jamestown slight apathetic javelin of the eel (level 31)
relentless handmade sprinkled xiphos of the hake (level 25)
raucous religious speckled tunic of the hake (level 6)
religious mitigating patchy overcoat of the hake (level 3)
raucous slight noble xiphos of the rail (level 2)
sawn upstanding aloof javelin of the eel (level 14)
rigorous organic normal cuirass of the myna (level 51)
moonbeam manganese dotted javelin of the hake (level 11)
oviparous obligatory uninterested rifle of the eel (level 15)
poisonous slight emperor's eyeshield of the rail (level 15)
rebellious candid Tahitian mace of the rat (level 45)
jackdaw's handheld rouge uniform of the wolf (level 12)
jackdaw's sandy monarch quarterstaff of the rail (level 46)
thunderbolt profligate dotted rifle of the hake (level 34)
""".strip(),
  'downbeat prodigal balsa rifle of the grouse (level 15)',
]

In [15]:
import collections

Processed = collections.namedtuple('Processed', ['phrases', 'categories'])

def process(examples):
  phrases = collections.Counter()
  categories = collections.defaultdict(list)
  processed = Processed(phrases, categories)
  for example in examples:
    for line in example.split('\n'):
      phrase, suffix = line.split(' of the ')
      phrase = phrase.split()
      for p in phrase:
        phrases[p] += 1
      category, _, level = suffix.split()
      level = int(level.strip(')'))
      categories[category].append((phrase, level))
  return processed

In [18]:
import pprint

processed = process(examples)

pprint.pprint(processed.phrases)
pprint.pprint(processed.categories)


Counter({'religious': 8,
         'neckguard': 7,
         'xiphos': 7,
         'glaive': 7,
         'rifle': 6,
         'whip': 6,
         'javelin': 6,
         'ordinary': 5,
         'monarch': 5,
         'tallowy': 5,
         'voulge': 5,
         'oviparous': 5,
         "ruler's": 5,
         'raucous': 5,
         'quarterstaff': 5,
         'dagger': 5,
         'patriarch': 5,
         'rainproof': 4,
         'Tahitian': 4,
         'zweihander': 4,
         'ridiculous': 4,
         'Jamestown': 4,
         'willow': 4,
         'flighty': 4,
         'overcoat': 4,
         'downbeat': 4,
         'halberd': 4,
         'uniform': 4,
         'manganese': 4,
         'dotted': 4,
         "jackdaw's": 4,
         'tropical': 4,
         'standard': 4,
         'eyeshield': 4,
         'outlandish': 4,
         'sprinkled': 4,
         'tunic': 4,
         'eligible': 3,
         'sawn': 3,
         'contraband': 3,
         'aloof': 3,
         'prodigal': 3,
         'Samoan': 3,
         'falchion': 3,
         'Malawi': 3,
         'reckless': 3,
         'yew': 3,
         'poisonous': 3,
         "doppelganger's": 3,
         'paintball': 3,
         'cuirass': 3,
         'transcribing': 3,
         'relentless': 3,
         'armet': 3,
         'patchy': 3,
         'ubiquitous': 3,
         'noble': 3,
         'markdown': 3,
         'blithesome': 3,
         'rapacious': 3,
         'mace': 3,
         'island': 3,
         'ravenous': 3,
         'distant': 3,
         'slight': 3,
         'katana': 2,
         'grievous': 2,
         'sovereign': 2,
         'profligate': 2,
         "hooligan's": 2,
         'detached': 2,
         'rigorous': 2,
         'handsome': 2,
         'apathetic': 2,
         'unresponsive': 2,
         'sanguine': 2,
         'maple': 2,
         'extravagant': 2,
         'Icelandic': 2,
         'birch': 2,
         'grandiose': 2,
         'rouge': 2,
         'candid': 2,
         'intelligent': 2,
         'organic': 2,
         'uninterested': 2,
         'normal': 2,
         'handheld': 2,
         'oak': 2,
         'Ugandan': 2,
         'Michigan': 2,
         'mundane': 2,
         'scimitar': 2,
         'iron-mail': 2,
         "navigator's": 2,
         'mitigating': 2,
         'pagan': 2,
         'diligent': 2,
         'thunderbolt': 2,
         'light': 2,
         'handmade': 2,
         'warhawk': 2,
         'handy': 2,
         'sandy': 2,
         'abandoned': 2,
         'moonbeam': 2,
         'handdown': 2,
         'frivolous': 2,
         'alligator': 2,
         'speckled': 2,
         "emperor's": 2,
         'ominous': 2,
         'bow': 2,
         'yataghan': 2,
         'bland': 1,
         'repetitious': 1,
         'negligent': 1,
         'arrogant': 1,
         'standalone': 1,
         'roundabout': 1,
         'organized': 1,
         'incandescent': 1,
         'vegan': 1,
         'elegant': 1,
         'ruinous': 1,
         'righteous': 1,
         "brigand's": 1,
         'enlightened': 1,
         'rimless': 1,
         'ruby': 1,
         "bandit's": 1,
         "investigator's": 1,
         'mediocre': 1,
         'wandering': 1,
         'scarlet': 1,
         'fumigating': 1,
         "propagandist's": 1,
         'nonchalant': 1,
         'demanding': 1,
         'pike': 1,
         'odious': 1,
         'understandable': 1,
         'scandalous': 1,
         'gigantic': 1,
         'Hawaiian': 1,
         'ruthless': 1,
         'mandatory': 1,
         'negligible': 1,
         'linothorax': 1,
         'random': 1,
         'carmine': 1,
         'Scandinavian': 1,
         'handsewn': 1,
         'malignant': 1,
         'average': 1,
         'upstanding': 1,
         'obligatory': 1,
         'rebellious': 1,
         'balsa': 1})
defaultdict(<class 'list'>,
            {'eel': [(['sawn', 'contraband', 'aloof', 'zweihander'], 6),
                     (['Malawi', 'negligent', 'detached', 'voulge'], 21),
                     (['rigorous', 'handsome', 'apathetic', 'neckguard'], 35),
                     (['rainproof', 'flighty', 'unresponsive', 'overcoat'], 14),
                     (['transcribing', 'grandiose', 'aloof', 'uniform'], 1),
                     (['sawn', 'organic', 'uninterested', 'dagger'], 6),
                     (['oviparous', 'diligent', 'nonchalant', 'neckguard'], 46),
                     (['handdown', 'religious', 'detached', 'glaive'], 13),
                     (['odious', "doppelganger's", 'distant', 'whip'], 56),
                     (['frivolous', 'outlandish', 'distant', 'javelin'], 2),
                     (['reckless', 'Michigan', 'unresponsive', 'rifle'], 54),
                     (['handsewn', "doppelganger's", 'distant', 'glaive'], 16),
                     (['Jamestown', 'slight', 'apathetic', 'javelin'], 31),
                     (['sawn', 'upstanding', 'aloof', 'javelin'], 14),
                     (['oviparous', 'obligatory', 'uninterested', 'rifle'],
                      15)],
             'grouse': [(['Jamestown', 'profligate', 'willow', 'xiphos'], 37),
                        (['reckless', 'arrogant', 'yew', 'xiphos'], 12),
                        (['poisonous', "doppelganger's", 'maple', 'whip'], 42),
                        (['paintball', 'Icelandic', 'birch', 'cuirass'], 21),
                        (['downbeat', 'handheld', 'oak', 'halberd'], 52),
                        (["jackdaw's", "navigator's", 'willow', 'whip'], 47),
                        (['blithesome', 'diligent', 'maple', 'scimitar'], 13),
                        (['reckless', 'vegan', 'oak', 'dagger'], 14),
                        (['oviparous',
                          "propagandist's",
                          'willow',
                          'quarterstaff'],
                         3),
                        (['raucous', 'abandoned', 'birch', 'armet'], 54),
                        (['ridiculous', 'eligible', 'yew', 'neckguard'], 15),
                        (['ridiculous', 'Ugandan', 'yew', 'dagger'], 57),
                        (['tallowy', 'pagan', 'willow', 'falchion'], 21),
                        (['downbeat', 'prodigal', 'balsa', 'rifle'], 15)],
             'hake': [(['raucous', 'candid', 'dotted', 'whip'], 21),
                      (['tallowy', 'intelligent', 'patchy', 'quarterstaff'],
                       31),
                      (['rainproof', 'outlandish', 'sprinkled', 'mace'], 16),
                      (['ridiculous', 'sandy', 'patchy', 'tunic'], 36),
                      (['rapacious', 'light', 'sprinkled', 'glaive'], 15),
                      (['ubiquitous', 'alligator', 'speckled', 'overcoat'], 4),
                      (['rapacious', 'religious', 'sprinkled', 'neckguard'],
                       36),
                      (['warhawk', 'outlandish', 'dotted', 'armet'], 14),
                      (['relentless', 'handmade', 'sprinkled', 'xiphos'], 25),
                      (['raucous', 'religious', 'speckled', 'tunic'], 6),
                      (['religious', 'mitigating', 'patchy', 'overcoat'], 3),
                      (['moonbeam', 'manganese', 'dotted', 'javelin'], 11),
                      (['thunderbolt', 'profligate', 'dotted', 'rifle'], 34)],
             'myna': [(['ridiculous', 'bland', 'ordinary', 'katana'], 47),
                      (['ubiquitous', 'flighty', 'ordinary', 'cuirass'], 23),
                      (['raucous', 'Icelandic', 'normal', 'whip'], 13),
                      (['roundabout', 'Michigan', 'mundane', 'scimitar'], 46),
                      (['tallowy', 'organized', 'mundane', 'iron-mail'], 46),
                      (['religious', 'mitigating', 'ordinary', 'xiphos'], 3),
                      (['markdown', 'manganese', 'standard', 'dagger'], 17),
                      (['warhawk', 'enlightened', 'standard', 'mace'], 35),
                      (['ravenous', "investigator's", 'mediocre', 'falchion'],
                       27),
                      (['moonbeam', 'grandiose', 'standard', 'pike'], 47),
                      (['ominous', 'extravagant', 'standard', 'bow'], 15),
                      (['relentless', 'scandalous', 'ordinary', 'whip'], 45),
                      (['blithesome', 'contraband', 'ordinary', 'katana'], 34),
                      (['frivolous', 'malignant', 'average', 'bow'], 33),
                      (['rigorous', 'organic', 'normal', 'cuirass'], 51)],
             'rail': [(['grievous', 'eligible', 'monarch', 'rifle'], 57),
                      (['repetitious', 'prodigal', 'sovereign', 'neckguard'],
                       6),
                      (['oviparous', 'extravagant', "ruler's", 'glaive'], 52),
                      (['paintball', 'Ugandan', 'noble', 'zweihander'], 56),
                      (['markdown', 'religious', 'patriarch', 'javelin'], 45),
                      (['thunderbolt', 'flighty', 'monarch', 'dagger'], 57),
                      (['rapacious', 'handmade', "ruler's", 'zweihander'], 13),
                      (['religious', 'handy', 'patriarch', 'glaive'], 6),
                      (['ravenous', 'outlandish', "ruler's", 'glaive'], 27),
                      (['ravenous', 'fumigating', "ruler's", 'voulge'], 36),
                      (['Jamestown', 'demanding', 'patriarch', 'neckguard'],
                       37),
                      (['transcribing', 'intelligent', 'noble', 'halberd'], 57),
                      (['uniform', 'contraband', 'monarch', 'halberd'], 31),
                      (['Jamestown',
                        'understandable',
                        'sovereign',
                        'iron-mail'],
                       27),
                      (['poisonous', 'manganese', "emperor's", 'quarterstaff'],
                       23),
                      (['rainproof', 'negligible', 'monarch', 'linothorax'],
                       54),
                      (['transcribing', "hooligan's", "ruler's", 'uniform'],
                       21),
                      (['Malawi', 'alligator', 'patriarch', 'voulge'], 2),
                      (['blithesome', 'Scandinavian', 'patriarch', 'eyeshield'],
                       12),
                      (['raucous', 'slight', 'noble', 'xiphos'], 2),
                      (['poisonous', 'slight', "emperor's", 'eyeshield'], 15),
                      (["jackdaw's", 'sandy', 'monarch', 'quarterstaff'], 46)],
             'rat': [(['rainproof', 'eligible', 'Tahitian', 'zweihander'], 47),
                     (['tallowy', "hooligan's", 'Samoan', 'falchion'], 5),
                     (['tallowy', 'incandescent', 'Samoan', 'voulge'], 51),
                     (['ubiquitous', 'pagan', 'Tahitian', 'xiphos'], 6),
                     (['downbeat', 'elegant', 'Tahitian', 'javelin'], 15),
                     (['ruinous', 'light', 'tropical', 'rifle'], 13),
                     (['righteous', "brigand's", 'Samoan', 'voulge'], 6),
                     (['Malawi', "bandit's", 'island', 'tunic'], 47),
                     (['markdown', "navigator's", 'island', 'xiphos'], 44),
                     (["jackdaw's", 'handsome', 'tropical', 'quarterstaff'],
                      21),
                     (['handdown', 'gigantic', 'Hawaiian', 'yataghan'], 34),
                     (['ruthless', 'mandatory', 'tropical', 'glaive'], 11),
                     (['oviparous', 'abandoned', 'island', 'yataghan'], 46),
                     (['ominous', 'prodigal', 'tropical', 'overcoat'], 3),
                     (['rebellious', 'candid', 'Tahitian', 'mace'], 45)],
             'wolf': [(['downbeat', 'flighty', 'sanguine', 'neckguard'], 47),
                      (['religious', 'standalone', 'sanguine', 'halberd'], 46),
                      (['relentless', 'manganese', 'rouge', 'armet'], 47),
                      (['rimless', 'handy', 'ruby', 'eyeshield'], 33),
                      (['grievous', 'wandering', 'scarlet', 'eyeshield'], 6),
                      (['paintball', 'random', 'carmine', 'tunic'], 47),
                      (["jackdaw's", 'handheld', 'rouge', 'uniform'], 12)]})

In [ ]: