コード例 #1
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def uncheck(ctx, skill):
    data = utility.load()
    if ctx.author.name in data['claims']:
        name = data['claims'][ctx.author.name]
        knight = data['knights'][name]

        if skill in knight['personality']:
            knight['personality'][skill]['check'] = False
            utility.save(data)
            await ctx.send("Unchecked " + skill + " for Sir " + name)
        elif skill in knight['passions']:
            knight['passions'][skill]['check'] = False
            utility.save(data)
            await ctx.send("Unchecked " + skill + " for Sir " + name)
        elif skill in knight['statistics']:
            knight['statistics'][skill]['check'] = False
            utility.save(data)
            await ctx.send("Unchecked " + skill + " for Sir " + name)
        elif skill in knight['skills']:
            knight['skills'][skill]['check'] = False
            utility.save(data)
            await ctx.send("Unchecked " + skill + " for Sir " + name)
        else:
            await ctx.send("Sir " + name + " does not have " + skill +
                           ". Did you mean" + '\'' + closestSkill(skill) +
                           "\'?")
    else:
        await ctx.send("Thou must first claim a knight")
コード例 #2
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def summarize(ctx, *argv):
    # Parse the argument list
    arg_list = []
    for arg in argv:
        arg_list += [arg]

    data = utility.load()

    knight = {}
    name = ""
    if len(argv) > 0:
        name = arg_list[0]
        if name in data['knights']:
            knight = data['knights'][name]
    else:
        if ctx.author.name in data['claims']:
            name = data['claims'][ctx.author.name]
            knight = data['knights'][name]

    if knight:
        # Sum all glory
        glory = 0
        for x in knight['history']:
            glory += x['glory']
        await ctx.send("Sir " + name + " is known to have accumulated " +
                       str(glory) + " points of glory")
    else:
        await ctx.send(
            "The annals of history do not contain the names of every lowborn peasant to walk the earth"
        )
コード例 #3
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def read_notes(ctx, *argv):
    # Parse the argument list
    arg_list = []
    for arg in argv:
        arg_list += [arg]

    data = utility.load()

    knight = {}
    name = ""
    if len(argv) > 0:
        name = arg_list[0]
        if name in data['knights']:
            knight = data['knights'][name]
        else:
            await ctx.send(
                "The annals of history do not contain the names of every lowborn peasant to walk the earth"
            )
            return
    else:
        if ctx.author.name in data['claims']:
            name = data['claims'][ctx.author.name]
            knight = data['knights'][name]
        else:
            await ctx.send(
                "Claim a knight or specify the knight you wish to know")
            return

    if knight:
        narration = "                                  Sir " + name + "'s Notes:\n"
        narration += "---------------------------------------------------------------------\n"
        for key in knight['notes']:
            narration += str(key) + ": " + str(knight['notes'][key]) + "\n"
        await ctx.send(narration)
コード例 #4
0
def combine(selector):
	total = {}
	for path, directories, files in os.walk('evaluations'):
		for file in files:
			if file.endswith('.json'):
				if re.search(selector, file):
					total[file[:-5]] = utility.load(os.path.join('evaluations', file))
		break
	return total
コード例 #5
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def unclaim(ctx):
    data = utility.load()

    if ctx.author.name in data['claims']:
        await ctx.send(ctx.author.name + " hath unclaimed Sir " +
                       data['claims'][ctx.author.name])
        del data['claims'][ctx.author.name]
        utility.save(data)
    else:
        await ctx.send("Thou has not claimed a knight")
コード例 #6
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def claim(ctx, name):
    data = utility.load()

    if name in data['knights']:
        if ctx.author.name in data['claims']:
            await ctx.send("Thou hath already claimed Sir " +
                           data['claims'][ctx.author.name])
        else:
            data['claims'][ctx.author.name] = name
            await ctx.send(ctx.author.name + " has claimed Sir " + name)
            utility.save(data)
    else:
        await ctx.send("I know not this Sir " + name)
コード例 #7
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def remove_note(ctx, note):
    data = utility.load()
    if ctx.author.name in data['claims']:
        name = data['claims'][ctx.author.name]
        knight = data['knights'][name]

        if note in knight['notes']:
            knight['notes'].pop(note)
            utility.save(data)
            await ctx.send("Removed note " + str(note) + " from Sir " + name)
        else:
            ctx.send("Sir " + name + " does not have that note")
    else:
        await ctx.send("Thou must first claim a knight")
コード例 #8
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def remove_passion(ctx, passion):
    data = utility.load()
    if ctx.author.name in data['claims']:
        name = data['claims'][ctx.author.name]
        knight = data['knights'][name]

        if passion in knight['passions']:
            knight['passions'].pop(passion)
            utility.save(data)
            await ctx.send("Removed " + passion + " from Sir " + name)
        else:
            ctx.send("Sir " + name + " does not have the passion " + passion)
    else:
        await ctx.send("Thou must first claim a knight")
コード例 #9
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def note(ctx, note, value):
    data = utility.load()
    if ctx.author.name in data['claims']:
        name = data['claims'][ctx.author.name]
        knight = data['knights'][name]
        if not note in knight['notes']:
            knight['notes'][note] = str(value)
        else:
            knight['notes'][note] = str(value)

        utility.save(data)
        await ctx.send("Note added for Sir " + name + " - " + str(note) +
                       ": " + str(value))
    else:
        await ctx.send("Thou must first claim a knight")
コード例 #10
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def add_passion(ctx, passion, value):
    data = utility.load()
    if ctx.author.name in data['claims']:
        name = data['claims'][ctx.author.name]
        knight = data['knights'][name]

        if not passion in knight['passions']:
            knight['passions'][passion] = {'check': False, 'value': int(value)}
        else:
            knight['passions'][passion]['value'] = int(value)

        utility.save(data)
        await ctx.send("Sir " + name + " has " + str(value) + " " + passion)
    else:
        await ctx.send("Thou must first claim a knight")
コード例 #11
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def set(ctx, skill, value):
    data = utility.load()
    if ctx.author.name in data['claims']:
        name = data['claims'][ctx.author.name]
        knight = data['knights'][name]

        if skill in personality_mirror:
            if not skill in knight['personality']:
                knight['personality'][skill] = {'check': False, 'value': 10}
                knight['personality'][personality_mirror[skill]] = {
                    'check': False,
                    'value': 10
                }

            knight['personality'][skill]['value'] = int(value)
            knight['personality'][
                personality_mirror[skill]]['value'] = 20 - int(value)
            utility.save(data)
            await ctx.send("Sir " + name + " has " + str(value) + " " + skill +
                           " and " + str(knight['personality'][
                               personality_mirror[skill]]['value']) + " " +
                           personality_mirror[skill])
        elif skill in skills:
            if not skill in knight['skills']:
                knight['skills'][skill] = {'check': False, 'value': 10}

            knight['skills'][skill]['value'] = int(value)
            utility.save(data)
            await ctx.send("Sir " + name + " has " + str(value) + " " + skill)
        elif skill in statistics:
            if not skill in knight['statistics']:
                knight['statistics'][skill] = {'check': False, 'value': 10}

            knight['statistics'][skill]['value'] = int(value)
            utility.save(data)
            await ctx.send("Sir " + name + " has " + str(value) + " " + skill)
        elif skill in knight['passions']:
            knight['passions'][skill]['value'] = int(value)
            utility.save(data)
            await ctx.send("Sir " + name + " has " + str(value) + " " + skill)
        else:
            await ctx.send(
                skill +
                " is not a valid trait, skill, passion, or statistic. Did you mean "
                + '\'' + closestSkill(skill) + "\'?")
    else:
        await ctx.send("Thou must first claim a knight")
コード例 #12
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def narrate(ctx, *argv):
    # Parse the argument list
    arg_list = []
    for arg in argv:
        arg_list += [arg]

    data = utility.load()

    knight = {}
    name = ""
    if len(argv) > 0:
        name = arg_list[0]
        if name in data['knights']:
            knight = data['knights'][name]
    else:
        if ctx.author.name in data['claims']:
            name = data['claims'][ctx.author.name]
            knight = data['knights'][name]

    if knight:
        narration = "Hear ye! Hear ye! The legend of Sir " + name + "!\n"
        narration += "---------------------------------------------------------------------\n"
        glory = 0
        knight = data['knights'][name]
        for x in range(len(knight['history'])):
            # Only print the last 10 items due to discord bot post character limit of 2000 characters
            if (x > len(knight['history']) - 20):
                narration += str(
                    knight['history'][x]['glory']
                ) + " glory for " + knight['history'][x]["reason"] + "\n"
            glory += knight['history'][x]['glory']

        narration += "---------------------------------------------------------------------\n"
        narration += str(glory) + " glory total!"

        await ctx.send(narration)
    else:
        await ctx.send(
            "The annals of history do not contain the names of every lowborn peasant to walk the earth"
        )
コード例 #13
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def glorify(ctx, *argv):
    # Parse the argument list
    arg_list = []
    for arg in argv:
        arg_list += [arg]

    name = arg_list[0]
    glory = arg_list[1]
    event = arg_list[-1]

    data = utility.load()

    if name in data['knights']:
        data['knights'][name]['history'].append({
            'glory': int(glory),
            "reason": event
        })
        utility.save(data)
        await ctx.send("May the deeds of Sir " + name +
                       " be celebrated for countless generations")
    else:
        await ctx.send(
            "I could not find that name. Use !knight to add a new knight or check thine spelling"
        )
コード例 #14
0
async def on_ready():
    utility.load()
    print('{0.user} is up'.format(client))
コード例 #15
0
ファイル: vis.py プロジェクト: tyMarking/chompy
import numpy as np
import os
from pathlib import Path
import matplotlib.pyplot as plt

THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
#THIS_FOLDER = "D:/Mass Storage/Math/chompy"

PRIME_DATA_FOLDER = Path(THIS_FOLDER, "./data/analysis/primeData")

#[size, {util.bkey(N) : [g', l', n(g'), n(N), rank(g'), file(g')]}]


files = os.listdir(PRIME_DATA_FOLDER)
for file in files:
	data = util.load(PRIME_DATA_FOLDER / file)

	"""
	Graphs: 
	*histogram of delta by l

	"""

	lXdelta = {}

	for key in data[1].keys():
		N = util.revDKey(key)
		Ndata = data[1][key]
		g = Ndata[0]
		l = Ndata[1]
		etaG = Ndata[2]
コード例 #16
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def roll(ctx, *argv):
    # Take argument list and concatentate as a single string
    argument = ""
    for arg in argv:
        argument += arg

    # Split at all '+' and then split at all '-'
    plus_split = argument.split('+')
    arg_list = []
    for i in plus_split:
        temp = i.split('-')
        if len(temp) > 1:
            arg_list.append(temp[0])
            for k in temp[1:]:
                arg_list.append(str(0 - int(k)))
        else:
            arg_list.append(temp[0])

    rolls = []
    bonus = 0
    total = 0
    message = ""

    # Load the knight claimed by the user, if any exists
    data = utility.load()
    if ctx.author.name in data['claims']:
        name = data['claims'][ctx.author.name]
        knight = data['knights'][name]

        # If the first argument matches the name of a skill, trait, etc. roll for that trait
        skill_name = argv[0]
        if skill_name in knight['personality']:
            await ctx.send(
                ctx.author.display_name +
                utility.roll(skill_name, knight['personality'][skill_name]
                             ['value'], *argv[1:]))
            return
        elif skill_name in knight['passions']:
            await ctx.send(ctx.author.display_name + utility.roll(
                skill_name, knight['passions'][skill_name]['value'], *argv[1:])
                           )
            return
        elif skill_name in knight['statistics']:
            await ctx.send(
                ctx.author.display_name +
                utility.roll(skill_name, knight['statistics'][skill_name]
                             ['value'], *argv[1:]))
            return
        elif skill_name in knight['skills']:
            await ctx.send(ctx.author.display_name + utility.roll(
                skill_name, knight['skills'][skill_name]['value'], *argv[1:]))
            return

    # This is a generic roll. Parse each argument and roll dice
    for it in arg_list:
        try:
            # Straight conversions to integer mean the argument is a bonus
            bonus += int(it)
        except ValueError:
            # Check for rolls like d20 or 2d20
            match_obj1 = re.match(r"\d[d]\d", it)
            match_obj2 = re.match(r"[d]\d", it)
            if match_obj1:
                split = it.split('d')
                num_rolls = int(split[0])
                for i in range(num_rolls):
                    roll_val = random.randint(1, int(split[1]))
                    rolls.append(roll_val)
                    total += roll_val
            elif match_obj2:
                roll_val = random.randint(1, int(it[1:]))
                rolls.append(roll_val)
                total += roll_val
            else:
                await ctx.send(
                    "Skills with spaces should be enclosed with parentheses and claim a knight if you haven't."
                )
                return

    # Format the roll result
    message = ctx.author.name + " Roll: " + str(total +
                                                bonus) + "\n     rolls: ["
    for i in rolls[:-1]:
        message += str(i) + ", "
    if rolls:
        message += str(rolls[-1])
    message += "] "

    if bonus != 0:
        message += "bonus " + str(bonus)

    await ctx.send(message)
コード例 #17
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def describe(ctx, *argv):
    # Parse the argument list
    arg_list = []
    for arg in argv:
        arg_list += [arg]

    data = utility.load()

    knight = {}
    name = ""
    if len(argv) > 0:
        name = arg_list[0]
        if name in data['knights']:
            knight = data['knights'][name]
        else:
            await ctx.send(
                "The annals of history do not contain the names of every lowborn peasant to walk the earth"
            )
            return
    else:
        if ctx.author.name in data['claims']:
            name = data['claims'][ctx.author.name]
            knight = data['knights'][name]
        else:
            await ctx.send(
                "Claim a knight or specify the knight you wish to know")
            return

    if knight:
        narration = "                                  Sir " + name + ":\n"
        narration += "---------------------------------------------------------------------\n"
        narration += "                                  Personality Traits:" + "\n"
        for key, value in personality_mirror.items():
            if list(personality_mirror.keys()).index(
                    key) % 2 == 0:  # Skip every odd key in personality_mirror
                if key in knight['personality']:
                    if knight['personality'][key]['check']:
                        narration += '[x] '
                    else:
                        narration += '[ ] '

                    narration += str(key) + ": " + str(
                        knight['personality'][key]['value']) + ", " + str(
                            value) + ": " + str(
                                knight['personality'][value]['value'])

                    if knight['personality'][value]['check']:
                        narration += ' [x]' + '\n'
                    else:
                        narration += ' [ ]' + '\n'

        narration += "---------------------------------------------------------------------\n"
        narration += "                                         Passions:" + "\n"
        for key in knight['passions']:
            if knight['passions'][key]['check']:
                narration += '[x] '
            else:
                narration += '[ ] '
            narration += str(key) + ": " + str(
                knight['passions'][key]['value']) + "\n"

        narration += "---------------------------------------------------------------------\n"
        narration += "                                         Statistics:" + "\n"
        for key in knight['statistics']:
            if knight['statistics'][key]['check']:
                narration += '[x] '
            else:
                narration += '[ ] '
            narration += str(key) + ": " + str(
                knight['statistics'][key]['value']) + "\n"

        narration += "---------------------------------------------------------------------\n"
        narration += "                                          Derived Stats:" + "\n"
        siz = knight['statistics']['siz']['value']
        dex = knight['statistics']['dex']['value']
        strength = knight['statistics']['str']['value']
        con = knight['statistics']['con']['value']
        app = knight['statistics']['app']['value']

        narration += "Damage: " + str(round((strength + siz) / 6)) + "d6\n"
        narration += "Healing rate: " + str(round(
            (strength + con) / 10)) + "\n"
        narration += "Move rate: " + str(round((strength + dex) / 10)) + "\n"
        narration += "Total hit points: " + str(siz + con) + "\n"
        narration += "Unconscious: " + str(round((siz + con) / 4)) + "\n"

        narration += "---------------------------------------------------------------------\n"
        narration += "                                            Skills:" + "\n"
        for key in knight['skills']:
            if knight['skills'][key]['check']:
                narration += '[x] '
            else:
                narration += '[ ] '
            narration += str(key) + ": " + str(
                knight['skills'][key]['value']) + "\n"

        # Discord messages have a limit of 2000 characters. Print up to 2000 at a time
        i = 0
        DISCORD_MSG_MAX = 2000
        while i < len(narration):
            end_of_chunk = i + DISCORD_MSG_MAX
            if len(narration) > i + DISCORD_MSG_MAX:
                # Look for previous \n to break on
                while narration[end_of_chunk] != '\n':
                    end_of_chunk -= 1

                await ctx.send(narration[i:end_of_chunk])
            else:
                await (ctx.send(narration[i:len(narration)]))

            i += end_of_chunk
コード例 #18
0
    print(model.coef_)
    utility.print_results(X_train, X_test, y_train, y_test, model)


def lasso_regression(X_train, X_test, y_train, y_test, alphas, cv):
    print('Running lasso regression with ' + str(cv) +
          '-fold cross-validation...')
    print('Possible alpha values:')
    print(alphas)

    model = linear_model.LassoCV(alphas=alphas, cv=cv)
    model.fit(X_train, y_train)
    print('Chosen alpha value: ' + str(model.alpha_))
    print('Model weights:')
    print(model.coef_)
    utility.print_results(X_train, X_test, y_train, y_test, model)


if __name__ == '__main__':
    X_train, X_test, y_train, y_test = utility.load()
    X_train, X_test = utility.standardize(X_train, X_test)
    print()

    ordinary_least_squares(X_train, X_test, y_train, y_test)

    ridge_alphas = [0.1, 0.5, 1.0, 5.0, 10.0, 50.0, 100.0, 500.0, 1000.0]
    ridge_regression(X_train, X_test, y_train, y_test, ridge_alphas, 10)

    lasso_alphas = [0.1, 0.5, 1.0, 5.0, 10.0, 50.0, 100.0, 500.0, 1000.0]
    lasso_regression(X_train, X_test, y_train, y_test, lasso_alphas, 10)
コード例 #19
0
ファイル: sbdownloader.py プロジェクト: redawgts/SBDownloader
from bs4 import BeautifulSoup

import utility

from scraper import Story, HTMLFormatter
from utility import Settings

settings_file = "settings.dat"
settings = Settings(settings_file)

# http://forums.spacebattles.com/threads/survival-of-the-fittest-worm-si.297753/
# http://forums.spacebattles.com/threads/to-go-a-viking-asoiaf-au.294304/

url = easygui.enterbox("URL:", "SBDownloader")

if not utility.is_site_down(url):
    doc = utility.get_page(url)
else:
    doc = utility.load("test.html")

soup = BeautifulSoup(doc, "html.parser")

story = Story.parse(soup)
story.download_messages()

fmt = HTMLFormatter()
doc = fmt.export_story(story, settings.author_only)
utility.mkdir(settings.download_path)
utility.save(doc, os.path.join(settings.download_path, story.clean_title+".html"))

settings.store()
コード例 #20
0
ファイル: historian.py プロジェクト: JiUnitK/ScribeBot
async def knight(ctx, name):
    data = utility.load()

    if name in data['knights']:
        await ctx.send("Sir " + name + " is already in the annals of history")
    else:
        data['knights'][name] = {}
        data['knights'][name]['personality'] = {
            'chaste': {
                'check': False,
                'value': 10
            },
            'lustful': {
                'check': False,
                'value': 10
            },
            'energetic': {
                'check': False,
                'value': 10
            },
            'lazy': {
                'check': False,
                'value': 10
            },
            'forgiving': {
                'check': False,
                'value': 10
            },
            'vengeful': {
                'check': False,
                'value': 10
            },
            'generous': {
                'check': False,
                'value': 10
            },
            'selfish': {
                'check': False,
                'value': 10
            },
            'honest': {
                'check': False,
                'value': 10
            },
            'deceitful': {
                'check': False,
                'value': 10
            },
            'just': {
                'check': False,
                'value': 10
            },
            'arbitrary': {
                'check': False,
                'value': 10
            },
            'merciful': {
                'check': False,
                'value': 10
            },
            'cruel': {
                'check': False,
                'value': 10
            },
            'modest': {
                'check': False,
                'value': 10
            },
            'proud': {
                'check': False,
                'value': 10
            },
            'prudent': {
                'check': False,
                'value': 10
            },
            'reckless': {
                'check': False,
                'value': 10
            },
            'spiritual': {
                'check': False,
                'value': 10
            },
            'worldly': {
                'check': False,
                'value': 10
            },
            'temperate': {
                'check': False,
                'value': 10
            },
            'indulgent': {
                'check': False,
                'value': 10
            },
            'trusting': {
                'check': False,
                'value': 10
            },
            'suspicious': {
                'check': False,
                'value': 10
            },
            'valorous': {
                'check': False,
                'value': 10
            },
            'cowardly': {
                'check': False,
                'value': 10
            },
        }
        data['knights'][name]['passions'] = {
            'fealty(lord)': {
                'check': False,
                'value': 15
            },
            'love(family)': {
                'check': False,
                'value': 15
            },
            'hospitality': {
                'check': False,
                'value': 15
            },
            'honor': {
                'check': False,
                'value': 15
            }
        }
        data['knights'][name]['statistics'] = {
            'siz': {
                'check': False,
                'value': 10
            },
            'dex': {
                'check': False,
                'value': 10
            },
            'str': {
                'check': False,
                'value': 10
            },
            'con': {
                'check': False,
                'value': 10
            },
            'app': {
                'check': False,
                'value': 10
            }
        }
        data['knights'][name]['skills'] = {
            "battle": {
                'check': False,
                'value': 10
            },
            "horsemanship": {
                'check': False,
                'value': 10
            },
            "sword": {
                'check': False,
                'value': 10
            },
            "lance": {
                'check': False,
                'value': 10
            },
            "spear": {
                'check': False,
                'value': 6
            },
            "dagger": {
                'check': False,
                'value': 5
            },
            "awareness": {
                'check': False,
                'value': 5
            },
            "boating": {
                'check': False,
                'value': 1
            },
            "compose": {
                'check': False,
                'value': 1
            },
            "courtesy": {
                'check': False,
                'value': 3
            },
            "dancing": {
                'check': False,
                'value': 2
            },
            "faerie lore": {
                'check': False,
                'value': 1
            },
            "falconry": {
                'check': False,
                'value': 3
            },
            "first aid": {
                'check': False,
                'value': 10
            },
            "flirting": {
                'check': False,
                'value': 3
            },
            "folklore": {
                'check': False,
                'value': 2
            },
            "gaming": {
                'check': False,
                'value': 3
            },
            "heraldry": {
                'check': False,
                'value': 3
            },
            "hunting": {
                'check': False,
                'value': 2
            },
            "intrigue": {
                'check': False,
                'value': 3
            },
            "orate": {
                'check': False,
                'value': 3
            },
            "play": {
                'check': False,
                'value': 3
            },
            "read": {
                'check': False,
                'value': 0
            },
            "recognize": {
                'check': False,
                'value': 3
            },
            "religion": {
                'check': False,
                'value': 2
            },
            "romance": {
                'check': False,
                'value': 2
            },
            "singing": {
                'check': False,
                'value': 2
            },
            "stewardship": {
                'check': False,
                'value': 2
            },
            "swimming": {
                'check': False,
                'value': 2
            },
            "tourney": {
                'check': False,
                'value': 2
            },
        }
        data['knights'][name]['history'] = []
        data['knights'][name]['notes'] = {}
        utility.save(data)
        await ctx.send("Thus marks the chapter of Sir " + name +
                       " in the annals of history")
コード例 #21
0
        try:
            for file in os.listdir(TEST_PATH):
                rate, sig = wav.read(os.path.join(TEST_PATH, file))
                feat = extract(sig)
                pca_feats = pca_transform([feat])
                result = words_clf.predict(pca_feats)
                result2 = gender_clf.predict(pca_feats)
                play(result[0])
                play(result2[0])
                os.remove(os.path.join(TEST_PATH, file))
        except Exception as e:
            print(e.__str__())


if __name__ == "__main__":
    # reading the data from saved models in train
    features = load(os.path.join(MODELS_PATH, WORDS_FEATURES))
    words_labels = load(os.path.join(MODELS_PATH, WORDS_LABLES))
    gender_labels = load(os.path.join(MODELS_PATH, GENDER_LABLES))

    pca_obj = PCA(n_components=50, whiten=True)
    pca_fit(features)
    pca_feats = pca_transform(features)
    words_clf = classify(pca_feats, words_labels)
    gender_clf = classify(pca_feats, gender_labels)

    print("words score :", words_clf.score(pca_feats, words_labels) * 100)
    print("gender score :", gender_clf.score(pca_feats, gender_labels) * 100)

    keep_predicting()